mirror of https://github.com/XAMPPRocky/tokei
Add menhir support (#781)
* Add menhir support * Add menhir support * Fixed bug with Menhir --------- Co-authored-by: XAMPPRocky <4464295+XAMPPRocky@users.noreply.github.com> Co-authored-by: Basile Pesin <basile.pesin@vertmo.org>
This commit is contained in:
parent
913df079c2
commit
099092fa1b
|
|
@ -940,6 +940,16 @@
|
|||
"Max": {
|
||||
"extensions": ["maxpat"]
|
||||
},
|
||||
"Menhir": {
|
||||
"nested": true,
|
||||
"quotes": [["\\\"", "\\\""]],
|
||||
"line_comment": ["//"],
|
||||
"multi_line_comments": [
|
||||
["(*", "*)"],
|
||||
["/*", "*/"]
|
||||
],
|
||||
"extensions": ["mll", "mly", "vy"]
|
||||
},
|
||||
"Meson": {
|
||||
"line_comment": ["#"],
|
||||
"quotes": [["'", "'"], ["'''", "'''"]],
|
||||
|
|
@ -1042,7 +1052,7 @@
|
|||
"OCaml": {
|
||||
"quotes": [["\\\"", "\\\""]],
|
||||
"multi_line_comments": [["(*", "*)"]],
|
||||
"extensions": ["ml", "mli", "mll", "mly", "re", "rei"]
|
||||
"extensions": ["ml", "mli", "re", "rei"]
|
||||
},
|
||||
"Odin": {
|
||||
"extensions": ["odin"],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
// 47 lines 31 code 7 comments 9 blanks
|
||||
|
||||
(* Example from the menhir development with instrumented comments.
|
||||
* (* Note: nested C style comments are not allowed. *)
|
||||
* https://gitlab.inria.fr/fpottier/menhir/-/tree/master/demos/calc-alias *)
|
||||
|
||||
%token<int> INT "42"
|
||||
%token PLUS "+"
|
||||
%token MINUS "-"
|
||||
%token TIMES "*"
|
||||
%token DIV "/"
|
||||
%token LPAREN "("
|
||||
%token RPAREN ")"
|
||||
%token EOL
|
||||
|
||||
(* Token aliases can be used throughout the rest of the grammar. E.g.,
|
||||
they can be used in precedence declarations: *)
|
||||
|
||||
%left "+" "-" /* lowest " precedence */
|
||||
%left "*" "/" /* medium precedence */
|
||||
%nonassoc UMINUS // highest "precedence"
|
||||
|
||||
%start <int> main
|
||||
|
||||
%%
|
||||
|
||||
main:
|
||||
| e = expr EOL
|
||||
{ e }
|
||||
|
||||
(* Token aliases can also be used inside rules: *)
|
||||
|
||||
expr:
|
||||
| i = "42"
|
||||
{ i }
|
||||
| "(" e = expr ")"
|
||||
{ e }
|
||||
| e1 = expr "+" e2 = expr
|
||||
{ e1 + e2 }
|
||||
| e1 = expr "-" e2 = expr
|
||||
{ e1 - e2 }
|
||||
| e1 = expr "*" e2 = expr
|
||||
{ e1 * e2 }
|
||||
| e1 = expr "/" e2 = expr
|
||||
{ e1 / e2 }
|
||||
| "-" e = expr %prec UMINUS
|
||||
{ - e }
|
||||
Loading…
Reference in New Issue