# HG changeset patch # User Adam Chlipala # Date 1201379349 18000 # Node ID 5c3cc348e9e66f2b30a8421992a4acfed353ee72 # Parent daa4f1d7a6634ee67cf9531859b86b629e559ca9 Rename Laconic* modules to Source* diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/compiler.sig --- a/src/compiler.sig Sat Jan 26 15:26:12 2008 -0500 +++ b/src/compiler.sig Sat Jan 26 15:29:09 2008 -0500 @@ -29,7 +29,7 @@ signature COMPILER = sig - val parse : string -> Laconic.file option + val parse : string -> Source.file option val testParse : string -> unit diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/compiler.sml --- a/src/compiler.sml Sat Jan 26 15:26:12 2008 -0500 +++ b/src/compiler.sml Sat Jan 26 15:29:09 2008 -0500 @@ -58,7 +58,7 @@ if ErrorMsg.anyErrors () then print "Recoverable parse error\n" else - (Print.print (LaconicPrint.p_file file); + (Print.print (SourcePrint.p_file file); print "\n") end diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/elaborate.sig --- a/src/elaborate.sig Sat Jan 26 15:26:12 2008 -0500 +++ b/src/elaborate.sig Sat Jan 26 15:29:09 2008 -0500 @@ -27,6 +27,6 @@ signature ELABORATE = sig - val elabFile : Laconic.file -> Elab.file + val elabFile : Source.file -> Elab.file end diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/elaborate.sml --- a/src/elaborate.sml Sat Jan 26 15:26:12 2008 -0500 +++ b/src/elaborate.sml Sat Jan 26 15:29:09 2008 -0500 @@ -27,7 +27,7 @@ structure Elaborate :> ELABORATE = struct -structure L = Laconic +structure L = Source structure L' = Elab structure E = ElabEnv structure U = ElabUtil diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/laconic.sml --- a/src/laconic.sml Sat Jan 26 15:26:12 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -(* Copyright (c) 2008, Adam Chlipala - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - The names of contributors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *) - -structure Laconic = struct - -type 'a located = 'a ErrorMsg.located - -datatype kind' = - KType - | KArrow of kind * kind - | KName - | KRecord of kind - -withtype kind = kind' located - -datatype explicitness = - Explicit - | Implicit - -datatype con' = - CAnnot of con * kind - - | TFun of con * con - | TCFun of explicitness * string * kind * con - | TRecord of con - - | CVar of string - | CApp of con * con - | CAbs of explicitness * string * kind * con - - | CName of string - - | CRecord of (con * con) list - | CConcat of con * con - -withtype con = con' located - -datatype decl' = - DCon of string * kind option * con - -withtype decl = decl' located - -type file = decl list - -end diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/laconic_print.sig --- a/src/laconic_print.sig Sat Jan 26 15:26:12 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -(* Copyright (c) 2008, Adam Chlipala - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - The names of contributors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *) - -(* Pretty-printing Laconic/Web *) - -signature LACONIC_PRINT = sig - val p_kind : Laconic.kind Print.printer - val p_explicitness : Laconic.explicitness Print.printer - val p_con : Laconic.con Print.printer - val p_decl : Laconic.decl Print.printer - val p_file : Laconic.file Print.printer -end diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/laconic_print.sml --- a/src/laconic_print.sml Sat Jan 26 15:26:12 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,147 +0,0 @@ -(* Copyright (c) 2008, Adam Chlipala - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - The names of contributors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *) - -(* Pretty-printing Laconic/Web *) - -structure LaconicPrint :> LACONIC_PRINT = struct - -open Print.PD -open Print - -open Laconic - -fun p_kind' par (k, _) = - case k of - KType => string "Type" - | KArrow (k1, k2) => parenIf par (box [p_kind' true k1, - space, - string "->", - space, - p_kind k2]) - | KName => string "Name" - | KRecord k => box [string "{", p_kind k, string "}"] - -and p_kind k = p_kind' false k - -fun p_explicitness e = - case e of - Explicit => string "::" - | Implicit => string ":::" - -fun p_con' par (c, _) = - case c of - CAnnot (c, k) => box [string "(", - p_con c, - space, - string "::", - space, - p_kind k, - string ")"] - - | TFun (t1, t2) => parenIf par (box [p_con' true t1, - space, - string "->", - space, - p_con t2]) - | TCFun (e, x, k, c) => parenIf par (box [string x, - space, - p_explicitness e, - space, - p_kind k, - space, - string "->", - space, - p_con c]) - | TRecord (CRecord xcs, _) => box [string "{", - p_list (fn (x, c) => - box [p_con x, - space, - string ":", - space, - p_con c]) xcs, - string "}"] - | TRecord c => box [string "$", - p_con' true c] - - | CVar s => string s - | CApp (c1, c2) => parenIf par (box [p_con c1, - space, - p_con' true c2]) - | CAbs (e, x, k, c) => parenIf par (box [string "fn", - space, - string x, - space, - p_explicitness e, - space, - p_kind k, - space, - string "=>", - space, - p_con c]) - - | CName s => box [string "#", string s] - - | CRecord xcs => box [string "[", - p_list (fn (x, c) => - box [p_con x, - space, - string "=", - space, - p_con c]) xcs, - string "]"] - | CConcat (c1, c2) => parenIf par (box [p_con' true c1, - space, - string "++", - space, - p_con c2]) - -and p_con c = p_con' false c - -fun p_decl ((d, _) : decl) = - case d of - DCon (x, NONE, c) => box [string "con", - space, - string x, - space, - string "=", - space, - p_con c] - | DCon (x, SOME k, c) => box [string "con", - space, - string x, - space, - string "::", - space, - p_kind k, - space, - string "=", - space, - p_con c] - -val p_file = p_list_sep newline p_decl - -end diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/lacweb.grm --- a/src/lacweb.grm Sat Jan 26 15:26:12 2008 -0500 +++ b/src/lacweb.grm Sat Jan 26 15:29:09 2008 -0500 @@ -27,7 +27,7 @@ (* Grammar for Laconic/Web programs *) -open Laconic +open Source val s = ErrorMsg.spanOf diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/source.sml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/source.sml Sat Jan 26 15:29:09 2008 -0500 @@ -0,0 +1,69 @@ +(* Copyright (c) 2008, Adam Chlipala + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - The names of contributors may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *) + +structure Source = struct + +type 'a located = 'a ErrorMsg.located + +datatype kind' = + KType + | KArrow of kind * kind + | KName + | KRecord of kind + +withtype kind = kind' located + +datatype explicitness = + Explicit + | Implicit + +datatype con' = + CAnnot of con * kind + + | TFun of con * con + | TCFun of explicitness * string * kind * con + | TRecord of con + + | CVar of string + | CApp of con * con + | CAbs of explicitness * string * kind * con + + | CName of string + + | CRecord of (con * con) list + | CConcat of con * con + +withtype con = con' located + +datatype decl' = + DCon of string * kind option * con + +withtype decl = decl' located + +type file = decl list + +end diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/source_print.sig --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/source_print.sig Sat Jan 26 15:29:09 2008 -0500 @@ -0,0 +1,36 @@ +(* Copyright (c) 2008, Adam Chlipala + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - The names of contributors may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *) + +(* Pretty-printing Laconic/Web *) + +signature SOURCE_PRINT = sig + val p_kind : Source.kind Print.printer + val p_explicitness : Source.explicitness Print.printer + val p_con : Source.con Print.printer + val p_decl : Source.decl Print.printer + val p_file : Source.file Print.printer +end diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/source_print.sml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/source_print.sml Sat Jan 26 15:29:09 2008 -0500 @@ -0,0 +1,147 @@ +(* Copyright (c) 2008, Adam Chlipala + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - The names of contributors may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *) + +(* Pretty-printing Laconic/Web *) + +structure SourcePrint :> SOURCE_PRINT = struct + +open Print.PD +open Print + +open Source + +fun p_kind' par (k, _) = + case k of + KType => string "Type" + | KArrow (k1, k2) => parenIf par (box [p_kind' true k1, + space, + string "->", + space, + p_kind k2]) + | KName => string "Name" + | KRecord k => box [string "{", p_kind k, string "}"] + +and p_kind k = p_kind' false k + +fun p_explicitness e = + case e of + Explicit => string "::" + | Implicit => string ":::" + +fun p_con' par (c, _) = + case c of + CAnnot (c, k) => box [string "(", + p_con c, + space, + string "::", + space, + p_kind k, + string ")"] + + | TFun (t1, t2) => parenIf par (box [p_con' true t1, + space, + string "->", + space, + p_con t2]) + | TCFun (e, x, k, c) => parenIf par (box [string x, + space, + p_explicitness e, + space, + p_kind k, + space, + string "->", + space, + p_con c]) + | TRecord (CRecord xcs, _) => box [string "{", + p_list (fn (x, c) => + box [p_con x, + space, + string ":", + space, + p_con c]) xcs, + string "}"] + | TRecord c => box [string "$", + p_con' true c] + + | CVar s => string s + | CApp (c1, c2) => parenIf par (box [p_con c1, + space, + p_con' true c2]) + | CAbs (e, x, k, c) => parenIf par (box [string "fn", + space, + string x, + space, + p_explicitness e, + space, + p_kind k, + space, + string "=>", + space, + p_con c]) + + | CName s => box [string "#", string s] + + | CRecord xcs => box [string "[", + p_list (fn (x, c) => + box [p_con x, + space, + string "=", + space, + p_con c]) xcs, + string "]"] + | CConcat (c1, c2) => parenIf par (box [p_con' true c1, + space, + string "++", + space, + p_con c2]) + +and p_con c = p_con' false c + +fun p_decl ((d, _) : decl) = + case d of + DCon (x, NONE, c) => box [string "con", + space, + string x, + space, + string "=", + space, + p_con c] + | DCon (x, SOME k, c) => box [string "con", + space, + string x, + space, + string "::", + space, + p_kind k, + space, + string "=", + space, + p_con c] + +val p_file = p_list_sep newline p_decl + +end diff -r daa4f1d7a663 -r 5c3cc348e9e6 src/sources --- a/src/sources Sat Jan 26 15:26:12 2008 -0500 +++ b/src/sources Sat Jan 26 15:29:09 2008 -0500 @@ -1,7 +1,7 @@ errormsg.sig errormsg.sml -laconic.sml +source.sml lacweb.grm lacweb.lex @@ -9,8 +9,8 @@ print.sig print.sml -laconic_print.sig -laconic_print.sml +source_print.sig +source_print.sml elab.sml