# HG changeset patch # User Adam Chlipala # Date 1244390515 14400 # Node ID d1b6acaec2658601c43f0f955472d686f55c870b # Parent 44c2c089ca15f2a793451def0e2aaf40f7ba393e && and || diff -r 44c2c089ca15 -r d1b6acaec265 src/urweb.grm --- a/src/urweb.grm Sun Jun 07 11:13:18 2009 -0400 +++ b/src/urweb.grm Sun Jun 07 12:01:55 2009 -0400 @@ -202,7 +202,7 @@ | 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 @@ %right SEMI %nonassoc LARROW %nonassoc IF THEN ELSE +%left ANDALSO +%left ORELSE %nonassoc DARROW %nonassoc COLON %nonassoc DCOLON TCOLON @@ -944,6 +946,23 @@ | 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 -r 44c2c089ca15 -r d1b6acaec265 src/urweb.lex --- a/src/urweb.lex Sun Jun 07 11:13:18 2009 -0400 +++ b/src/urweb.lex Sun Jun 07 12:01:55 2009 -0400 @@ -333,6 +333,9 @@ "---" => (Tokens.MINUSMINUSMINUS (pos yypos, pos yypos + size yytext)); "^" => (Tokens.CARET (pos yypos, pos yypos + size yytext)); + "&&" => (Tokens.ANDALSO (pos yypos, pos yypos + size yytext)); + "||" => (Tokens.ORELSE (pos yypos, pos yypos + size yytext)); + "=" => (Tokens.EQ (pos yypos, pos yypos + size yytext)); "<>" => (Tokens.NE (pos yypos, pos yypos + size yytext)); "<" => (Tokens.LT (pos yypos, pos yypos + size yytext)); @@ -377,6 +380,7 @@ "then" => (Tokens.THEN (pos yypos, pos yypos + size yytext)); "else" => (Tokens.ELSE (pos yypos, pos yypos + size yytext)); + "structure" => (Tokens.STRUCTURE (pos yypos, pos yypos + size yytext)); "signature" => (Tokens.SIGNATURE (pos yypos, pos yypos + size yytext)); "struct" => (Tokens.STRUCT (pos yypos, pos yypos + size yytext));