comparison src/pathcheck.sml @ 725:4c5796512edc

Catching duplicate cookie and style paths
author Adam Chlipala <adamc@hcoop.net>
date Thu, 16 Apr 2009 12:07:21 -0400
parents d8217b4cb617
children 72670131dace
comparison
equal deleted inserted replaced
724:12ec14a6be0b 725:4c5796512edc
34 structure SS = BinarySetFn(struct 34 structure SS = BinarySetFn(struct
35 type ord_key = string 35 type ord_key = string
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, cookies, styles)) =
40 let 40 let
41 fun doFunc s = 41 fun doFunc s =
42 (if SS.member (funcs, s) then 42 (if SS.member (funcs, s) then
43 E.errorAt loc ("Duplicate function path " ^ s) 43 E.errorAt loc ("Duplicate function path " ^ s)
44 else 44 else
45 (); 45 ();
46 (SS.add (funcs, s), rels)) 46 (SS.add (funcs, s), rels, cookies, styles))
47 47
48 fun doRel s = 48 fun doRel s =
49 (if SS.member (rels, s) then 49 (if SS.member (rels, s) then
50 E.errorAt loc ("Duplicate table/sequence path " ^ s) 50 E.errorAt loc ("Duplicate table/sequence path " ^ s)
51 else 51 else
52 (); 52 ();
53 (funcs, SS.add (rels, s))) 53 (funcs, SS.add (rels, s), cookies, styles))
54
55 fun doCookie s =
56 (if SS.member (cookies, s) then
57 E.errorAt loc ("Duplicate cookie path " ^ s)
58 else
59 ();
60 (funcs, rels, SS.add (cookies, s), styles))
61
62 fun doStyle s =
63 (if SS.member (styles, s) then
64 E.errorAt loc ("Duplicate style path " ^ s)
65 else
66 ();
67 (funcs, rels, cookies, SS.add (styles, s)))
54 in 68 in
55 case d of 69 case d of
56 DExport (_, s, _, _, _) => doFunc s 70 DExport (_, s, _, _, _) => doFunc s
57 71
58 | DTable (s, _, pe, ce) => 72 | DTable (s, _, pe, ce) =>
84 else 98 else
85 (); 99 ();
86 SS.add (rels, s') 100 SS.add (rels, s')
87 end 101 end
88 in 102 in
89 (funcs, constraints (ce, rels)) 103 (funcs, constraints (ce, rels), cookies, styles)
90 end 104 end
91 | DSequence s => doRel s 105 | DSequence s => doRel s
92 106
93 | _ => (funcs, rels) 107 | DCookie s => doCookie s
108 | DStyle s => doStyle s
109
110 | _ => (funcs, rels, cookies, styles)
94 end 111 end
95 112
96 fun check ds = ignore (foldl checkDecl (SS.empty, SS.empty) ds) 113 fun check ds = ignore (foldl checkDecl (SS.empty, SS.empty, SS.empty, SS.empty) ds)
97 114
98 end 115 end