diff --git a/src/Lexer.mll b/src/Lexer.mll index ba016f0..19bd802 100644 --- a/src/Lexer.mll +++ b/src/Lexer.mll @@ -44,6 +44,12 @@ rule entry = parse { PRINT } | "rec" { REC } +| "ifzero" + { IFZERO } +| "then" + { THEN } +| "else" + { ELSE } | "->" { ARROW } | "=" diff --git a/src/Parser.mly b/src/Parser.mly index 4f032b2..9e1adba 100644 --- a/src/Parser.mly +++ b/src/Parser.mly @@ -1,6 +1,7 @@ %token IDENT %token INTLITERAL %token FUN IN LET PRINT REC +%token IFZERO THEN ELSE %token ARROW EQ LPAREN RPAREN %token 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_)