diff options
| author | Pierre-Marie Pédrot | 2016-05-11 19:10:04 +0200 |
|---|---|---|
| committer | Pierre-Marie Pédrot | 2016-05-11 19:10:04 +0200 |
| commit | 4d9bcbda2fbf09939cddff4e4b42e5397d8a5cf1 (patch) | |
| tree | c41decbdd8bb9eb81c076cdea6d1c64bbcb0ff94 /grammar/q_util.ml4 | |
| parent | 6be542f4ccb1d7fe95a65f4600f202a2424370d9 (diff) | |
| parent | 9acfdfd9b7d1cae34b97a4c06c52c4646e15589b (diff) | |
Thorough rewriting of the Pcoq API towards safety and static invariants.
Amongst other things:
1. No more unsafe grammar extensions, except when going through the CAMLPX-based
Pcoq.Gram module. This is mostly safe because CAMLPX adds casts to ensure that
parsing rules are well-typed. In particular, constr notation is now based on
GADTs ensuring well-typedness.
2. Less reliance on unsafe coq inside Pcoq, and exposing a self-contained API.
The Entry module was also removed as it now results useless.
3. Purely functional API for synchronized grammar extension. This gets rid of
quite buggy code maintaining a table of empty entries to work around CAMLPX bugs.
The state modification is now explicit and grammar extensions synchronized with
the summary must provide the rules they want to perform instead of doing so
imperatively.
Diffstat (limited to 'grammar/q_util.ml4')
| -rw-r--r-- | grammar/q_util.ml4 | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/grammar/q_util.ml4 b/grammar/q_util.ml4 index c529260e9d..53330429d9 100644 --- a/grammar/q_util.ml4 +++ b/grammar/q_util.ml4 @@ -61,18 +61,20 @@ let mlexpr_of_option f = function let mlexpr_of_ident id = <:expr< Names.Id.of_string $str:id$ >> +let symbol_of_string s = <:expr< Extend.Atoken (CLexer.terminal $str:s$) >> + let rec mlexpr_of_prod_entry_key f = function | Ulist1 s -> <:expr< Extend.Alist1 $mlexpr_of_prod_entry_key f s$ >> - | Ulist1sep (s,sep) -> <:expr< Extend.Alist1sep $mlexpr_of_prod_entry_key f s$ $str:sep$ >> + | Ulist1sep (s,sep) -> <:expr< Extend.Alist1sep $mlexpr_of_prod_entry_key f s$ $symbol_of_string sep$ >> | Ulist0 s -> <:expr< Extend.Alist0 $mlexpr_of_prod_entry_key f s$ >> - | Ulist0sep (s,sep) -> <:expr< Extend.Alist0sep $mlexpr_of_prod_entry_key f s$ $str:sep$ >> + | Ulist0sep (s,sep) -> <:expr< Extend.Alist0sep $mlexpr_of_prod_entry_key f s$ $symbol_of_string sep$ >> | Uopt s -> <:expr< Extend.Aopt $mlexpr_of_prod_entry_key f s$ >> | Uentry e -> <:expr< Extend.Aentry $f e$ >> | Uentryl (e, l) -> (** Keep in sync with Pcoq! *) assert (e = "tactic"); - if l = 5 then <:expr< Extend.Aentry (Pcoq.name_of_entry Pcoq.Tactic.binder_tactic) >> - else <:expr< Extend.Aentryl (Pcoq.name_of_entry Pcoq.Tactic.tactic_expr) $mlexpr_of_int l$ >> + if l = 5 then <:expr< Extend.Aentry (Pcoq.Tactic.binder_tactic) >> + else <:expr< Extend.Aentryl (Pcoq.Tactic.tactic_expr) $mlexpr_of_int l$ >> let rec type_of_user_symbol = function | Ulist1 s | Ulist1sep (s, _) | Ulist0 s | Ulist0sep (s, _) -> |
