diff src/urweb.grm @ 842:d1b6acaec265

&& and ||
author Adam Chlipala <adamc@hcoop.net>
date Sun, 07 Jun 2009 12:01:55 -0400
parents 5154a047c6bc
children 9f0ea203a1ca
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)))