diff src/lacweb.grm @ 174:7ee424760d2f

Elaborating module constructor patterns; parsing record patterns
author Adam Chlipala <adamc@hcoop.net>
date Thu, 31 Jul 2008 11:28:55 -0400
parents 8221b95cc24c
children b2d752455182
line wrap: on
line diff
--- a/src/lacweb.grm	Thu Jul 31 10:44:52 2008 -0400
+++ b/src/lacweb.grm	Thu Jul 31 11:28:55 2008 -0400
@@ -43,7 +43,7 @@
  | SYMBOL of string | CSYMBOL of string
  | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE
  | EQ | COMMA | COLON | DCOLON | TCOLON | DOT | HASH | UNDER | UNDERUNDER | BAR
- | DIVIDE | GT
+ | DIVIDE | GT | DOTDOTDOT
  | CON | LTYPE | VAL | REC | AND | FOLD | UNIT | KUNIT
  | DATATYPE | OF
  | TYPE | NAME
@@ -104,6 +104,7 @@
  | branchs of (pat * exp) list
  | pat of pat
  | pterm of pat
+ | rpat of (string * pat) list * bool
 
  | attrs of (con * exp) list
  | attr of con * exp
@@ -351,6 +352,13 @@
        | INT                            (PPrim (Prim.Int INT), s (INTleft, INTright))
        | STRING                         (PPrim (Prim.String STRING), s (STRINGleft, STRINGright))
        | LPAREN pat RPAREN              (pat)
+       | LBRACE RBRACE                  (PRecord ([], false), s (LBRACEleft, RBRACEright))
+       | UNIT                           (PRecord ([], false), s (UNITleft, UNITright))
+       | LBRACE rpat RBRACE             (PRecord rpat, s (LBRACEleft, RBRACEright))
+
+rpat   : STRING EQ pat                  ([(STRING, pat)], false)
+       | DOTDOTDOT                      ([], true)
+       | STRING EQ pat COMMA rpat       ((STRING, pat) :: #1 rpat, #2 rpat)
 
 rexp   :                                ([])
        | ident EQ eexp                  ([(ident, eexp)])