Mercurial > urweb
comparison src/lacweb.grm @ 209:1487c712eb12
Stub WHERE support
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 16 Aug 2008 12:15:38 -0400 |
parents | cc68da3801bc |
children | f4033abd6ab1 |
comparison
equal
deleted
inserted
replaced
208:63a2f2322c1f | 209:1487c712eb12 |
---|---|
70 ErrorMsg.errorAt loc "Select of field from unbound table"; | 70 ErrorMsg.errorAt loc "Select of field from unbound table"; |
71 | 71 |
72 tabs | 72 tabs |
73 end | 73 end |
74 | 74 |
75 fun sql_inject (v, t, loc) = | |
76 let | |
77 val e = (EApp ((EVar (["Basis"], "sql_inject"), loc), (v, loc)), loc) | |
78 in | |
79 (EApp (e, (t, loc)), loc) | |
80 end | |
81 | |
75 %% | 82 %% |
76 %header (functor LacwebLrValsFn(structure Token : TOKEN)) | 83 %header (functor LacwebLrValsFn(structure Token : TOKEN)) |
77 | 84 |
78 %term | 85 %term |
79 EOF | 86 EOF |
93 | 100 |
94 | XML_BEGIN of string | XML_END | 101 | XML_BEGIN of string | XML_END |
95 | NOTAGS of string | 102 | NOTAGS of string |
96 | BEGIN_TAG of string | END_TAG of string | 103 | BEGIN_TAG of string | END_TAG of string |
97 | 104 |
98 | SELECT | FROM | AS | 105 | SELECT | FROM | AS | CWHERE |
106 | TRUE | FALSE | |
99 | 107 |
100 %nonterm | 108 %nonterm |
101 file of decl list | 109 file of decl list |
102 | decls of decl list | 110 | decls of decl list |
103 | decl of decl | 111 | decl of decl |
164 | tident of con | 172 | tident of con |
165 | fident of con | 173 | fident of con |
166 | seli of select_item | 174 | seli of select_item |
167 | selis of select_item list | 175 | selis of select_item list |
168 | select of select | 176 | select of select |
177 | sqlexp of exp | |
178 | wopt of exp | |
169 | 179 |
170 | 180 |
171 %verbose (* print summary of errors *) | 181 %verbose (* print summary of errors *) |
172 %pos int (* positions *) | 182 %pos int (* positions *) |
173 %start file | 183 %start file |
552 attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTright)) | 562 attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTright)) |
553 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright)) | 563 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright)) |
554 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright)) | 564 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright)) |
555 | LBRACE eexp RBRACE (eexp) | 565 | LBRACE eexp RBRACE (eexp) |
556 | 566 |
557 query : SELECT select FROM tables (let | 567 query : SELECT select FROM tables wopt |
568 (let | |
558 val loc = s (SELECTleft, tablesright) | 569 val loc = s (SELECTleft, tablesright) |
559 | 570 |
560 val sel = | 571 val sel = |
561 case select of | 572 case select of |
562 Star => map (fn (nm, _) => | 573 Star => map (fn (nm, _) => |
577 | 588 |
578 val sel = (CRecord sel, loc) | 589 val sel = (CRecord sel, loc) |
579 | 590 |
580 val e = (EVar (["Basis"], "sql_query"), loc) | 591 val e = (EVar (["Basis"], "sql_query"), loc) |
581 val e = (ECApp (e, sel), loc) | 592 val e = (ECApp (e, sel), loc) |
582 val e = (EApp (e, (ERecord tables, loc)), loc) | 593 val re = (ERecord [((CName "From", loc), |
594 (ERecord tables, loc)), | |
595 ((CName "Where", loc), | |
596 wopt)], loc) | |
597 val e = (EApp (e, re), loc) | |
583 in | 598 in |
584 e | 599 e |
585 end) | 600 end) |
586 | 601 |
587 tables : table ([table]) | 602 tables : table ([table]) |
607 selis : seli ([seli]) | 622 selis : seli ([seli]) |
608 | seli COMMA selis (seli :: selis) | 623 | seli COMMA selis (seli :: selis) |
609 | 624 |
610 select : STAR (Star) | 625 select : STAR (Star) |
611 | selis (Items selis) | 626 | selis (Items selis) |
627 | |
628 sqlexp : TRUE (sql_inject (EVar (["Basis"], "True"), | |
629 EVar (["Basis"], "sql_bool"), | |
630 s (TRUEleft, TRUEright))) | |
631 | FALSE (sql_inject (EVar (["Basis"], "False"), | |
632 EVar (["Basis"], "sql_bool"), | |
633 s (FALSEleft, FALSEright))) | |
634 | |
635 wopt : (sql_inject (EVar (["Basis"], "True"), | |
636 EVar (["Basis"], "sql_bool"), | |
637 ErrorMsg.dummySpan)) | |
638 | CWHERE sqlexp (sqlexp) |