aboutsummaryrefslogtreecommitdiff
path: root/coqpp
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2019-03-31 23:07:48 +0200
committerPierre-Marie Pédrot2019-03-31 23:07:48 +0200
commit5dd3c18f4e50eef53ae4413b7b80951f17edad5f (patch)
tree0a104d6afc109b7b89c8997d1afb3bc9f1e89dc3 /coqpp
parentcb502e44aac8328ffd6c37429e050a01f72b2c53 (diff)
parentf832476404a29d7791c1a6d7970988d3b2e3ad9e (diff)
Merge PR #9733: [lexer] keyword protected quotation token for arbitrary text
Ack-by: Zimmi48 Ack-by: ejgallego Ack-by: gares Reviewed-by: ppedrot
Diffstat (limited to 'coqpp')
-rw-r--r--coqpp/coqpp_main.ml17
1 files changed, 5 insertions, 12 deletions
diff --git a/coqpp/coqpp_main.ml b/coqpp/coqpp_main.ml
index 90158c3aa3..f4c819eeb6 100644
--- a/coqpp/coqpp_main.ml
+++ b/coqpp/coqpp_main.ml
@@ -163,6 +163,8 @@ let is_token s = match string_split s with
let rec parse_tokens = function
| [GSymbString s] -> SymbToken ("", Some s)
+| [GSymbQualid ("QUOTATION", None); GSymbString s] ->
+ SymbToken ("QUOTATION", Some s)
| [GSymbQualid ("SELF", None)] -> SymbSelf
| [GSymbQualid ("NEXT", None)] -> SymbNext
| [GSymbQualid ("LIST0", None); tkn] ->
@@ -212,17 +214,9 @@ let print_fun fmt (vars, body) =
(** Meta-program instead of calling Tok.of_pattern here because otherwise
violates value restriction *)
-let print_tok fmt = function
-| "", s -> fprintf fmt "Tok.KEYWORD %a" print_string s
-| "IDENT", s -> fprintf fmt "Tok.IDENT %a" print_string s
-| "PATTERNIDENT", s -> fprintf fmt "Tok.PATTERNIDENT %a" print_string s
-| "FIELD", s -> fprintf fmt "Tok.FIELD %a" print_string s
-| "INT", s -> fprintf fmt "Tok.INT %a" print_string s
-| "STRING", s -> fprintf fmt "Tok.STRING %a" print_string s
-| "LEFTQMARK", _ -> fprintf fmt "Tok.LEFTQMARK"
-| "BULLET", s -> fprintf fmt "Tok.BULLET %a" print_string s
-| "EOI", _ -> fprintf fmt "Tok.EOI"
-| _ -> failwith "Tok.of_pattern: not a constructor"
+let print_tok fmt (k,o) =
+ let print_pat fmt = print_opt fmt print_string in
+ fprintf fmt "(%a,%a)" print_string k print_pat o
let rec print_prod fmt p =
let (vars, tkns) = List.split p.gprod_symbs in
@@ -240,7 +234,6 @@ and print_symbols fmt = function
and print_symbol fmt tkn = match tkn with
| SymbToken (t, s) ->
- let s = match s with None -> "" | Some s -> s in
fprintf fmt "(Extend.Atoken (%a))" print_tok (t, s)
| SymbEntry (e, None) ->
fprintf fmt "(Extend.Aentry %s)" e