summaryrefslogtreecommitdiff
path: root/src/urweb.grm
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-06-07 12:01:55 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-06-07 12:01:55 -0400
commit2b3788462fada38dab4a72d036aff5e66b8d9240 (patch)
tree84a97087380ae2e0bff21d4227c8293dc42e80f8 /src/urweb.grm
parent6994a00f608335fc2e835538dfd84b70aa486d0f (diff)
&& and ||
Diffstat (limited to 'src/urweb.grm')
-rw-r--r--src/urweb.grm21
1 files changed, 20 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)))