summaryrefslogtreecommitdiff
path: root/src/lacweb.grm
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-07-29 16:38:15 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-07-29 16:38:15 -0400
commitaa1b3a24913edd0dc97af0d1fc9e3dc0026a2460 (patch)
treeea20c705efe957d91b540e491ed8b7c6ff58efd9 /src/lacweb.grm
parentc9e2d6c9f290298c0068a72831d314793897f327 (diff)
Parsing basic patterns
Diffstat (limited to 'src/lacweb.grm')
-rw-r--r--src/lacweb.grm20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lacweb.grm b/src/lacweb.grm
index a1a0663f..a5a4f745 100644
--- a/src/lacweb.grm
+++ b/src/lacweb.grm
@@ -51,6 +51,7 @@ fun uppercaseFirst "" = ""
| FN | PLUSPLUS | MINUSMINUS | DOLLAR | TWIDDLE
| STRUCTURE | SIGNATURE | STRUCT | SIG | END | FUNCTOR | WHERE | EXTERN
| INCLUDE | OPEN | CONSTRAINT | CONSTRAINTS | EXPORT
+ | CASE
| XML_BEGIN of string | XML_END
| NOTAGS of string
@@ -99,6 +100,11 @@ fun uppercaseFirst "" = ""
| tag of string * exp
| tagHead of string * exp
+ | branch of pat * exp
+ | branchs of (pat * exp) list
+ | pat of pat
+ | pterm of pat
+
| attrs of (con * exp) list
| attr of con * exp
| attrv of exp
@@ -310,6 +316,7 @@ eexp : eapps (eapps)
| LPAREN eexp RPAREN DCOLON cexp (EAnnot (eexp, cexp), s (LPARENleft, cexpright))
| eexp MINUSMINUS cexp (ECut (eexp, cexp), s (eexpleft, cexpright))
+ | CASE eexp OF barOpt branch branchs (ECase (eexp, branch :: branchs), s (CASEleft, branchsright))
eterm : LPAREN eexp RPAREN (#1 eexp, s (LPARENleft, RPARENright))
@@ -330,6 +337,19 @@ eterm : LPAREN eexp RPAREN (#1 eexp, s (LPARENleft, RPARENright))
(EPrim (Prim.String ""), s (XML_BEGINleft, XML_ENDright))),
s (XML_BEGINleft, XML_ENDright))
+branch : pat DARROW eexp (pat, eexp)
+
+branchs: ([])
+ | BAR branch branchs (branch :: branchs)
+
+pat : pterm (pterm)
+ | cpath pterm (PCon (#1 cpath, #2 cpath, SOME pterm), s (cpathleft, ptermright))
+
+pterm : SYMBOL (PVar SYMBOL, s (SYMBOLleft, SYMBOLright))
+ | cpath (PCon (#1 cpath, #2 cpath, NONE), s (cpathleft, cpathright))
+ | UNDER (PWild, s (UNDERleft, UNDERright))
+ | LPAREN pat RPAREN (pat)
+
rexp : ([])
| ident EQ eexp ([(ident, eexp)])
| ident EQ eexp COMMA rexp ((ident, eexp) :: rexp)