comparison src/urweb.grm @ 704:70cbdcf5989b

UNIQUE constraints
author Adam Chlipala <adamc@hcoop.net>
date Tue, 07 Apr 2009 12:24:31 -0400
parents 500e93aa436f
children e6706a1df013
comparison
equal deleted inserted replaced
703:a5d8b470d7ca 704:70cbdcf5989b
206 | COUNT | AVG | SUM | MIN | MAX 206 | COUNT | AVG | SUM | MIN | MAX
207 | ASC | DESC 207 | ASC | DESC
208 | INSERT | INTO | VALUES | UPDATE | SET | DELETE | NULL | IS 208 | INSERT | INTO | VALUES | UPDATE | SET | DELETE | NULL | IS
209 | CURRENT_TIMESTAMP 209 | CURRENT_TIMESTAMP
210 | NE | LT | LE | GT | GE 210 | NE | LT | LE | GT | GE
211 | CCONSTRAINT | UNIQUE
211 212
212 %nonterm 213 %nonterm
213 file of decl list 214 file of decl list
214 | decls of decl list 215 | decls of decl list
215 | decl of decl list 216 | decl of decl list
219 220
220 | dargs of string list 221 | dargs of string list
221 | barOpt of unit 222 | barOpt of unit
222 | dcons of (string * con option) list 223 | dcons of (string * con option) list
223 | dcon of string * con option 224 | dcon of string * con option
225
226 | cst of exp
227 | csts of exp
228 | cstopt of exp
224 229
225 | sgn of sgn 230 | sgn of sgn
226 | sgntm of sgn 231 | sgntm of sgn
227 | sgi of sgn_item 232 | sgi of sgn_item
228 | sgis of sgn_item list 233 | sgis of sgn_item list
287 292
288 | query of exp 293 | query of exp
289 | query1 of exp 294 | query1 of exp
290 | tables of (con * exp) list 295 | tables of (con * exp) list
291 | tname of con 296 | tname of con
297 | tnameW of (con * con)
298 | tnames of con
299 | tnames' of (con * con) list
292 | table of con * exp 300 | table of con * exp
293 | tident of con 301 | tident of con
294 | fident of con 302 | fident of con
295 | seli of select_item 303 | seli of select_item
296 | selis of select_item list 304 | selis of select_item list
408 | OPEN CONSTRAINTS mpath (case mpath of 416 | OPEN CONSTRAINTS mpath (case mpath of
409 [] => raise Fail "Impossible mpath parse [3]" 417 [] => raise Fail "Impossible mpath parse [3]"
410 | m :: ms => [(DOpenConstraints (m, ms), s (OPENleft, mpathright))]) 418 | m :: ms => [(DOpenConstraints (m, ms), s (OPENleft, mpathright))])
411 | CONSTRAINT cterm TWIDDLE cterm ([(DConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))]) 419 | CONSTRAINT cterm TWIDDLE cterm ([(DConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))])
412 | EXPORT spath ([(DExport spath, s (EXPORTleft, spathright))]) 420 | EXPORT spath ([(DExport spath, s (EXPORTleft, spathright))])
413 | TABLE SYMBOL COLON cexp ([(DTable (SYMBOL, entable cexp), s (TABLEleft, cexpright))]) 421 | TABLE SYMBOL COLON cterm cstopt([(DTable (SYMBOL, entable cterm, cstopt), s (TABLEleft, cstoptright))])
414 | SEQUENCE SYMBOL ([(DSequence SYMBOL, s (SEQUENCEleft, SYMBOLright))]) 422 | SEQUENCE SYMBOL ([(DSequence SYMBOL, s (SEQUENCEleft, SYMBOLright))])
415 | CLASS SYMBOL EQ cexp (let 423 | CLASS SYMBOL EQ cexp (let
416 val loc = s (CLASSleft, cexpright) 424 val loc = s (CLASSleft, cexpright)
417 in 425 in
418 [(DClass (SYMBOL, (KWild, loc), cexp), loc)] 426 [(DClass (SYMBOL, (KWild, loc), cexp), loc)]
457 (SYMBOL, SOME t, e) 465 (SYMBOL, SOME t, e)
458 end) 466 end)
459 467
460 copt : (NONE) 468 copt : (NONE)
461 | COLON cexp (SOME cexp) 469 | COLON cexp (SOME cexp)
470
471 cstopt : (EVar (["Basis"], "no_constraint", Infer), dummy)
472 | csts (csts)
473
474 csts : CCONSTRAINT tname cst (let
475 val loc = s (CCONSTRAINTleft, cstright)
476
477 val e = (EVar (["Basis"], "one_constraint", Infer), loc)
478 val e = (ECApp (e, tname), loc)
479 in
480 (EApp (e, cst), loc)
481 end)
482 | csts COMMA csts (let
483 val loc = s (csts1left, csts2right)
484
485 val e = (EVar (["Basis"], "join_constraints", Infer), loc)
486 val e = (EApp (e, csts1), loc)
487 in
488 (EApp (e, csts2), loc)
489 end)
490 | LBRACE LBRACE eexp RBRACE RBRACE (eexp)
491
492 cst : UNIQUE tnames (let
493 val loc = s (UNIQUEleft, tnamesright)
494
495 val e = (EVar (["Basis"], "unique", Infer), loc)
496 val e = (ECApp (e, tnames), loc)
497 in
498 (EDisjointApp e, loc)
499 end)
500 | LBRACE eexp RBRACE (eexp)
501
502 tnameW : tname (let
503 val loc = s (tnameleft, tnameright)
504 in
505 (tname, (CWild (KType, loc), loc))
506 end)
507
508 tnames : tnameW (CRecord [tnameW], s (tnameWleft, tnameWright))
509 | LPAREN tnames' RPAREN (CRecord tnames', s (LPARENleft, RPARENright))
510 | LBRACE LBRACE cexp RBRACE RBRACE (cexp)
511
512 tnames': tnameW ([tnameW])
513 | tnameW COMMA tnames' (tnameW :: tnames')
462 514
463 valis : vali ([vali]) 515 valis : vali ([vali])
464 | vali AND valis (vali :: valis) 516 | vali AND valis (vali :: valis)
465 517
466 sgn : sgntm (sgntm) 518 sgn : sgntm (sgntm)