Mercurial > urweb
comparison src/pathcheck.sml @ 704:70cbdcf5989b
UNIQUE constraints
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 07 Apr 2009 12:24:31 -0400 |
parents | 56aaa1941dad |
children | d8217b4cb617 |
comparison
equal
deleted
inserted
replaced
703:a5d8b470d7ca | 704:70cbdcf5989b |
---|---|
36 val compare = String.compare | 36 val compare = String.compare |
37 end) | 37 end) |
38 | 38 |
39 fun checkDecl ((d, loc), (funcs, rels)) = | 39 fun checkDecl ((d, loc), (funcs, rels)) = |
40 let | 40 let |
41 fun doFunc s = | |
42 (if SS.member (funcs, s) then | |
43 E.errorAt loc ("Duplicate function path " ^ s) | |
44 else | |
45 (); | |
46 (SS.add (funcs, s), rels)) | |
47 | |
41 fun doRel s = | 48 fun doRel s = |
42 (if SS.member (rels, s) then | 49 (if SS.member (rels, s) then |
43 E.errorAt loc ("Duplicate table/sequence path " ^ s) | 50 E.errorAt loc ("Duplicate table/sequence path " ^ s) |
44 else | 51 else |
45 (); | 52 (); |
46 (funcs, SS.add (rels, s))) | 53 (funcs, SS.add (rels, s))) |
47 in | 54 in |
48 case d of | 55 case d of |
49 DExport (_, s, _, _, _) => | 56 DExport (_, s, _, _, _) => doFunc s |
50 (if SS.member (funcs, s) then | |
51 E.errorAt loc ("Duplicate function path " ^ s) | |
52 else | |
53 (); | |
54 (SS.add (funcs, s), rels)) | |
55 | 57 |
56 | DTable (s, _) => doRel s | 58 | DTable (s, _, e) => |
59 let | |
60 fun constraints (e, rels) = | |
61 case #1 e of | |
62 ERecord [(s', _, _)] => | |
63 let | |
64 val s' = s ^ "_" ^ s' | |
65 in | |
66 if SS.member (rels, s') then | |
67 E.errorAt loc ("Duplicate constraint path " ^ s') | |
68 else | |
69 (); | |
70 SS.add (rels, s') | |
71 end | |
72 | EStrcat (e1, e2) => constraints (e2, constraints (e1, rels)) | |
73 | _ => rels | |
74 in | |
75 (funcs, constraints (e, #2 (doRel s))) | |
76 end | |
57 | DSequence s => doRel s | 77 | DSequence s => doRel s |
58 | 78 |
59 | _ => (funcs, rels) | 79 | _ => (funcs, rels) |
60 end | 80 end |
61 | 81 |