Mercurial > urweb
changeset 842:d1b6acaec265
&& and ||
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 07 Jun 2009 12:01:55 -0400 (2009-06-07) |
parents | 44c2c089ca15 |
children | 9f0ea203a1ca |
files | src/urweb.grm src/urweb.lex |
diffstat | 2 files changed, 24 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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)))
--- 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 @@ <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 @@ <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));