adamc@377: (* Copyright (c) 2008, Adam Chlipala adamc@377: * All rights reserved. adamc@377: * adamc@377: * Redistribution and use in source and binary forms, with or without adamc@377: * modification, are permitted provided that the following conditions are met: adamc@377: * adamc@377: * - Redistributions of source code must retain the above copyright notice, adamc@377: * this list of conditions and the following disclaimer. adamc@377: * - Redistributions in binary form must reproduce the above copyright notice, adamc@377: * this list of conditions and the following disclaimer in the documentation adamc@377: * and/or other materials provided with the distribution. adamc@377: * - The names of contributors may not be used to endorse or promote products adamc@377: * derived from this software without specific prior written permission. adamc@377: * adamc@377: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" adamc@377: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE adamc@377: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE adamc@377: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE adamc@377: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR adamc@377: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF adamc@377: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS adamc@377: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN adamc@377: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) adamc@377: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE adamc@377: * POSSIBILITY OF SUCH DAMAGE. adamc@377: *) adamc@377: adamc@377: structure PathCheck :> PATH_CHECK = struct adamc@377: adamc@377: open Mono adamc@377: adamc@377: structure E = ErrorMsg adamc@377: adamc@377: structure SS = BinarySetFn(struct adamc@377: type ord_key = string adamc@377: val compare = String.compare adamc@377: end) adamc@377: adamc@377: fun checkDecl ((d, loc), (funcs, rels)) = adamc@377: let adamc@377: fun doRel s = adamc@377: (if SS.member (rels, s) then adamc@377: E.errorAt loc ("Duplicate table/sequence path " ^ s) adamc@377: else adamc@377: (); adamc@377: (funcs, SS.add (rels, s))) adamc@377: in adamc@377: case d of adamc@609: DExport (_, s, _, _, _) => adamc@377: (if SS.member (funcs, s) then adamc@377: E.errorAt loc ("Duplicate function path " ^ s) adamc@377: else adamc@377: (); adamc@377: (SS.add (funcs, s), rels)) adamc@377: adamc@377: | DTable (s, _) => doRel s adamc@377: | DSequence s => doRel s adamc@377: adamc@377: | _ => (funcs, rels) adamc@377: end adamc@377: adamc@377: fun check ds = ignore (foldl checkDecl (SS.empty, SS.empty) ds) adamc@377: adamc@377: end