annotate src/lacweb.grm @ 123:e3041657d653

Parsing and elaborating (non-mutual) 'val rec'
author Adam Chlipala <adamc@hcoop.net>
date Thu, 17 Jul 2008 10:09:34 -0400
parents 3739af9e727a
children 5df655503288
rev   line source
adamc@1 1 (* Copyright (c) 2008, Adam Chlipala
adamc@1 2 * All rights reserved.
adamc@1 3 *
adamc@1 4 * Redistribution and use in source and binary forms, with or without
adamc@1 5 * modification, are permitted provided that the following conditions are met:
adamc@1 6 *
adamc@1 7 * - Redistributions of source code must retain the above copyright notice,
adamc@1 8 * this list of conditions and the following disclaimer.
adamc@1 9 * - Redistributions in binary form must reproduce the above copyright notice,
adamc@1 10 * this list of conditions and the following disclaimer in the documentation
adamc@1 11 * and/or other materials provided with the distribution.
adamc@1 12 * - The names of contributors may not be used to endorse or promote products
adamc@1 13 * derived from this software without specific prior written permission.
adamc@1 14 *
adamc@1 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
adamc@1 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
adamc@1 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
adamc@1 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
adamc@1 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
adamc@1 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
adamc@1 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
adamc@1 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
adamc@1 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
adamc@1 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
adamc@1 25 * POSSIBILITY OF SUCH DAMAGE.
adamc@1 26 *)
adamc@1 27
adamc@1 28 (* Grammar for Laconic/Web programs *)
adamc@1 29
adamc@4 30 open Source
adamc@1 31
adamc@1 32 val s = ErrorMsg.spanOf
adamc@1 33
adamc@104 34 fun uppercaseFirst "" = ""
adamc@104 35 | uppercaseFirst s = str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
adamc@104 36
adamc@1 37 %%
adamc@1 38 %header (functor LacwebLrValsFn(structure Token : TOKEN))
adamc@1 39
adamc@1 40 %term
adamc@1 41 EOF
adamc@14 42 | STRING of string | INT of Int64.int | FLOAT of Real64.real
adamc@1 43 | SYMBOL of string | CSYMBOL of string
adamc@1 44 | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE
adamc@18 45 | EQ | COMMA | COLON | DCOLON | TCOLON | DOT | HASH | UNDER | UNDERUNDER
adamc@91 46 | DIVIDE | GT
adamc@123 47 | CON | LTYPE | VAL | REC | AND | FOLD | UNIT | KUNIT
adamc@7 48 | TYPE | NAME
adamc@1 49 | ARROW | LARROW | DARROW
adamc@84 50 | FN | PLUSPLUS | DOLLAR | TWIDDLE
adamc@88 51 | STRUCTURE | SIGNATURE | STRUCT | SIG | END | FUNCTOR | WHERE | EXTERN
adamc@109 52 | INCLUDE | OPEN | CONSTRAINT | CONSTRAINTS | EXPORT
adamc@1 53
adamc@91 54 | XML_BEGIN of string | XML_END
adamc@91 55 | NOTAGS of string
adamc@91 56 | BEGIN_TAG of string | END_TAG of string
adamc@91 57
adamc@30 58 %nonterm
adamc@1 59 file of decl list
adamc@1 60 | decls of decl list
adamc@1 61 | decl of decl
adamc@123 62 | vali of string * con option * exp
adamc@123 63 | valis of (string * con option * exp) list
adamc@1 64
adamc@30 65 | sgn of sgn
adamc@42 66 | sgntm of sgn
adamc@30 67 | sgi of sgn_item
adamc@30 68 | sgis of sgn_item list
adamc@30 69
adamc@30 70 | str of str
adamc@30 71
adamc@1 72 | kind of kind
adamc@1 73 | kcolon of explicitness
adamc@1 74
adamc@34 75 | path of string list * string
adamc@34 76 | spath of str
adamc@59 77 | mpath of string list
adamc@34 78
adamc@1 79 | cexp of con
adamc@1 80 | capps of con
adamc@1 81 | cterm of con
adamc@1 82 | ident of con
adamc@1 83 | rcon of (con * con) list
adamc@83 84 | rconn of (con * con) list
adamc@1 85 | rcone of (con * con) list
adamc@1 86
adamc@8 87 | eexp of exp
adamc@8 88 | eapps of exp
adamc@8 89 | eterm of exp
adamc@12 90 | rexp of (con * exp) list
adamc@91 91 | xml of exp
adamc@91 92 | xmlOne of exp
adamc@8 93
adamc@104 94 | attrs of (con * exp) list
adamc@104 95 | attr of con * exp
adamc@104 96 | attrv of exp
adamc@104 97
adamc@1 98 %verbose (* print summary of errors *)
adamc@1 99 %pos int (* positions *)
adamc@1 100 %start file
adamc@1 101 %pure
adamc@1 102 %eop EOF
adamc@1 103 %noshift EOF
adamc@1 104
adamc@1 105 %name Lacweb
adamc@1 106
adamc@1 107 %nonassoc DARROW
adamc@1 108 %nonassoc COLON
adamc@6 109 %nonassoc DCOLON TCOLON
adamc@1 110 %right COMMA
adamc@1 111 %right ARROW LARROW
adamc@1 112 %right PLUSPLUS
adamc@84 113 %nonassoc TWIDDLE
adamc@1 114 %nonassoc DOLLAR
adamc@1 115 %left DOT
adamc@1 116
adamc@1 117 %%
adamc@1 118
adamc@1 119 file : decls (decls)
adamc@54 120 | SIG sgis ([(DSgn ("?", (SgnConst sgis, s (SIGleft, sgisright))),
adamc@54 121 s (SIGleft, sgisright))])
adamc@1 122
adamc@1 123 decls : ([])
adamc@1 124 | decl decls (decl :: decls)
adamc@1 125
adamc@1 126 decl : CON SYMBOL EQ cexp (DCon (SYMBOL, NONE, cexp), s (CONleft, cexpright))
adamc@1 127 | CON SYMBOL DCOLON kind EQ cexp (DCon (SYMBOL, SOME kind, cexp), s (CONleft, cexpright))
adamc@7 128 | LTYPE SYMBOL EQ cexp (DCon (SYMBOL, SOME (KType, s (LTYPEleft, cexpright)), cexp),
adamc@7 129 s (LTYPEleft, cexpright))
adamc@123 130 | VAL vali (DVal vali, s (VALleft, valiright))
adamc@123 131 | VAL REC valis (DValRec valis, s (VALleft, valisright))
adamc@1 132
adamc@30 133 | SIGNATURE CSYMBOL EQ sgn (DSgn (CSYMBOL, sgn), s (SIGNATUREleft, sgnright))
adamc@30 134 | STRUCTURE CSYMBOL EQ str (DStr (CSYMBOL, NONE, str), s (STRUCTUREleft, strright))
adamc@30 135 | STRUCTURE CSYMBOL COLON sgn EQ str (DStr (CSYMBOL, SOME sgn, str), s (STRUCTUREleft, strright))
adamc@42 136 | FUNCTOR CSYMBOL LPAREN CSYMBOL COLON sgn RPAREN EQ str
adamc@42 137 (DStr (CSYMBOL1, NONE,
adamc@42 138 (StrFun (CSYMBOL2, sgn1, NONE, str), s (FUNCTORleft, strright))),
adamc@42 139 s (FUNCTORleft, strright))
adamc@42 140 | FUNCTOR CSYMBOL LPAREN CSYMBOL COLON sgn RPAREN COLON sgn EQ str
adamc@42 141 (DStr (CSYMBOL1, NONE,
adamc@42 142 (StrFun (CSYMBOL2, sgn1, SOME sgn2, str), s (FUNCTORleft, strright))),
adamc@42 143 s (FUNCTORleft, strright))
adamc@48 144 | EXTERN STRUCTURE CSYMBOL COLON sgn (DFfiStr (CSYMBOL, sgn), s (EXTERNleft, sgnright))
adamc@61 145 | OPEN mpath (case mpath of
adamc@61 146 [] => raise Fail "Impossible mpath parse [1]"
adamc@61 147 | m :: ms => (DOpen (m, ms), s (OPENleft, mpathright)))
adamc@88 148 | OPEN CONSTRAINTS mpath (case mpath of
adamc@88 149 [] => raise Fail "Impossible mpath parse [3]"
adamc@88 150 | m :: ms => (DOpenConstraints (m, ms), s (OPENleft, mpathright)))
adamc@88 151 | CONSTRAINT cterm TWIDDLE cterm (DConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))
adamc@109 152 | EXPORT spath (DExport spath, s (EXPORTleft, spathright))
adamc@30 153
adamc@123 154 vali : SYMBOL EQ eexp (SYMBOL, NONE, eexp)
adamc@123 155 | SYMBOL COLON cexp EQ eexp (SYMBOL, SOME cexp, eexp)
adamc@123 156
adamc@123 157 valis : vali ([vali])
adamc@123 158 | vali AND valis (vali :: valis)
adamc@123 159
adamc@42 160 sgn : sgntm (sgntm)
adamc@40 161 | FUNCTOR LPAREN CSYMBOL COLON sgn RPAREN COLON sgn
adamc@40 162 (SgnFun (CSYMBOL, sgn1, sgn2), s (FUNCTORleft, sgn2right))
adamc@30 163
adamc@42 164 sgntm : SIG sgis END (SgnConst sgis, s (SIGleft, ENDright))
adamc@59 165 | mpath (case mpath of
adamc@61 166 [] => raise Fail "Impossible mpath parse [2]"
adamc@59 167 | [x] => SgnVar x
adamc@59 168 | m :: ms => SgnProj (m,
adamc@59 169 List.take (ms, length ms - 1),
adamc@59 170 List.nth (ms, length ms - 1)),
adamc@59 171 s (mpathleft, mpathright))
adamc@42 172 | sgntm WHERE CON SYMBOL EQ cexp (SgnWhere (sgntm, SYMBOL, cexp), s (sgntmleft, cexpright))
adamc@42 173 | sgntm WHERE LTYPE SYMBOL EQ cexp(SgnWhere (sgntm, SYMBOL, cexp), s (sgntmleft, cexpright))
adamc@42 174 | LPAREN sgn RPAREN (sgn)
adamc@42 175
adamc@30 176 sgi : CON SYMBOL DCOLON kind (SgiConAbs (SYMBOL, kind), s (CONleft, kindright))
adamc@30 177 | LTYPE SYMBOL (SgiConAbs (SYMBOL, (KType, s (LTYPEleft, SYMBOLright))),
adamc@30 178 s (LTYPEleft, SYMBOLright))
adamc@30 179 | CON SYMBOL EQ cexp (SgiCon (SYMBOL, NONE, cexp), s (CONleft, cexpright))
adamc@30 180 | CON SYMBOL DCOLON kind EQ cexp (SgiCon (SYMBOL, SOME kind, cexp), s (CONleft, cexpright))
adamc@30 181 | LTYPE SYMBOL EQ cexp (SgiCon (SYMBOL, SOME (KType, s (LTYPEleft, cexpright)), cexp),
adamc@30 182 s (LTYPEleft, cexpright))
adamc@30 183 | VAL SYMBOL COLON cexp (SgiVal (SYMBOL, cexp), s (VALleft, cexpright))
adamc@30 184
adamc@30 185 | STRUCTURE CSYMBOL COLON sgn (SgiStr (CSYMBOL, sgn), s (STRUCTUREleft, sgnright))
adamc@59 186 | SIGNATURE CSYMBOL EQ sgn (SgiSgn (CSYMBOL, sgn), s (SIGNATUREleft, sgnright))
adamc@42 187 | FUNCTOR CSYMBOL LPAREN CSYMBOL COLON sgn RPAREN COLON sgn
adamc@42 188 (SgiStr (CSYMBOL1,
adamc@42 189 (SgnFun (CSYMBOL2, sgn1, sgn2), s (FUNCTORleft, sgn2right))),
adamc@42 190 s (FUNCTORleft, sgn2right))
adamc@58 191 | INCLUDE sgn (SgiInclude sgn, s (INCLUDEleft, sgnright))
adamc@88 192 | CONSTRAINT cterm TWIDDLE cterm (SgiConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))
adamc@30 193
adamc@30 194 sgis : ([])
adamc@30 195 | sgi sgis (sgi :: sgis)
adamc@30 196
adamc@30 197 str : STRUCT decls END (StrConst decls, s (STRUCTleft, ENDright))
adamc@34 198 | spath (spath)
adamc@40 199 | FUNCTOR LPAREN CSYMBOL COLON sgn RPAREN DARROW str
adamc@40 200 (StrFun (CSYMBOL, sgn, NONE, str), s (FUNCTORleft, strright))
adamc@40 201 | FUNCTOR LPAREN CSYMBOL COLON sgn RPAREN COLON sgn DARROW str
adamc@40 202 (StrFun (CSYMBOL, sgn1, SOME sgn2, str), s (FUNCTORleft, strright))
adamc@44 203 | spath LPAREN str RPAREN (StrApp (spath, str), s (spathleft, RPARENright))
adamc@34 204
adamc@34 205 spath : CSYMBOL (StrVar CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
adamc@34 206 | spath DOT CSYMBOL (StrProj (spath, CSYMBOL), s (spathleft, CSYMBOLright))
adamc@30 207
adamc@1 208 kind : TYPE (KType, s (TYPEleft, TYPEright))
adamc@1 209 | NAME (KName, s (NAMEleft, NAMEright))
adamc@1 210 | LBRACE kind RBRACE (KRecord kind, s (LBRACEleft, RBRACEright))
adamc@1 211 | kind ARROW kind (KArrow (kind1, kind2), s (kind1left, kind2right))
adamc@1 212 | LPAREN kind RPAREN (#1 kind, s (LPARENleft, RPARENright))
adamc@82 213 | KUNIT (KUnit, s (KUNITleft, KUNITright))
adamc@18 214 | UNDERUNDER (KWild, s (UNDERUNDERleft, UNDERUNDERright))
adamc@1 215
adamc@1 216 capps : cterm (cterm)
adamc@1 217 | capps cterm (CApp (capps, cterm), s (cappsleft, ctermright))
adamc@1 218
adamc@1 219 cexp : capps (capps)
adamc@1 220 | cexp ARROW cexp (TFun (cexp1, cexp2), s (cexp1left, cexp2right))
adamc@15 221 | SYMBOL kcolon kind ARROW cexp (TCFun (kcolon, SYMBOL, kind, cexp), s (SYMBOLleft, cexpright))
adamc@1 222
adamc@1 223 | cexp PLUSPLUS cexp (CConcat (cexp1, cexp2), s (cexp1left, cexp1right))
adamc@1 224
adamc@67 225 | FN SYMBOL DARROW cexp (CAbs (SYMBOL, NONE, cexp), s (FNleft, cexpright))
adamc@67 226 | FN SYMBOL DCOLON kind DARROW cexp (CAbs (SYMBOL, SOME kind, cexp), s (FNleft, cexpright))
adamc@84 227 | cterm TWIDDLE cterm DARROW cexp(CDisjoint (cterm1, cterm2, cexp), s (cterm1left, cexpright))
adamc@85 228 | cterm TWIDDLE cterm ARROW cexp (TDisjoint (cterm1, cterm2, cexp), s (cterm1left, cexpright))
adamc@1 229
adamc@8 230 | LPAREN cexp RPAREN DCOLON kind (CAnnot (cexp, kind), s (LPARENleft, kindright))
adamc@6 231
adamc@18 232 | UNDER DCOLON kind (CWild kind, s (UNDERleft, UNDERright))
adamc@18 233
adamc@1 234 kcolon : DCOLON (Explicit)
adamc@1 235 | TCOLON (Implicit)
adamc@1 236
adamc@34 237 path : SYMBOL ([], SYMBOL)
adamc@34 238 | CSYMBOL DOT path (let val (ms, x) = path in (CSYMBOL :: ms, x) end)
adamc@34 239
adamc@59 240 mpath : CSYMBOL ([CSYMBOL])
adamc@59 241 | CSYMBOL DOT mpath (CSYMBOL :: mpath)
adamc@59 242
adamc@1 243 cterm : LPAREN cexp RPAREN (#1 cexp, s (LPARENleft, RPARENright))
adamc@1 244 | LBRACK rcon RBRACK (CRecord rcon, s (LBRACKleft, RBRACKright))
adamc@83 245 | LBRACK rconn RBRACK (CRecord rconn, s (LBRACKleft, RBRACKright))
adamc@1 246 | LBRACE rcone RBRACE (TRecord (CRecord rcone, s (LBRACEleft, RBRACEright)),
adamc@1 247 s (LBRACEleft, RBRACEright))
adamc@1 248 | DOLLAR cterm (TRecord cterm, s (DOLLARleft, ctermright))
adamc@1 249 | HASH CSYMBOL (CName CSYMBOL, s (HASHleft, CSYMBOLright))
adamc@1 250
adamc@34 251 | path (CVar path, s (pathleft, pathright))
adamc@18 252 | UNDER (CWild (KWild, s (UNDERleft, UNDERright)), s (UNDERleft, UNDERright))
adamc@67 253 | FOLD (CFold, s (FOLDleft, FOLDright))
adamc@82 254 | UNIT (CUnit, s (UNITleft, UNITright))
adamc@1 255
adamc@1 256 rcon : ([])
adamc@1 257 | ident EQ cexp ([(ident, cexp)])
adamc@1 258 | ident EQ cexp COMMA rcon ((ident, cexp) :: rcon)
adamc@1 259
adamc@83 260 rconn : ident ([(ident, (CUnit, s (identleft, identright)))])
adamc@83 261 | ident COMMA rconn ((ident, (CUnit, s (identleft, identright))) :: rconn)
adamc@83 262
adamc@1 263 rcone : ([])
adamc@1 264 | ident COLON cexp ([(ident, cexp)])
adamc@1 265 | ident COLON cexp COMMA rcone ((ident, cexp) :: rcone)
adamc@1 266
adamc@1 267 ident : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
adamc@89 268 | path (CVar path, s (pathleft, pathright))
adamc@8 269
adamc@8 270 eapps : eterm (eterm)
adamc@8 271 | eapps eterm (EApp (eapps, eterm), s (eappsleft, etermright))
adamc@8 272 | eapps LBRACK cexp RBRACK (ECApp (eapps, cexp), s (eappsleft, RBRACKright))
adamc@8 273
adamc@8 274 eexp : eapps (eapps)
adamc@8 275 | FN SYMBOL kcolon kind DARROW eexp (ECAbs (kcolon, SYMBOL, kind, eexp), s (FNleft, eexpright))
adamc@8 276 | FN SYMBOL COLON cexp DARROW eexp (EAbs (SYMBOL, SOME cexp, eexp), s (FNleft, eexpright))
adamc@8 277 | FN SYMBOL DARROW eexp (EAbs (SYMBOL, NONE, eexp), s (FNleft, eexpright))
adamc@93 278 | LBRACK cterm TWIDDLE cterm RBRACK DARROW eexp(EDisjoint (cterm1, cterm2, eexp), s (LBRACKleft, RBRACKright))
adamc@93 279 | FN UNIT DARROW eexp (let
adamc@93 280 val loc = s (FNleft, eexpright)
adamc@93 281 in
adamc@93 282 (EAbs ("_", SOME (TRecord (CRecord [], loc), loc), eexp), loc)
adamc@93 283 end)
adamc@8 284
adamc@8 285 | LPAREN eexp RPAREN DCOLON cexp (EAnnot (eexp, cexp), s (LPARENleft, cexpright))
adamc@12 286 | eterm DOT ident (EField (eterm, ident), s (etermleft, identright))
adamc@8 287
adamc@8 288 eterm : LPAREN eexp RPAREN (#1 eexp, s (LPARENleft, RPARENright))
adamc@8 289
adamc@34 290 | path (EVar path, s (pathleft, pathright))
adamc@12 291 | LBRACE rexp RBRACE (ERecord rexp, s (LBRACEleft, RBRACEright))
adamc@110 292 | UNIT (ERecord [], s (UNITleft, UNITright))
adamc@12 293
adamc@14 294 | INT (EPrim (Prim.Int INT), s (INTleft, INTright))
adamc@14 295 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright))
adamc@14 296 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright))
adamc@14 297
adamc@71 298 | FOLD (EFold, s (FOLDleft, FOLDright))
adamc@71 299
adamc@91 300 | XML_BEGIN xml XML_END (xml)
adamc@91 301 | XML_BEGIN XML_END (EApp ((EVar (["Basis"], "cdata"), s (XML_BEGINleft, XML_ENDright)),
adamc@91 302 (EPrim (Prim.String ""), s (XML_BEGINleft, XML_ENDright))),
adamc@91 303 s (XML_BEGINleft, XML_ENDright))
adamc@91 304
adamc@12 305 rexp : ([])
adamc@12 306 | ident EQ eexp ([(ident, eexp)])
adamc@12 307 | ident EQ eexp COMMA rexp ((ident, eexp) :: rexp)
adamc@91 308
adamc@91 309 xml : xmlOne xml (let
adamc@91 310 val pos = s (xmlOneleft, xmlright)
adamc@91 311 in
adamc@91 312 (EApp ((EApp (
adamc@91 313 (ECApp ((EVar (["Basis"], "join"), pos),
adamc@91 314 (CWild (KRecord (KUnit, pos), pos), pos)), pos),
adamc@91 315 xmlOne), pos),
adamc@91 316 xml), pos)
adamc@91 317 end)
adamc@91 318 | xmlOne (xmlOne)
adamc@91 319
adamc@91 320 xmlOne : NOTAGS (EApp ((EVar (["Basis"], "cdata"), s (NOTAGSleft, NOTAGSright)),
adamc@91 321 (EPrim (Prim.String NOTAGS), s (NOTAGSleft, NOTAGSright))),
adamc@91 322 s (NOTAGSleft, NOTAGSright))
adamc@104 323 | BEGIN_TAG attrs DIVIDE GT (let
adamc@92 324 val pos = s (BEGIN_TAGleft, GTright)
adamc@92 325 in
adamc@104 326 (EApp ((EApp ((EApp ((EVar (["Basis"], "tag"), pos),
adamc@104 327 (ERecord attrs, pos)), pos),
adamc@92 328 (EVar ([], BEGIN_TAG), pos)),
adamc@92 329 pos),
adamc@92 330 (EApp ((EVar (["Basis"], "cdata"), pos),
adamc@92 331 (EPrim (Prim.String ""), pos)),
adamc@92 332 pos)), pos)
adamc@92 333 end)
adamc@92 334
adamc@104 335 | BEGIN_TAG attrs GT xml END_TAG(let
adamc@104 336 val pos = s (BEGIN_TAGleft, GTright)
adamc@104 337 in
adamc@104 338 if BEGIN_TAG = END_TAG then
adamc@104 339 (EApp ((EApp ((EApp ((EVar (["Basis"], "tag"), pos),
adamc@104 340 (ERecord attrs, pos)), pos),
adamc@104 341 (EVar ([], BEGIN_TAG), pos)),
adamc@104 342 pos),
adamc@104 343 xml), pos)
adamc@104 344 else
adamc@104 345 (ErrorMsg.errorAt pos "Begin and end tags don't match.";
adamc@104 346 (EFold, pos))
adamc@104 347 end)
adamc@92 348
adamc@104 349 attrs : ([])
adamc@104 350 | attr attrs (attr :: attrs)
adamc@104 351
adamc@104 352 attr : SYMBOL EQ attrv ((CName (uppercaseFirst SYMBOL), s (SYMBOLleft, SYMBOLright)), attrv)
adamc@104 353
adamc@104 354 attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTright))
adamc@104 355 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright))
adamc@104 356 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright))
adamc@110 357 | LBRACE eexp RBRACE (eexp)