annotate src/lacweb.grm @ 149:7420fa18d657

Record cut
author Adam Chlipala <adamc@hcoop.net>
date Thu, 24 Jul 2008 10:09:21 -0400
parents 6f9e224692ec
children 34ccd7d2bea8
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@149 50 | FN | PLUSPLUS | MINUSMINUS | 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@141 93 | tag of string * exp
adamc@141 94 | tagHead of string * exp
adamc@8 95
adamc@104 96 | attrs of (con * exp) list
adamc@104 97 | attr of con * exp
adamc@104 98 | attrv of exp
adamc@104 99
adamc@1 100 %verbose (* print summary of errors *)
adamc@1 101 %pos int (* positions *)
adamc@1 102 %start file
adamc@1 103 %pure
adamc@1 104 %eop EOF
adamc@1 105 %noshift EOF
adamc@1 106
adamc@1 107 %name Lacweb
adamc@1 108
adamc@1 109 %nonassoc DARROW
adamc@1 110 %nonassoc COLON
adamc@6 111 %nonassoc DCOLON TCOLON
adamc@1 112 %right COMMA
adamc@1 113 %right ARROW LARROW
adamc@149 114 %right PLUSPLUS MINUSMINUS
adamc@84 115 %nonassoc TWIDDLE
adamc@1 116 %nonassoc DOLLAR
adamc@1 117 %left DOT
adamc@1 118
adamc@1 119 %%
adamc@1 120
adamc@1 121 file : decls (decls)
adamc@54 122 | SIG sgis ([(DSgn ("?", (SgnConst sgis, s (SIGleft, sgisright))),
adamc@54 123 s (SIGleft, sgisright))])
adamc@1 124
adamc@1 125 decls : ([])
adamc@1 126 | decl decls (decl :: decls)
adamc@1 127
adamc@1 128 decl : CON SYMBOL EQ cexp (DCon (SYMBOL, NONE, cexp), s (CONleft, cexpright))
adamc@1 129 | CON SYMBOL DCOLON kind EQ cexp (DCon (SYMBOL, SOME kind, cexp), s (CONleft, cexpright))
adamc@7 130 | LTYPE SYMBOL EQ cexp (DCon (SYMBOL, SOME (KType, s (LTYPEleft, cexpright)), cexp),
adamc@7 131 s (LTYPEleft, cexpright))
adamc@123 132 | VAL vali (DVal vali, s (VALleft, valiright))
adamc@123 133 | VAL REC valis (DValRec valis, s (VALleft, valisright))
adamc@1 134
adamc@30 135 | SIGNATURE CSYMBOL EQ sgn (DSgn (CSYMBOL, sgn), s (SIGNATUREleft, sgnright))
adamc@30 136 | STRUCTURE CSYMBOL EQ str (DStr (CSYMBOL, NONE, str), s (STRUCTUREleft, strright))
adamc@30 137 | STRUCTURE CSYMBOL COLON sgn EQ str (DStr (CSYMBOL, SOME sgn, str), s (STRUCTUREleft, strright))
adamc@42 138 | FUNCTOR CSYMBOL LPAREN CSYMBOL COLON sgn RPAREN EQ str
adamc@42 139 (DStr (CSYMBOL1, NONE,
adamc@42 140 (StrFun (CSYMBOL2, sgn1, NONE, str), s (FUNCTORleft, strright))),
adamc@42 141 s (FUNCTORleft, strright))
adamc@42 142 | FUNCTOR CSYMBOL LPAREN CSYMBOL COLON sgn RPAREN COLON sgn EQ str
adamc@42 143 (DStr (CSYMBOL1, NONE,
adamc@42 144 (StrFun (CSYMBOL2, sgn1, SOME sgn2, str), s (FUNCTORleft, strright))),
adamc@42 145 s (FUNCTORleft, strright))
adamc@48 146 | EXTERN STRUCTURE CSYMBOL COLON sgn (DFfiStr (CSYMBOL, sgn), s (EXTERNleft, sgnright))
adamc@61 147 | OPEN mpath (case mpath of
adamc@61 148 [] => raise Fail "Impossible mpath parse [1]"
adamc@61 149 | m :: ms => (DOpen (m, ms), s (OPENleft, mpathright)))
adamc@88 150 | OPEN CONSTRAINTS mpath (case mpath of
adamc@88 151 [] => raise Fail "Impossible mpath parse [3]"
adamc@88 152 | m :: ms => (DOpenConstraints (m, ms), s (OPENleft, mpathright)))
adamc@88 153 | CONSTRAINT cterm TWIDDLE cterm (DConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))
adamc@109 154 | EXPORT spath (DExport spath, s (EXPORTleft, spathright))
adamc@30 155
adamc@123 156 vali : SYMBOL EQ eexp (SYMBOL, NONE, eexp)
adamc@123 157 | SYMBOL COLON cexp EQ eexp (SYMBOL, SOME cexp, eexp)
adamc@123 158
adamc@123 159 valis : vali ([vali])
adamc@123 160 | vali AND valis (vali :: valis)
adamc@123 161
adamc@42 162 sgn : sgntm (sgntm)
adamc@40 163 | FUNCTOR LPAREN CSYMBOL COLON sgn RPAREN COLON sgn
adamc@40 164 (SgnFun (CSYMBOL, sgn1, sgn2), s (FUNCTORleft, sgn2right))
adamc@30 165
adamc@42 166 sgntm : SIG sgis END (SgnConst sgis, s (SIGleft, ENDright))
adamc@59 167 | mpath (case mpath of
adamc@61 168 [] => raise Fail "Impossible mpath parse [2]"
adamc@59 169 | [x] => SgnVar x
adamc@59 170 | m :: ms => SgnProj (m,
adamc@59 171 List.take (ms, length ms - 1),
adamc@59 172 List.nth (ms, length ms - 1)),
adamc@59 173 s (mpathleft, mpathright))
adamc@42 174 | sgntm WHERE CON SYMBOL EQ cexp (SgnWhere (sgntm, SYMBOL, cexp), s (sgntmleft, cexpright))
adamc@42 175 | sgntm WHERE LTYPE SYMBOL EQ cexp(SgnWhere (sgntm, SYMBOL, cexp), s (sgntmleft, cexpright))
adamc@42 176 | LPAREN sgn RPAREN (sgn)
adamc@42 177
adamc@30 178 sgi : CON SYMBOL DCOLON kind (SgiConAbs (SYMBOL, kind), s (CONleft, kindright))
adamc@30 179 | LTYPE SYMBOL (SgiConAbs (SYMBOL, (KType, s (LTYPEleft, SYMBOLright))),
adamc@30 180 s (LTYPEleft, SYMBOLright))
adamc@30 181 | CON SYMBOL EQ cexp (SgiCon (SYMBOL, NONE, cexp), s (CONleft, cexpright))
adamc@30 182 | CON SYMBOL DCOLON kind EQ cexp (SgiCon (SYMBOL, SOME kind, cexp), s (CONleft, cexpright))
adamc@30 183 | LTYPE SYMBOL EQ cexp (SgiCon (SYMBOL, SOME (KType, s (LTYPEleft, cexpright)), cexp),
adamc@30 184 s (LTYPEleft, cexpright))
adamc@30 185 | VAL SYMBOL COLON cexp (SgiVal (SYMBOL, cexp), s (VALleft, cexpright))
adamc@30 186
adamc@30 187 | STRUCTURE CSYMBOL COLON sgn (SgiStr (CSYMBOL, sgn), s (STRUCTUREleft, sgnright))
adamc@59 188 | SIGNATURE CSYMBOL EQ sgn (SgiSgn (CSYMBOL, sgn), s (SIGNATUREleft, sgnright))
adamc@42 189 | FUNCTOR CSYMBOL LPAREN CSYMBOL COLON sgn RPAREN COLON sgn
adamc@42 190 (SgiStr (CSYMBOL1,
adamc@42 191 (SgnFun (CSYMBOL2, sgn1, sgn2), s (FUNCTORleft, sgn2right))),
adamc@42 192 s (FUNCTORleft, sgn2right))
adamc@58 193 | INCLUDE sgn (SgiInclude sgn, s (INCLUDEleft, sgnright))
adamc@88 194 | CONSTRAINT cterm TWIDDLE cterm (SgiConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))
adamc@30 195
adamc@30 196 sgis : ([])
adamc@30 197 | sgi sgis (sgi :: sgis)
adamc@30 198
adamc@30 199 str : STRUCT decls END (StrConst decls, s (STRUCTleft, ENDright))
adamc@34 200 | spath (spath)
adamc@40 201 | FUNCTOR LPAREN CSYMBOL COLON sgn RPAREN DARROW str
adamc@40 202 (StrFun (CSYMBOL, sgn, NONE, str), s (FUNCTORleft, strright))
adamc@40 203 | FUNCTOR LPAREN CSYMBOL COLON sgn RPAREN COLON sgn DARROW str
adamc@40 204 (StrFun (CSYMBOL, sgn1, SOME sgn2, str), s (FUNCTORleft, strright))
adamc@44 205 | spath LPAREN str RPAREN (StrApp (spath, str), s (spathleft, RPARENright))
adamc@34 206
adamc@34 207 spath : CSYMBOL (StrVar CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
adamc@34 208 | spath DOT CSYMBOL (StrProj (spath, CSYMBOL), s (spathleft, CSYMBOLright))
adamc@30 209
adamc@1 210 kind : TYPE (KType, s (TYPEleft, TYPEright))
adamc@1 211 | NAME (KName, s (NAMEleft, NAMEright))
adamc@1 212 | LBRACE kind RBRACE (KRecord kind, s (LBRACEleft, RBRACEright))
adamc@1 213 | kind ARROW kind (KArrow (kind1, kind2), s (kind1left, kind2right))
adamc@1 214 | LPAREN kind RPAREN (#1 kind, s (LPARENleft, RPARENright))
adamc@82 215 | KUNIT (KUnit, s (KUNITleft, KUNITright))
adamc@18 216 | UNDERUNDER (KWild, s (UNDERUNDERleft, UNDERUNDERright))
adamc@1 217
adamc@1 218 capps : cterm (cterm)
adamc@1 219 | capps cterm (CApp (capps, cterm), s (cappsleft, ctermright))
adamc@1 220
adamc@1 221 cexp : capps (capps)
adamc@1 222 | cexp ARROW cexp (TFun (cexp1, cexp2), s (cexp1left, cexp2right))
adamc@15 223 | SYMBOL kcolon kind ARROW cexp (TCFun (kcolon, SYMBOL, kind, cexp), s (SYMBOLleft, cexpright))
adamc@1 224
adamc@1 225 | cexp PLUSPLUS cexp (CConcat (cexp1, cexp2), s (cexp1left, cexp1right))
adamc@1 226
adamc@67 227 | FN SYMBOL DARROW cexp (CAbs (SYMBOL, NONE, cexp), s (FNleft, cexpright))
adamc@67 228 | FN SYMBOL DCOLON kind DARROW cexp (CAbs (SYMBOL, SOME kind, cexp), s (FNleft, cexpright))
adamc@84 229 | cterm TWIDDLE cterm DARROW cexp(CDisjoint (cterm1, cterm2, cexp), s (cterm1left, cexpright))
adamc@85 230 | cterm TWIDDLE cterm ARROW cexp (TDisjoint (cterm1, cterm2, cexp), s (cterm1left, cexpright))
adamc@1 231
adamc@8 232 | LPAREN cexp RPAREN DCOLON kind (CAnnot (cexp, kind), s (LPARENleft, kindright))
adamc@6 233
adamc@18 234 | UNDER DCOLON kind (CWild kind, s (UNDERleft, UNDERright))
adamc@18 235
adamc@1 236 kcolon : DCOLON (Explicit)
adamc@1 237 | TCOLON (Implicit)
adamc@1 238
adamc@34 239 path : SYMBOL ([], SYMBOL)
adamc@34 240 | CSYMBOL DOT path (let val (ms, x) = path in (CSYMBOL :: ms, x) end)
adamc@34 241
adamc@59 242 mpath : CSYMBOL ([CSYMBOL])
adamc@59 243 | CSYMBOL DOT mpath (CSYMBOL :: mpath)
adamc@59 244
adamc@1 245 cterm : LPAREN cexp RPAREN (#1 cexp, s (LPARENleft, RPARENright))
adamc@1 246 | LBRACK rcon RBRACK (CRecord rcon, s (LBRACKleft, RBRACKright))
adamc@83 247 | LBRACK rconn RBRACK (CRecord rconn, s (LBRACKleft, RBRACKright))
adamc@1 248 | LBRACE rcone RBRACE (TRecord (CRecord rcone, s (LBRACEleft, RBRACEright)),
adamc@1 249 s (LBRACEleft, RBRACEright))
adamc@1 250 | DOLLAR cterm (TRecord cterm, s (DOLLARleft, ctermright))
adamc@1 251 | HASH CSYMBOL (CName CSYMBOL, s (HASHleft, CSYMBOLright))
adamc@1 252
adamc@34 253 | path (CVar path, s (pathleft, pathright))
adamc@18 254 | UNDER (CWild (KWild, s (UNDERleft, UNDERright)), s (UNDERleft, UNDERright))
adamc@67 255 | FOLD (CFold, s (FOLDleft, FOLDright))
adamc@82 256 | UNIT (CUnit, s (UNITleft, UNITright))
adamc@1 257
adamc@1 258 rcon : ([])
adamc@1 259 | ident EQ cexp ([(ident, cexp)])
adamc@1 260 | ident EQ cexp COMMA rcon ((ident, cexp) :: rcon)
adamc@1 261
adamc@83 262 rconn : ident ([(ident, (CUnit, s (identleft, identright)))])
adamc@83 263 | ident COMMA rconn ((ident, (CUnit, s (identleft, identright))) :: rconn)
adamc@83 264
adamc@1 265 rcone : ([])
adamc@1 266 | ident COLON cexp ([(ident, cexp)])
adamc@1 267 | ident COLON cexp COMMA rcone ((ident, cexp) :: rcone)
adamc@1 268
adamc@1 269 ident : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
adamc@89 270 | path (CVar path, s (pathleft, pathright))
adamc@8 271
adamc@8 272 eapps : eterm (eterm)
adamc@8 273 | eapps eterm (EApp (eapps, eterm), s (eappsleft, etermright))
adamc@8 274 | eapps LBRACK cexp RBRACK (ECApp (eapps, cexp), s (eappsleft, RBRACKright))
adamc@8 275
adamc@8 276 eexp : eapps (eapps)
adamc@8 277 | FN SYMBOL kcolon kind DARROW eexp (ECAbs (kcolon, SYMBOL, kind, eexp), s (FNleft, eexpright))
adamc@8 278 | FN SYMBOL COLON cexp DARROW eexp (EAbs (SYMBOL, SOME cexp, eexp), s (FNleft, eexpright))
adamc@8 279 | FN SYMBOL DARROW eexp (EAbs (SYMBOL, NONE, eexp), s (FNleft, eexpright))
adamc@93 280 | LBRACK cterm TWIDDLE cterm RBRACK DARROW eexp(EDisjoint (cterm1, cterm2, eexp), s (LBRACKleft, RBRACKright))
adamc@93 281 | FN UNIT DARROW eexp (let
adamc@93 282 val loc = s (FNleft, eexpright)
adamc@93 283 in
adamc@93 284 (EAbs ("_", SOME (TRecord (CRecord [], loc), loc), eexp), loc)
adamc@93 285 end)
adamc@8 286
adamc@8 287 | LPAREN eexp RPAREN DCOLON cexp (EAnnot (eexp, cexp), s (LPARENleft, cexpright))
adamc@149 288 | eexp MINUSMINUS cexp (ECut (eexp, cexp), s (eexpleft, cexpright))
adamc@8 289
adamc@8 290 eterm : LPAREN eexp RPAREN (#1 eexp, s (LPARENleft, RPARENright))
adamc@8 291
adamc@34 292 | path (EVar path, s (pathleft, pathright))
adamc@12 293 | LBRACE rexp RBRACE (ERecord rexp, s (LBRACEleft, RBRACEright))
adamc@110 294 | UNIT (ERecord [], s (UNITleft, UNITright))
adamc@12 295
adamc@14 296 | INT (EPrim (Prim.Int INT), s (INTleft, INTright))
adamc@14 297 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright))
adamc@14 298 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright))
adamc@14 299
adamc@142 300 | path DOT ident (EField ((EVar path, s (pathleft, pathright)), ident), s (pathleft, identright))
adamc@71 301 | FOLD (EFold, s (FOLDleft, FOLDright))
adamc@71 302
adamc@91 303 | XML_BEGIN xml XML_END (xml)
adamc@91 304 | XML_BEGIN XML_END (EApp ((EVar (["Basis"], "cdata"), s (XML_BEGINleft, XML_ENDright)),
adamc@91 305 (EPrim (Prim.String ""), s (XML_BEGINleft, XML_ENDright))),
adamc@91 306 s (XML_BEGINleft, XML_ENDright))
adamc@91 307
adamc@12 308 rexp : ([])
adamc@12 309 | ident EQ eexp ([(ident, eexp)])
adamc@12 310 | ident EQ eexp COMMA rexp ((ident, eexp) :: rexp)
adamc@91 311
adamc@141 312 xml : xmlOne xml (let
adamc@141 313 val pos = s (xmlOneleft, xmlright)
adamc@141 314 in
adamc@141 315 (EApp ((EApp (
adamc@141 316 (EVar (["Basis"], "join"), pos),
adamc@91 317 xmlOne), pos),
adamc@141 318 xml), pos)
adamc@141 319 end)
adamc@141 320 | xmlOne (xmlOne)
adamc@91 321
adamc@141 322 xmlOne : NOTAGS (EApp ((EVar (["Basis"], "cdata"), s (NOTAGSleft, NOTAGSright)),
adamc@141 323 (EPrim (Prim.String NOTAGS), s (NOTAGSleft, NOTAGSright))),
adamc@141 324 s (NOTAGSleft, NOTAGSright))
adamc@141 325 | tag DIVIDE GT (let
adamc@141 326 val pos = s (tagleft, GTright)
adamc@141 327 in
adamc@141 328 (EApp (#2 tag,
adamc@141 329 (EApp ((EVar (["Basis"], "cdata"), pos),
adamc@141 330 (EPrim (Prim.String ""), pos)),
adamc@141 331 pos)), pos)
adamc@141 332 end)
adamc@141 333
adamc@141 334 | tag GT xml END_TAG (let
adamc@141 335 val pos = s (tagleft, GTright)
adamc@141 336 in
adamc@141 337 if #1 tag = END_TAG then
adamc@141 338 if END_TAG = "lform" then
adamc@141 339 (EApp ((EVar (["Basis"], "lform"), pos),
adamc@141 340 xml), pos)
adamc@141 341 else
adamc@141 342 (EApp (#2 tag, xml), pos)
adamc@141 343 else
adamc@141 344 (ErrorMsg.errorAt pos "Begin and end tags don't match.";
adamc@141 345 (EFold, pos))
adamc@141 346 end)
adamc@141 347 | LBRACE eexp RBRACE (eexp)
adamc@92 348
adamc@141 349 tag : tagHead attrs (let
adamc@141 350 val pos = s (tagHeadleft, attrsright)
adamc@141 351 in
adamc@141 352 (#1 tagHead,
adamc@141 353 (EApp ((EApp ((EVar (["Basis"], "tag"), pos),
adamc@141 354 (ERecord attrs, pos)), pos),
adamc@141 355 (EApp (#2 tagHead,
adamc@141 356 (ERecord [], pos)), pos)),
adamc@141 357 pos))
adamc@141 358 end)
adamc@141 359
adamc@141 360 tagHead: BEGIN_TAG (let
adamc@141 361 val pos = s (BEGIN_TAGleft, BEGIN_TAGright)
adamc@141 362 in
adamc@141 363 (BEGIN_TAG,
adamc@141 364 (EVar ([], BEGIN_TAG), pos))
adamc@141 365 end)
adamc@141 366 | tagHead LBRACE cexp RBRACE (#1 tagHead, (ECApp (#2 tagHead, cexp), s (tagHeadleft, RBRACEright)))
adamc@92 367
adamc@104 368 attrs : ([])
adamc@104 369 | attr attrs (attr :: attrs)
adamc@104 370
adamc@104 371 attr : SYMBOL EQ attrv ((CName (uppercaseFirst SYMBOL), s (SYMBOLleft, SYMBOLright)), attrv)
adamc@104 372
adamc@104 373 attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTright))
adamc@104 374 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright))
adamc@104 375 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright))
adamc@110 376 | LBRACE eexp RBRACE (eexp)