comparison 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
comparison
equal deleted inserted replaced
202:af5bd54cbbd7 203:dd82457fda82
32 val s = ErrorMsg.spanOf 32 val s = ErrorMsg.spanOf
33 33
34 fun uppercaseFirst "" = "" 34 fun uppercaseFirst "" = ""
35 | uppercaseFirst s = str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE) 35 | uppercaseFirst s = str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
36 36
37 fun entable t =
38 case #1 t of
39 TRecord c => c
40 | _ => t
41
37 %% 42 %%
38 %header (functor LacwebLrValsFn(structure Token : TOKEN)) 43 %header (functor LacwebLrValsFn(structure Token : TOKEN))
39 44
40 %term 45 %term
41 EOF 46 EOF
48 | DATATYPE | OF 53 | DATATYPE | OF
49 | TYPE | NAME 54 | TYPE | NAME
50 | ARROW | LARROW | DARROW | STAR 55 | ARROW | LARROW | DARROW | STAR
51 | FN | PLUSPLUS | MINUSMINUS | DOLLAR | TWIDDLE 56 | FN | PLUSPLUS | MINUSMINUS | DOLLAR | TWIDDLE
52 | STRUCTURE | SIGNATURE | STRUCT | SIG | END | FUNCTOR | WHERE | EXTERN 57 | STRUCTURE | SIGNATURE | STRUCT | SIG | END | FUNCTOR | WHERE | EXTERN
53 | INCLUDE | OPEN | CONSTRAINT | CONSTRAINTS | EXPORT 58 | INCLUDE | OPEN | CONSTRAINT | CONSTRAINTS | EXPORT | TABLE
54 | CASE | IF | THEN | ELSE 59 | CASE | IF | THEN | ELSE
55 60
56 | XML_BEGIN of string | XML_END 61 | XML_BEGIN of string | XML_END
57 | NOTAGS of string 62 | NOTAGS of string
58 | BEGIN_TAG of string | END_TAG of string 63 | BEGIN_TAG of string | END_TAG of string
175 | OPEN CONSTRAINTS mpath (case mpath of 180 | OPEN CONSTRAINTS mpath (case mpath of
176 [] => raise Fail "Impossible mpath parse [3]" 181 [] => raise Fail "Impossible mpath parse [3]"
177 | m :: ms => (DOpenConstraints (m, ms), s (OPENleft, mpathright))) 182 | m :: ms => (DOpenConstraints (m, ms), s (OPENleft, mpathright)))
178 | CONSTRAINT cterm TWIDDLE cterm (DConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright)) 183 | CONSTRAINT cterm TWIDDLE cterm (DConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))
179 | EXPORT spath (DExport spath, s (EXPORTleft, spathright)) 184 | EXPORT spath (DExport spath, s (EXPORTleft, spathright))
185 | TABLE SYMBOL COLON cexp (DTable (SYMBOL, entable cexp), s (TABLEleft, cexpright))
180 186
181 dargs : ([]) 187 dargs : ([])
182 | SYMBOL dargs (SYMBOL :: dargs) 188 | SYMBOL dargs (SYMBOL :: dargs)
183 189
184 barOpt : () 190 barOpt : ()
232 (SgiStr (CSYMBOL1, 238 (SgiStr (CSYMBOL1,
233 (SgnFun (CSYMBOL2, sgn1, sgn2), s (FUNCTORleft, sgn2right))), 239 (SgnFun (CSYMBOL2, sgn1, sgn2), s (FUNCTORleft, sgn2right))),
234 s (FUNCTORleft, sgn2right)) 240 s (FUNCTORleft, sgn2right))
235 | INCLUDE sgn (SgiInclude sgn, s (INCLUDEleft, sgnright)) 241 | INCLUDE sgn (SgiInclude sgn, s (INCLUDEleft, sgnright))
236 | CONSTRAINT cterm TWIDDLE cterm (SgiConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright)) 242 | CONSTRAINT cterm TWIDDLE cterm (SgiConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))
243 | TABLE SYMBOL COLON cexp (SgiTable (SYMBOL, entable cexp), s (TABLEleft, cexpright))
237 244
238 sgis : ([]) 245 sgis : ([])
239 | sgi sgis (sgi :: sgis) 246 | sgi sgis (sgi :: sgis)
240 247
241 str : STRUCT decls END (StrConst decls, s (STRUCTleft, ENDright)) 248 str : STRUCT decls END (StrConst decls, s (STRUCTleft, ENDright))