diff options
| author | Pierre-Marie Pédrot | 2015-10-26 11:50:11 +0100 |
|---|---|---|
| committer | Pierre-Marie Pédrot | 2015-10-27 00:03:38 +0100 |
| commit | fb50a8aaf8826349ac8c3a90a6d9b354b9cf34ca (patch) | |
| tree | 87e21a31c37a5314d38cfcd485a2b5fc4b23533b /grammar | |
| parent | aff038fbbe5ade8d58a895b3d2f6e32267c5184c (diff) | |
Type-safe grammar extensions.
Diffstat (limited to 'grammar')
| -rw-r--r-- | grammar/q_util.ml4 | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/grammar/q_util.ml4 b/grammar/q_util.ml4 index 5ec7510f79..19f436f926 100644 --- a/grammar/q_util.ml4 +++ b/grammar/q_util.ml4 @@ -49,7 +49,20 @@ let mlexpr_of_option f = function | None -> <:expr< None >> | Some e -> <:expr< Some $f e$ >> +let mlexpr_of_token = function +| Tok.KEYWORD s -> <:expr< Tok.KEYWORD $mlexpr_of_string s$ >> +| Tok.METAIDENT s -> <:expr< Tok.METAIDENT $mlexpr_of_string s$ >> +| Tok.PATTERNIDENT s -> <:expr< Tok.PATTERNIDENT $mlexpr_of_string s$ >> +| Tok.IDENT s -> <:expr< Tok.IDENT $mlexpr_of_string s$ >> +| Tok.FIELD s -> <:expr< Tok.FIELD $mlexpr_of_string s$ >> +| Tok.INT s -> <:expr< Tok.INT $mlexpr_of_string s$ >> +| Tok.STRING s -> <:expr< Tok.STRING $mlexpr_of_string s$ >> +| Tok.LEFTQMARK -> <:expr< Tok.LEFTQMARK >> +| Tok.BULLET s -> <:expr< Tok.BULLET $mlexpr_of_string s$ >> +| Tok.EOI -> <:expr< Tok.EOI >> + let rec mlexpr_of_prod_entry_key : type s a. (s, a) Pcoq.entry_key -> _ = function + | Pcoq.Atoken t -> <:expr< Pcoq.Atoken $mlexpr_of_token t$ >> | Pcoq.Alist1 s -> <:expr< Pcoq.Alist1 $mlexpr_of_prod_entry_key s$ >> | Pcoq.Alist1sep (s,sep) -> <:expr< Pcoq.Alist1sep $mlexpr_of_prod_entry_key s$ $str:sep$ >> | Pcoq.Alist0 s -> <:expr< Pcoq.Alist0 $mlexpr_of_prod_entry_key s$ >> |
