diff options
-rw-r--r-- | src/urweb.grm | 21 | ||||
-rw-r--r-- | src/urweb.lex | 4 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/urweb.grm b/src/urweb.grm index 0232a3f3..5a2da601 100644 --- a/src/urweb.grm +++ b/src/urweb.grm @@ -202,7 +202,7 @@ fun patType loc (p : pat) = | STRUCTURE | SIGNATURE | STRUCT | SIG | END | FUNCTOR | WHERE | EXTERN | SQL | INCLUDE | OPEN | CONSTRAINT | CONSTRAINTS | EXPORT | TABLE | SEQUENCE | VIEW | COOKIE | STYLE - | CASE | IF | THEN | ELSE + | CASE | IF | THEN | ELSE | ANDALSO | ORELSE | XML_BEGIN of string | XML_END | XML_BEGIN_END of string | NOTAGS of string @@ -365,6 +365,8 @@ fun patType loc (p : pat) = %right SEMI %nonassoc LARROW %nonassoc IF THEN ELSE +%left ANDALSO +%left ORELSE %nonassoc DARROW %nonassoc COLON %nonassoc DCOLON TCOLON @@ -944,6 +946,23 @@ eexp : eapps (eapps) | eexp GT eexp (native_op ("gt", eexp1, eexp2, s (eexp1left, eexp2right))) | eexp GE eexp (native_op ("ge", eexp1, eexp2, s (eexp1left, eexp2right))) + | eexp ANDALSO eexp (let + val loc = s (eexp1left, eexp2right) + in + (ECase (eexp1, [((PCon (["Basis"], "True", NONE), loc), + eexp2), + ((PCon (["Basis"], "False", NONE), loc), + (EVar (["Basis"], "False", Infer), loc))]), loc) + end) + | eexp ORELSE eexp (let + val loc = s (eexp1left, eexp2right) + in + (ECase (eexp1, [((PCon (["Basis"], "True", NONE), loc), + (EVar (["Basis"], "True", Infer), loc)), + ((PCon (["Basis"], "False", NONE), loc), + eexp2)]), loc) + end) + | eexp PLUSPLUS eexp (EConcat (eexp1, eexp2), s (eexp1left, eexp2right)) | eexp CARET eexp (native_op ("strcat", eexp1, eexp2, s (eexp1left, eexp2right))) diff --git a/src/urweb.lex b/src/urweb.lex index c23dfe62..38816a3c 100644 --- a/src/urweb.lex +++ b/src/urweb.lex @@ -333,6 +333,9 @@ notags = [^<{\n]+; <INITIAL> "---" => (Tokens.MINUSMINUSMINUS (pos yypos, pos yypos + size yytext)); <INITIAL> "^" => (Tokens.CARET (pos yypos, pos yypos + size yytext)); +<INITIAL> "&&" => (Tokens.ANDALSO (pos yypos, pos yypos + size yytext)); +<INITIAL> "||" => (Tokens.ORELSE (pos yypos, pos yypos + size yytext)); + <INITIAL> "=" => (Tokens.EQ (pos yypos, pos yypos + size yytext)); <INITIAL> "<>" => (Tokens.NE (pos yypos, pos yypos + size yytext)); <INITIAL> "<" => (Tokens.LT (pos yypos, pos yypos + size yytext)); @@ -377,6 +380,7 @@ notags = [^<{\n]+; <INITIAL> "then" => (Tokens.THEN (pos yypos, pos yypos + size yytext)); <INITIAL> "else" => (Tokens.ELSE (pos yypos, pos yypos + size yytext)); + <INITIAL> "structure" => (Tokens.STRUCTURE (pos yypos, pos yypos + size yytext)); <INITIAL> "signature" => (Tokens.SIGNATURE (pos yypos, pos yypos + size yytext)); <INITIAL> "struct" => (Tokens.STRUCT (pos yypos, pos yypos + size yytext)); |