Mercurial > urweb
comparison src/urweb.grm @ 2206:c1a62ce47083
Merge.
author | Ziv Scully <ziv@mit.edu> |
---|---|
date | Tue, 27 May 2014 21:38:01 -0400 |
parents | 403f0cc65b9c |
children | afeeabdcce77 |
comparison
equal
deleted
inserted
replaced
2205:cdea39473c78 | 2206:c1a62ce47083 |
---|---|
1 (* Copyright (c) 2008-2012, Adam Chlipala | 1 (* Copyright (c) 2008-2014, Adam Chlipala |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are met: | 5 * modification, are permitted provided that the following conditions are met: |
6 * | 6 * |
223 "table" => "tabl" | 223 "table" => "tabl" |
224 | _ => bt | 224 | _ => bt |
225 | 225 |
226 datatype prop_kind = Delete | Update | 226 datatype prop_kind = Delete | Update |
227 | 227 |
228 datatype attr = Class of exp | DynClass of exp | Style of exp | DynStyle of exp | Normal of con * exp | 228 datatype attr = Class of exp | DynClass of exp | Style of exp | DynStyle of exp | Normal of con * exp | Data of string * exp |
229 | 229 |
230 fun patType loc (p : pat) = | 230 fun patType loc (p : pat) = |
231 case #1 p of | 231 case #1 p of |
232 PAnnot (_, t) => t | 232 PAnnot (_, t) => t |
233 | _ => (CWild (KType, loc), loc) | 233 | _ => (CWild (KType, loc), loc) |
320 val e' = (EApp (e', pb), loc) | 320 val e' = (EApp (e', pb), loc) |
321 in | 321 in |
322 (EApp (e', ob), loc) | 322 (EApp (e', ob), loc) |
323 end | 323 end |
324 | 324 |
325 fun patternOut (e : exp) = | |
326 case #1 e of | |
327 EWild => (PWild, #2 e) | |
328 | EVar ([], x, Infer) => | |
329 if Char.isUpper (String.sub (x, 0)) then | |
330 (PCon ([], x, NONE), #2 e) | |
331 else | |
332 (PVar x, #2 e) | |
333 | EVar (xs, x, Infer) => | |
334 if Char.isUpper (String.sub (x, 0)) then | |
335 (PCon (xs, x, NONE), #2 e) | |
336 else | |
337 (ErrorMsg.errorAt (#2 e) "Badly capitalized constructor name in pattern"; | |
338 (PWild, #2 e)) | |
339 | EPrim p => (PPrim p, #2 e) | |
340 | EApp ((EVar (xs, x, Infer), _), e') => | |
341 (PCon (xs, x, SOME (patternOut e')), #2 e) | |
342 | ERecord (xes, flex) => | |
343 (PRecord (map (fn (x, e') => | |
344 let | |
345 val x = | |
346 case #1 x of | |
347 CName x => x | |
348 | _ => (ErrorMsg.errorAt (#2 e) "Field name not constant in pattern"; | |
349 "") | |
350 in | |
351 (x, patternOut e') | |
352 end) xes, flex), #2 e) | |
353 | EAnnot (e', t) => | |
354 (PAnnot (patternOut e', t), #2 e) | |
355 | _ => (ErrorMsg.errorAt (#2 e) "This is an expression but not a pattern."; | |
356 (PWild, #2 e)) | |
357 | |
325 %% | 358 %% |
326 %header (functor UrwebLrValsFn(structure Token : TOKEN)) | 359 %header (functor UrwebLrValsFn(structure Token : TOKEN)) |
327 | 360 |
328 %term | 361 %term |
329 EOF | 362 EOF |
330 | STRING of string | INT of Int64.int | FLOAT of Real64.real | CHAR of char | 363 | STRING of string | INT of Int64.int | FLOAT of Real64.real | CHAR of char |
331 | SYMBOL of string | CSYMBOL of string | 364 | SYMBOL of string | CSYMBOL of string |
332 | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE | 365 | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE |
333 | EQ | COMMA | COLON | DCOLON | DCOLONWILD | TCOLON | TCOLONWILD | DOT | HASH | UNDER | UNDERUNDER | BAR | 366 | EQ | COMMA | COLON | DCOLON | DCOLONWILD | TCOLON | TCOLONWILD | DOT | HASH | UNDER | UNDERUNDER | BAR |
334 | PLUS | MINUS | DIVIDE | DOTDOTDOT | MOD | AT | 367 | PLUS | MINUS | DIVIDE | DOTDOTDOT | MOD | AT |
335 | CON | LTYPE | VAL | REC | AND | FUN | MAP | UNIT | KUNIT | CLASS | 368 | CON | LTYPE | VAL | REC | AND | FUN | MAP | UNIT | KUNIT | CLASS | FFI |
336 | DATATYPE | OF | 369 | DATATYPE | OF |
337 | TYPE | NAME | 370 | TYPE | NAME |
338 | ARROW | LARROW | DARROW | STAR | SEMI | KARROW | DKARROW | BANG | 371 | ARROW | LARROW | DARROW | STAR | SEMI | KARROW | DKARROW | BANG |
339 | FN | PLUSPLUS | MINUSMINUS | MINUSMINUSMINUS | DOLLAR | TWIDDLE | CARET | 372 | FN | PLUSPLUS | MINUSMINUS | MINUSMINUSMINUS | DOLLAR | TWIDDLE | CARET |
340 | LET | IN | 373 | LET | IN |
426 | 459 |
427 | eexp of exp | 460 | eexp of exp |
428 | eapps of exp | 461 | eapps of exp |
429 | eterm of exp | 462 | eterm of exp |
430 | etuple of exp list | 463 | etuple of exp list |
431 | rexp of (con * exp) list | 464 | rexp of (con * exp) list * bool |
432 | xml of exp | 465 | xml of exp |
433 | xmlOne of exp | 466 | xmlOne of exp |
434 | xmlOpt of exp | 467 | xmlOpt of exp |
435 | tag of (string * exp) * exp option * exp option * exp | 468 | tag of (string * exp) * exp option * exp option * exp |
436 | tagHead of string * exp | 469 | tagHead of string * exp |
437 | bind of string * con option * exp | 470 | bind of pat * con option * exp |
438 | edecl of edecl | 471 | edecl of edecl |
439 | edecls of edecl list | 472 | edecls of edecl list |
440 | 473 |
441 | earg of exp * con -> exp * con | 474 | earg of exp * con -> exp * con |
442 | eargp of exp * con -> exp * con | 475 | eargp of exp * con -> exp * con |
451 | patS of pat | 484 | patS of pat |
452 | pterm of pat | 485 | pterm of pat |
453 | rpat of (string * pat) list * bool | 486 | rpat of (string * pat) list * bool |
454 | ptuple of pat list | 487 | ptuple of pat list |
455 | 488 |
456 | attrs of exp option * exp option * exp option * exp option * (con * exp) list | 489 | attrs of exp option * exp option * exp option * exp option * (string * exp) list * (con * exp) list |
457 | attr of attr | 490 | attr of attr |
458 | attrv of exp | 491 | attrv of exp |
459 | 492 |
460 | query of exp | 493 | query of exp |
461 | query1 of exp | 494 | query1 of exp |
497 | sqlexps of exp list | 530 | sqlexps of exp list |
498 | fsets of (con * exp) list | 531 | fsets of (con * exp) list |
499 | enterDml of unit | 532 | enterDml of unit |
500 | leaveDml of unit | 533 | leaveDml of unit |
501 | 534 |
535 | ffi_mode of ffi_mode | |
536 | ffi_modes of ffi_mode list | |
537 | |
502 | 538 |
503 %verbose (* print summary of errors *) | 539 %verbose (* print summary of errors *) |
504 %pos int (* positions *) | 540 %pos int (* positions *) |
505 %start file | 541 %start file |
506 %pure | 542 %pure |
610 s (VIEWleft, RBRACEright))]) | 646 s (VIEWleft, RBRACEright))]) |
611 | COOKIE SYMBOL COLON cexp ([(DCookie (SYMBOL, cexp), s (COOKIEleft, cexpright))]) | 647 | COOKIE SYMBOL COLON cexp ([(DCookie (SYMBOL, cexp), s (COOKIEleft, cexpright))]) |
612 | STYLE SYMBOL ([(DStyle SYMBOL, s (STYLEleft, SYMBOLright))]) | 648 | STYLE SYMBOL ([(DStyle SYMBOL, s (STYLEleft, SYMBOLright))]) |
613 | TASK eapps EQ eexp ([(DTask (eapps, eexp), s (TASKleft, eexpright))]) | 649 | TASK eapps EQ eexp ([(DTask (eapps, eexp), s (TASKleft, eexpright))]) |
614 | POLICY eexp ([(DPolicy eexp, s (POLICYleft, eexpright))]) | 650 | POLICY eexp ([(DPolicy eexp, s (POLICYleft, eexpright))]) |
651 | FFI SYMBOL ffi_modes COLON cexp([(DFfi (SYMBOL, ffi_modes, cexp), s (FFIleft, cexpright))]) | |
615 | 652 |
616 dtype : SYMBOL dargs EQ barOpt dcons (SYMBOL, dargs, dcons) | 653 dtype : SYMBOL dargs EQ barOpt dcons (SYMBOL, dargs, dcons) |
617 | 654 |
618 dtypes : dtype ([dtype]) | 655 dtypes : dtype ([dtype]) |
619 | dtype AND dtypes (dtype :: dtypes) | 656 | dtype AND dtypes (dtype :: dtypes) |
728 | 765 |
729 val e = (EVar (["Basis"], "foreign_key", Infer), loc) | 766 val e = (EVar (["Basis"], "foreign_key", Infer), loc) |
730 val e = (EApp (e, mat), loc) | 767 val e = (EApp (e, mat), loc) |
731 val e = (EApp (e, texp), loc) | 768 val e = (EApp (e, texp), loc) |
732 in | 769 in |
733 (EApp (e, (ERecord [((CName "OnDelete", loc), | 770 (EApp (e, (ERecord ([((CName "OnDelete", loc), |
734 findMode Delete), | 771 findMode Delete), |
735 ((CName "OnUpdate", loc), | 772 ((CName "OnUpdate", loc), |
736 findMode Update)], loc)), loc) | 773 findMode Update)], false), loc)), loc) |
737 end) | 774 end) |
738 | 775 |
739 | LBRACE eexp RBRACE (eexp) | 776 | LBRACE eexp RBRACE (eexp) |
740 | 777 |
741 tnameW : tname (let | 778 tnameW : tname (let |
777 val e = (EDisjointApp e, loc) | 814 val e = (EDisjointApp e, loc) |
778 | 815 |
779 val witness = map (fn (c, _) => | 816 val witness = map (fn (c, _) => |
780 (c, (EWild, loc))) | 817 (c, (EWild, loc))) |
781 (#1 tnames :: #2 tnames) | 818 (#1 tnames :: #2 tnames) |
782 val witness = (ERecord witness, loc) | 819 val witness = (ERecord (witness, false), loc) |
783 in | 820 in |
784 (EApp (e, witness), loc) | 821 (EApp (e, witness), loc) |
785 end) | 822 end) |
786 | 823 |
787 pkopt : (EVar (["Basis"], "no_primary_key", Infer), dummy) | 824 pkopt : (EVar (["Basis"], "no_primary_key", Infer), dummy) |
1134 (ECase (eexp1, [((PCon (["Basis"], "True", NONE), loc), eexp2), | 1171 (ECase (eexp1, [((PCon (["Basis"], "True", NONE), loc), eexp2), |
1135 ((PCon (["Basis"], "False", NONE), loc), eexp3)]), loc) | 1172 ((PCon (["Basis"], "False", NONE), loc), eexp3)]), loc) |
1136 end) | 1173 end) |
1137 | bind SEMI eexp (let | 1174 | bind SEMI eexp (let |
1138 val loc = s (bindleft, eexpright) | 1175 val loc = s (bindleft, eexpright) |
1139 val (v, to, e1) = bind | 1176 val (p, to, e1) = bind |
1140 val e = (EVar (["Basis"], "bind", Infer), loc) | 1177 val e = (EVar (["Basis"], "bind", Infer), loc) |
1141 val e = (EApp (e, e1), loc) | 1178 val e = (EApp (e, e1), loc) |
1142 in | 1179 |
1143 (EApp (e, (EAbs (v, to, eexp), loc)), loc) | 1180 val f = case #1 p of |
1181 PVar v => (EAbs (v, to, eexp), loc) | |
1182 | _ => (EAbs ("$x", to, | |
1183 (ECase ((EVar ([], "$x", Infer), loc), | |
1184 [(p, eexp)]), loc)), loc) | |
1185 in | |
1186 (EApp (e, f), loc) | |
1144 end) | 1187 end) |
1145 | eexp EQ eexp (native_op ("eq", eexp1, eexp2, s (eexp1left, eexp2right))) | 1188 | eexp EQ eexp (native_op ("eq", eexp1, eexp2, s (eexp1left, eexp2right))) |
1146 | eexp NE eexp (native_op ("ne", eexp1, eexp2, s (eexp1left, eexp2right))) | 1189 | eexp NE eexp (native_op ("ne", eexp1, eexp2, s (eexp1left, eexp2right))) |
1147 | MINUS eterm (native_unop ("neg", eterm, s (MINUSleft, etermright))) | 1190 | MINUS eterm (native_unop ("neg", eterm, s (MINUSleft, etermright))) |
1148 | eexp PLUS eexp (native_op ("plus", eexp1, eexp2, s (eexp1left, eexp2right))) | 1191 | eexp PLUS eexp (native_op ("plus", eexp1, eexp2, s (eexp1left, eexp2right))) |
1179 | 1222 |
1180 | eapps DCOLON eexp (let | 1223 | eapps DCOLON eexp (let |
1181 val loc = s (eappsleft, eexpright) | 1224 val loc = s (eappsleft, eexpright) |
1182 in | 1225 in |
1183 (EApp ((EVar (["Basis"], "Cons", Infer), loc), | 1226 (EApp ((EVar (["Basis"], "Cons", Infer), loc), |
1184 (ERecord [((CName "1", loc), | 1227 (ERecord ([((CName "1", loc), |
1185 eapps), | 1228 eapps), |
1186 ((CName "2", loc), | 1229 ((CName "2", loc), |
1187 eexp)], loc)), loc) | 1230 eexp)], false), loc)), loc) |
1188 end) | 1231 end) |
1189 | 1232 |
1190 bind : SYMBOL LARROW eapps (SYMBOL, NONE, eapps) | 1233 bind : eapps LARROW eapps (patternOut eapps1, NONE, eapps2) |
1191 | eapps (let | 1234 | eapps (let |
1192 val loc = s (eappsleft, eappsright) | 1235 val loc = s (eappsleft, eappsright) |
1193 in | 1236 in |
1194 ("_", SOME (TRecord (CRecord [], loc), loc), eapps) | 1237 ((PVar "_", loc), SOME (TRecord (CRecord [], loc), loc), eapps) |
1195 end) | 1238 end) |
1196 | 1239 |
1197 eargs : earg (earg) | 1240 eargs : earg (earg) |
1198 | eargl (eargl) | 1241 | eargl (eargl) |
1199 | 1242 |
1287 | LPAREN etuple RPAREN (let | 1330 | LPAREN etuple RPAREN (let |
1288 val loc = s (LPARENleft, RPARENright) | 1331 val loc = s (LPARENleft, RPARENright) |
1289 in | 1332 in |
1290 (ERecord (ListUtil.mapi (fn (i, e) => | 1333 (ERecord (ListUtil.mapi (fn (i, e) => |
1291 ((CName (Int.toString (i + 1)), loc), | 1334 ((CName (Int.toString (i + 1)), loc), |
1292 e)) etuple), loc) | 1335 e)) etuple, false), loc) |
1293 end) | 1336 end) |
1294 | 1337 |
1295 | path (EVar (#1 path, #2 path, Infer), s (pathleft, pathright)) | 1338 | path (EVar (#1 path, #2 path, Infer), s (pathleft, pathright)) |
1296 | cpath (EVar (#1 cpath, #2 cpath, Infer), s (cpathleft, cpathright)) | 1339 | cpath (EVar (#1 cpath, #2 cpath, Infer), s (cpathleft, cpathright)) |
1297 | AT path (EVar (#1 path, #2 path, TypesOnly), s (ATleft, pathright)) | 1340 | AT path (EVar (#1 path, #2 path, TypesOnly), s (ATleft, pathright)) |
1298 | AT AT path (EVar (#1 path, #2 path, DontInfer), s (AT1left, pathright)) | 1341 | AT AT path (EVar (#1 path, #2 path, DontInfer), s (AT1left, pathright)) |
1299 | AT cpath (EVar (#1 cpath, #2 cpath, TypesOnly), s (ATleft, cpathright)) | 1342 | AT cpath (EVar (#1 cpath, #2 cpath, TypesOnly), s (ATleft, cpathright)) |
1300 | AT AT cpath (EVar (#1 cpath, #2 cpath, DontInfer), s (AT1left, cpathright)) | 1343 | AT AT cpath (EVar (#1 cpath, #2 cpath, DontInfer), s (AT1left, cpathright)) |
1301 | LBRACE rexp RBRACE (ERecord rexp, s (LBRACEleft, RBRACEright)) | 1344 | LBRACE rexp RBRACE (ERecord rexp, s (LBRACEleft, RBRACEright)) |
1302 | UNIT (ERecord [], s (UNITleft, UNITright)) | 1345 | LBRACE RBRACE (ERecord ([], false), s (LBRACEleft, RBRACEright)) |
1346 | UNIT (ERecord ([], false), s (UNITleft, UNITright)) | |
1303 | 1347 |
1304 | INT (EPrim (Prim.Int INT), s (INTleft, INTright)) | 1348 | INT (EPrim (Prim.Int INT), s (INTleft, INTright)) |
1305 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright)) | 1349 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright)) |
1306 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright)) | 1350 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright)) |
1307 | CHAR (EPrim (Prim.Char CHAR), s (CHARleft, CHARright)) | 1351 | CHAR (EPrim (Prim.Char CHAR), s (CHARleft, CHARright)) |
1384 ErrorMsg.errorAt loc ("Length mismatch in INSERT field specification (" | 1428 ErrorMsg.errorAt loc ("Length mismatch in INSERT field specification (" |
1385 ^ Int.toString (length fields) | 1429 ^ Int.toString (length fields) |
1386 ^ " vs. " ^ Int.toString (length sqlexps) ^ ")") | 1430 ^ " vs. " ^ Int.toString (length sqlexps) ^ ")") |
1387 else | 1431 else |
1388 (); | 1432 (); |
1389 (EApp (e, (ERecord (ListPair.zip (fields, sqlexps)), loc)), loc) | 1433 (EApp (e, (ERecord (ListPair.zip (fields, sqlexps), false), loc)), loc) |
1390 end) | 1434 end) |
1391 | LPAREN enterDml UPDATE texp SET fsets CWHERE sqlexp leaveDml RPAREN | 1435 | LPAREN enterDml UPDATE texp SET fsets CWHERE sqlexp leaveDml RPAREN |
1392 (let | 1436 (let |
1393 val loc = s (LPARENleft, RPARENright) | 1437 val loc = s (LPARENleft, RPARENright) |
1394 | 1438 |
1395 val e = (EVar (["Basis"], "update", Infer), loc) | 1439 val e = (EVar (["Basis"], "update", Infer), loc) |
1396 val e = (ECApp (e, (CWild (KRecord (KType, loc), loc), loc)), loc) | 1440 val e = (ECApp (e, (CWild (KRecord (KType, loc), loc), loc)), loc) |
1397 val e = (EApp (e, (ERecord fsets, loc)), loc) | 1441 val e = (EApp (e, (ERecord (fsets, false), loc)), loc) |
1398 val e = (EApp (e, texp), loc) | 1442 val e = (EApp (e, texp), loc) |
1399 in | 1443 in |
1400 (EApp (e, sqlexp), loc) | 1444 (EApp (e, sqlexp), loc) |
1401 end) | 1445 end) |
1402 | LPAREN enterDml DELETE FROM texp CWHERE sqlexp leaveDml RPAREN | 1446 | LPAREN enterDml DELETE FROM texp CWHERE sqlexp leaveDml RPAREN |
1484 | INT EQ pat COMMA rpat ((Int64.toString INT, pat) :: #1 rpat, #2 rpat) | 1528 | INT EQ pat COMMA rpat ((Int64.toString INT, pat) :: #1 rpat, #2 rpat) |
1485 | 1529 |
1486 ptuple : pat COMMA pat ([pat1, pat2]) | 1530 ptuple : pat COMMA pat ([pat1, pat2]) |
1487 | pat COMMA ptuple (pat :: ptuple) | 1531 | pat COMMA ptuple (pat :: ptuple) |
1488 | 1532 |
1489 rexp : ([]) | 1533 rexp : DOTDOTDOT ([], true) |
1490 | ident EQ eexp ([(ident, eexp)]) | 1534 | ident EQ eexp ([(ident, eexp)], false) |
1491 | ident EQ eexp COMMA rexp ((ident, eexp) :: rexp) | 1535 | ident EQ eexp COMMA rexp ((ident, eexp) :: #1 rexp, #2 rexp) |
1492 | 1536 |
1493 xml : xmlOne xml (let | 1537 xml : xmlOne xml (let |
1494 val pos = s (xmlOneleft, xmlright) | 1538 val pos = s (xmlOneleft, xmlright) |
1495 in | 1539 in |
1496 (EApp ((EApp ( | 1540 (EApp ((EApp ( |
1600 val eo = case #4 attrs of | 1644 val eo = case #4 attrs of |
1601 NONE => (EVar (["Basis"], "None", Infer), pos) | 1645 NONE => (EVar (["Basis"], "None", Infer), pos) |
1602 | SOME e => (EApp ((EVar (["Basis"], "Some", Infer), pos), | 1646 | SOME e => (EApp ((EVar (["Basis"], "Some", Infer), pos), |
1603 e), pos) | 1647 e), pos) |
1604 val e = (EApp (e, eo), pos) | 1648 val e = (EApp (e, eo), pos) |
1605 val e = (EApp (e, (ERecord (#5 attrs), pos)), pos) | 1649 |
1650 val atts = case #5 attrs of | |
1651 [] => #6 attrs | |
1652 | data :: datas => | |
1653 let | |
1654 fun doOne (name, value) = | |
1655 let | |
1656 val e = (EVar (["Basis"], "data_attr", Infer), pos) | |
1657 val e = (EApp (e, (EPrim (Prim.String name), pos)), pos) | |
1658 in | |
1659 (EApp (e, value), pos) | |
1660 end | |
1661 | |
1662 val datas' = foldl (fn (nv, acc) => | |
1663 let | |
1664 val e = (EVar (["Basis"], "data_attrs", Infer), pos) | |
1665 val e = (EApp (e, acc), pos) | |
1666 in | |
1667 (EApp (e, doOne nv), pos) | |
1668 end) (doOne data) datas | |
1669 in | |
1670 ((CName "Data", pos), datas') :: #6 attrs | |
1671 end | |
1672 | |
1673 val e = (EApp (e, (ERecord (atts, false), pos)), pos) | |
1606 val e = (EApp (e, (EApp (#2 tagHead, | 1674 val e = (EApp (e, (EApp (#2 tagHead, |
1607 (ERecord [], pos)), pos)), pos) | 1675 (ERecord ([], false), pos)), pos)), pos) |
1608 in | 1676 in |
1609 (tagHead, #1 attrs, #2 attrs, e) | 1677 (tagHead, #1 attrs, #2 attrs, e) |
1610 end) | 1678 end) |
1611 | 1679 |
1612 tagHead: BEGIN_TAG (let | 1680 tagHead: BEGIN_TAG (let |
1616 (bt, | 1684 (bt, |
1617 (EVar ([], bt, Infer), pos)) | 1685 (EVar ([], bt, Infer), pos)) |
1618 end) | 1686 end) |
1619 | tagHead LBRACE cexp RBRACE (#1 tagHead, (ECApp (#2 tagHead, cexp), s (tagHeadleft, RBRACEright))) | 1687 | tagHead LBRACE cexp RBRACE (#1 tagHead, (ECApp (#2 tagHead, cexp), s (tagHeadleft, RBRACEright))) |
1620 | 1688 |
1621 attrs : (NONE, NONE, NONE, NONE, []) | 1689 attrs : (NONE, NONE, NONE, NONE, [], []) |
1622 | attr attrs (let | 1690 | attr attrs (let |
1623 val loc = s (attrleft, attrsright) | 1691 val loc = s (attrleft, attrsright) |
1624 in | 1692 in |
1625 case attr of | 1693 case attr of |
1626 Class e => | 1694 Class e => |
1627 (case #1 attrs of | 1695 (case #1 attrs of |
1628 NONE => () | 1696 NONE => () |
1629 | SOME _ => ErrorMsg.errorAt loc "Multiple classes specified for tag"; | 1697 | SOME _ => ErrorMsg.errorAt loc "Multiple classes specified for tag"; |
1630 (SOME e, #2 attrs, #3 attrs, #4 attrs, #5 attrs)) | 1698 (SOME e, #2 attrs, #3 attrs, #4 attrs, #5 attrs, #6 attrs)) |
1631 | DynClass e => | 1699 | DynClass e => |
1632 (case #2 attrs of | 1700 (case #2 attrs of |
1633 NONE => () | 1701 NONE => () |
1634 | SOME _ => ErrorMsg.errorAt loc "Multiple dynamic classes specified for tag"; | 1702 | SOME _ => ErrorMsg.errorAt loc "Multiple dynamic classes specified for tag"; |
1635 (#1 attrs, SOME e, #3 attrs, #4 attrs, #5 attrs)) | 1703 (#1 attrs, SOME e, #3 attrs, #4 attrs, #5 attrs, #6 attrs)) |
1636 | Style e => | 1704 | Style e => |
1637 (case #3 attrs of | 1705 (case #3 attrs of |
1638 NONE => () | 1706 NONE => () |
1639 | SOME _ => ErrorMsg.errorAt loc "Multiple styles specified for tag"; | 1707 | SOME _ => ErrorMsg.errorAt loc "Multiple styles specified for tag"; |
1640 (#1 attrs, #2 attrs, SOME e, #4 attrs, #5 attrs)) | 1708 (#1 attrs, #2 attrs, SOME e, #4 attrs, #5 attrs, #6 attrs)) |
1641 | DynStyle e => | 1709 | DynStyle e => |
1642 (case #4 attrs of | 1710 (case #4 attrs of |
1643 NONE => () | 1711 NONE => () |
1644 | SOME _ => ErrorMsg.errorAt loc "Multiple dynamic classes specified for tag"; | 1712 | SOME _ => ErrorMsg.errorAt loc "Multiple dynamic classes specified for tag"; |
1645 (#1 attrs, #2 attrs, #3 attrs, SOME e, #5 attrs)) | 1713 (#1 attrs, #2 attrs, #3 attrs, SOME e, #5 attrs, #6 attrs)) |
1714 | Data xe => | |
1715 (#1 attrs, #2 attrs, #3 attrs, #4 attrs, xe :: #5 attrs, #6 attrs) | |
1646 | Normal xe => | 1716 | Normal xe => |
1647 (#1 attrs, #2 attrs, #3 attrs, #4 attrs, xe :: #5 attrs) | 1717 (#1 attrs, #2 attrs, #3 attrs, #4 attrs, #5 attrs, xe :: #6 attrs) |
1648 end) | 1718 end) |
1649 | 1719 |
1650 attr : SYMBOL EQ attrv (case SYMBOL of | 1720 attr : SYMBOL EQ attrv (case SYMBOL of |
1651 "class" => Class attrv | 1721 "class" => Class attrv |
1652 | "dynClass" => DynClass attrv | 1722 | "dynClass" => DynClass attrv |
1653 | "style" => Style attrv | 1723 | "style" => Style attrv |
1654 | "dynStyle" => DynStyle attrv | 1724 | "dynStyle" => DynStyle attrv |
1655 | _ => | 1725 | _ => |
1656 let | 1726 if String.isPrefix "data-" SYMBOL then |
1657 val sym = makeAttr SYMBOL | 1727 Data (String.extract (SYMBOL, 5, NONE), attrv) |
1658 in | 1728 else |
1659 Normal ((CName sym, s (SYMBOLleft, SYMBOLright)), | 1729 let |
1660 if (sym = "Href" orelse sym = "Src") | 1730 val sym = makeAttr SYMBOL |
1661 andalso (case #1 attrv of | 1731 in |
1662 EPrim _ => true | 1732 Normal ((CName sym, s (SYMBOLleft, SYMBOLright)), |
1663 | _ => false) then | 1733 if (sym = "Href" orelse sym = "Src") |
1664 let | 1734 andalso (case #1 attrv of |
1665 val loc = s (attrvleft, attrvright) | 1735 EPrim _ => true |
1666 in | 1736 | _ => false) then |
1667 (EApp ((EVar (["Basis"], "bless", Infer), loc), | 1737 let |
1668 attrv), loc) | 1738 val loc = s (attrvleft, attrvright) |
1669 end | 1739 in |
1670 else | 1740 (EApp ((EVar (["Basis"], "bless", Infer), loc), |
1671 attrv) | 1741 attrv), loc) |
1672 end) | 1742 end |
1743 else | |
1744 attrv) | |
1745 end) | |
1673 | 1746 |
1674 attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTright)) | 1747 attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTright)) |
1675 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright)) | 1748 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright)) |
1676 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright)) | 1749 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright)) |
1677 | LBRACE eexp RBRACE (eexp) | 1750 | LBRACE eexp RBRACE (eexp) |
1678 | 1751 |
1679 query : query1 obopt lopt ofopt (let | 1752 query : query1 obopt lopt ofopt (let |
1680 val loc = s (query1left, query1right) | 1753 val loc = s (query1left, query1right) |
1681 | 1754 |
1682 val re = (ERecord [((CName "Rows", loc), | 1755 val re = (ERecord ([((CName "Rows", loc), |
1683 query1), | 1756 query1), |
1684 ((CName "OrderBy", loc), | 1757 ((CName "OrderBy", loc), |
1685 obopt), | 1758 obopt), |
1686 ((CName "Limit", loc), | 1759 ((CName "Limit", loc), |
1687 lopt), | 1760 lopt), |
1688 ((CName "Offset", loc), | 1761 ((CName "Offset", loc), |
1689 ofopt)], loc) | 1762 ofopt)], false), loc) |
1690 in | 1763 in |
1691 (EApp ((EVar (["Basis"], "sql_query", Infer), loc), re), loc) | 1764 (EApp ((EVar (["Basis"], "sql_query", Infer), loc), re), loc) |
1692 end) | 1765 end) |
1693 | 1766 |
1694 dopt : (EVar (["Basis"], "False", Infer), dummy) | 1767 dopt : (EVar (["Basis"], "False", Infer), dummy) |
1765 end | 1838 end |
1766 | 1839 |
1767 val e = (EVar (["Basis"], "sql_query1", Infer), loc) | 1840 val e = (EVar (["Basis"], "sql_query1", Infer), loc) |
1768 val e = (ECApp (e, (CRecord (map (fn nm => (nm, (CUnit, loc))) empties), | 1841 val e = (ECApp (e, (CRecord (map (fn nm => (nm, (CUnit, loc))) empties), |
1769 loc)), loc) | 1842 loc)), loc) |
1770 val re = (ERecord [((CName "Distinct", loc), | 1843 val re = (ERecord ([((CName "Distinct", loc), |
1771 dopt), | 1844 dopt), |
1772 ((CName "From", loc), | 1845 ((CName "From", loc), |
1773 #2 tables), | 1846 #2 tables), |
1774 ((CName "Where", loc), | 1847 ((CName "Where", loc), |
1775 wopt), | 1848 wopt), |
1776 ((CName "GroupBy", loc), | 1849 ((CName "GroupBy", loc), |
1777 grp), | 1850 grp), |
1778 ((CName "Having", loc), | 1851 ((CName "Having", loc), |
1779 hopt), | 1852 hopt), |
1780 ((CName "SelectFields", loc), | 1853 ((CName "SelectFields", loc), |
1781 (ECApp ((EVar (["Basis"], "sql_subset", Infer), loc), | 1854 (ECApp ((EVar (["Basis"], "sql_subset", Infer), loc), |
1782 sel), loc)), | 1855 sel), loc)), |
1783 ((CName "SelectExps", loc), | 1856 ((CName "SelectExps", loc), |
1784 (ERecord exps, loc))], loc) | 1857 (ERecord (exps, false), loc))], false), loc) |
1785 | 1858 |
1786 val e = (EApp (e, re), loc) | 1859 val e = (EApp (e, re), loc) |
1787 in | 1860 in |
1788 e | 1861 e |
1789 end) | 1862 end) |
1905 val e = (EVar (["Basis"], "sql_from_query", Infer), loc) | 1978 val e = (EVar (["Basis"], "sql_from_query", Infer), loc) |
1906 val e = (ECApp (e, tname), loc) | 1979 val e = (ECApp (e, tname), loc) |
1907 in | 1980 in |
1908 ([tname], (EApp (e, query), loc)) | 1981 ([tname], (EApp (e, query), loc)) |
1909 end) | 1982 end) |
1983 | LPAREN fitem RPAREN (fitem) | |
1910 | 1984 |
1911 tname : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright)) | 1985 tname : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright)) |
1912 | LBRACE cexp RBRACE (cexp) | 1986 | LBRACE cexp RBRACE (cexp) |
1913 | 1987 |
1914 table : SYMBOL ((CName (capitalize SYMBOL), s (SYMBOLleft, SYMBOLright)), | 1988 table : SYMBOL ((CName (capitalize SYMBOL), s (SYMBOLleft, SYMBOLright)), |
2195 | 2269 |
2196 sqlagg : AVG ("avg") | 2270 sqlagg : AVG ("avg") |
2197 | SUM ("sum") | 2271 | SUM ("sum") |
2198 | MIN ("min") | 2272 | MIN ("min") |
2199 | MAX ("max") | 2273 | MAX ("max") |
2274 | |
2275 ffi_mode : SYMBOL (case SYMBOL of | |
2276 "effectful" => Effectful | |
2277 | "benignEffectful" => BenignEffectful | |
2278 | "clientOnly" => ClientOnly | |
2279 | "serverOnly" => ServerOnly | |
2280 | _ => (ErrorMsg.errorAt (s (SYMBOLleft, SYMBOLright)) "Invalid FFI mode"; Effectful)) | |
2281 | SYMBOL STRING (case SYMBOL of | |
2282 "jsFunc" => JsFunc STRING | |
2283 | _ => (ErrorMsg.errorAt (s (SYMBOLleft, SYMBOLright)) "Invalid FFI mode"; Effectful)) | |
2284 | |
2285 ffi_modes : ([]) | |
2286 | ffi_mode ffi_modes (ffi_mode :: ffi_modes) |