Add IfZero construct to lexer + parser
This commit is contained in:
parent
7bc7921fc3
commit
2a65d41cd8
2 changed files with 10 additions and 0 deletions
|
@ -44,6 +44,12 @@ rule entry = parse
|
|||
{ PRINT }
|
||||
| "rec"
|
||||
{ REC }
|
||||
| "ifzero"
|
||||
{ IFZERO }
|
||||
| "then"
|
||||
{ THEN }
|
||||
| "else"
|
||||
{ ELSE }
|
||||
| "->"
|
||||
{ ARROW }
|
||||
| "="
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
%token<string> IDENT
|
||||
%token<int> INTLITERAL
|
||||
%token FUN IN LET PRINT REC
|
||||
%token IFZERO THEN ELSE
|
||||
%token ARROW EQ LPAREN RPAREN
|
||||
%token<RawLambda.binop> MULOP ADDOP
|
||||
%token EOF
|
||||
|
@ -67,6 +68,9 @@ any_term_:
|
|||
{ Lam (x, t) }
|
||||
| LET mode = recursive x = IDENT EQ t1 = any_term IN t2 = any_term
|
||||
{ Let (mode, x, t1, t2) }
|
||||
| IFZERO expr = any_term THEN tIf = any_term ELSE tElse = any_term
|
||||
{ IfZero (expr, tIf, tElse) }
|
||||
|
||||
|
||||
%inline any_term:
|
||||
t = placed(any_term_)
|
||||
|
|
Loading…
Reference in a new issue