aboutsummaryrefslogtreecommitdiff
path: root/coqpp
diff options
context:
space:
mode:
authorPierre Roux2018-10-20 14:40:23 +0200
committerPierre Roux2019-04-02 00:02:21 +0200
commit552bb5aba750785d8f19aa7b333baa59e9199369 (patch)
treedf349e57ff8c34e2da48d8c786d2466426822511 /coqpp
parent4dc3d04d0812005f221e88744c587de8ef0f38ee (diff)
Add parsing of decimal constants (e.g., 1.02e+01)
Rather than integers '[0-9]+', numeral constant can now be parsed according to the regexp '[0-9]+ ([.][0-9]+)? ([eE][+-]?[0-9]+)?'. This can be used in one of the two following ways: - using the function `Notation.register_rawnumeral_interpreter` in an OCaml plugin - using `Numeral Notation` with the type `decimal` added to `Decimal.v` See examples of each use case in the next two commits.
Diffstat (limited to 'coqpp')
-rw-r--r--coqpp/coqpp_main.ml8
1 files changed, 6 insertions, 2 deletions
diff --git a/coqpp/coqpp_main.ml b/coqpp/coqpp_main.ml
index fce4db1869..26e1e25fb9 100644
--- a/coqpp/coqpp_main.ml
+++ b/coqpp/coqpp_main.ml
@@ -225,7 +225,8 @@ function
| "IDENT", s -> fprintf fmt "Tok.PIDENT (%a)" print_pat s
| "PATTERNIDENT", s -> fprintf fmt "Tok.PPATTERNIDENT (%a)" print_pat s
| "FIELD", s -> fprintf fmt "Tok.PFIELD (%a)" print_pat s
-| "NUMERAL", s -> fprintf fmt "Tok.PNUMERAL (%a)" print_pat s
+| "NUMERAL", None -> fprintf fmt "Tok.PNUMERAL None"
+| "NUMERAL", Some s -> fprintf fmt "Tok.PNUMERAL (Some (NumTok.int %a))" print_string s
| "STRING", s -> fprintf fmt "Tok.PSTRING (%a)" print_pat s
| "LEFTQMARK", None -> fprintf fmt "Tok.PLEFTQMARK"
| "BULLET", s -> fprintf fmt "Tok.PBULLET (%a)" print_pat s
@@ -463,7 +464,10 @@ end =
struct
let terminal s =
- let c = Printf.sprintf "Extend.Atoken (CLexer.terminal \"%s\")" s in
+ let p =
+ if s <> "" && s.[0] >= '0' && s.[0] <= '9' then "CLexer.terminal_numeral"
+ else "CLexer.terminal" in
+ let c = Printf.sprintf "Extend.Atoken (%s \"%s\")" p s in
SymbQuote c
let rec parse_symb self = function