diff src/lacweb.grm @ 203:dd82457fda82

Parsing and elaborating 'table'
author Adam Chlipala <adamc@hcoop.net>
date Thu, 14 Aug 2008 13:20:29 -0400
parents 5dbba661deab
children 241c9a0e3397
line wrap: on
line diff
--- a/src/lacweb.grm	Tue Aug 12 14:55:05 2008 -0400
+++ b/src/lacweb.grm	Thu Aug 14 13:20:29 2008 -0400
@@ -34,6 +34,11 @@
 fun uppercaseFirst "" = ""
   | uppercaseFirst s = str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
 
+fun entable t =
+    case #1 t of
+        TRecord c => c
+      | _ => t
+
 %%
 %header (functor LacwebLrValsFn(structure Token : TOKEN))
 
@@ -50,7 +55,7 @@
  | ARROW | LARROW | DARROW | STAR
  | FN | PLUSPLUS | MINUSMINUS | DOLLAR | TWIDDLE
  | STRUCTURE | SIGNATURE | STRUCT | SIG | END | FUNCTOR | WHERE | EXTERN
- | INCLUDE | OPEN | CONSTRAINT | CONSTRAINTS | EXPORT
+ | INCLUDE | OPEN | CONSTRAINT | CONSTRAINTS | EXPORT | TABLE
  | CASE | IF | THEN | ELSE
 
  | XML_BEGIN of string | XML_END
@@ -177,6 +182,7 @@
                                            | m :: ms => (DOpenConstraints (m, ms), s (OPENleft, mpathright)))
        | CONSTRAINT cterm TWIDDLE cterm (DConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))
        | EXPORT spath                   (DExport spath, s (EXPORTleft, spathright))
+       | TABLE SYMBOL COLON cexp        (DTable (SYMBOL, entable cexp), s (TABLEleft, cexpright))
 
 dargs  :                                ([])
        | SYMBOL dargs                   (SYMBOL :: dargs)
@@ -234,6 +240,7 @@
                                          s (FUNCTORleft, sgn2right))
        | INCLUDE sgn                    (SgiInclude sgn, s (INCLUDEleft, sgnright))
        | CONSTRAINT cterm TWIDDLE cterm (SgiConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))
+       | TABLE SYMBOL COLON cexp        (SgiTable (SYMBOL, entable cexp), s (TABLEleft, cexpright))
 
 sgis   :                                ([])
        | sgi sgis                       (sgi :: sgis)