adamc@0: (* Copyright (c) 2008, Adam Chlipala adamc@0: * All rights reserved. adamc@0: * adamc@0: * Redistribution and use in source and binary forms, with or without adamc@0: * modification, are permitted provided that the following conditions are met: adamc@0: * adamc@0: * - Redistributions of source code must retain the above copyright notice, adamc@0: * this list of conditions and the following disclaimer. adamc@0: * - Redistributions in binary form must reproduce the above copyright notice, adamc@0: * this list of conditions and the following disclaimer in the documentation adamc@0: * and/or other materials provided with the distribution. adamc@0: * - The names of contributors may not be used to endorse or promote products adamc@0: * derived from this software without specific prior written permission. adamc@0: * adamc@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" adamc@0: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE adamc@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE adamc@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE adamc@0: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR adamc@0: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF adamc@0: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS adamc@0: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN adamc@0: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) adamc@0: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE adamc@0: * POSSIBILITY OF SUCH DAMAGE. adamc@0: *) adamc@0: adamc@4: structure Source = struct adamc@0: adamc@0: type 'a located = 'a ErrorMsg.located adamc@0: adamc@0: datatype kind' = adamc@0: KType adamc@0: | KArrow of kind * kind adamc@0: | KName adamc@0: | KRecord of kind adamc@82: | KUnit adamc@207: | KTuple of kind list adamc@18: | KWild adamc@0: adamc@623: | KFun of string * kind adamc@623: | KVar of string adamc@623: adamc@0: withtype kind = kind' located adamc@0: adamc@1: datatype explicitness = adamc@1: Explicit adamc@1: | Implicit adamc@1: adamc@0: datatype con' = adamc@0: CAnnot of con * kind adamc@0: adamc@0: | TFun of con * con adamc@1: | TCFun of explicitness * string * kind * con adamc@0: | TRecord of con adamc@628: | TDisjoint of con * con * con adamc@0: adamc@34: | CVar of string list * string adamc@0: | CApp of con * con adamc@67: | CAbs of string * kind option * con adamc@0: adamc@623: | CKAbs of string * con adamc@623: | TKFun of string * con adamc@623: adamc@0: | CName of string adamc@0: adamc@1: | CRecord of (con * con) list adamc@0: | CConcat of con * con adamc@621: | CMap adamc@0: adamc@82: | CUnit adamc@82: adamc@207: | CTuple of con list adamc@207: | CProj of con * int adamc@207: adamc@18: | CWild of kind adamc@18: adamc@0: withtype con = con' located adamc@0: adamc@706: datatype inference = adamc@706: Infer adamc@706: | DontInfer adamc@706: | TypesOnly adamc@706: adamc@30: datatype sgn_item' = adamc@30: SgiConAbs of string * kind adamc@30: | SgiCon of string * kind option * con adamc@191: | SgiDatatype of string * string list * (string * con option) list adamc@156: | SgiDatatypeImp of string * string list * string adamc@30: | SgiVal of string * con adamc@706: | SgiTable of string * con * exp adamc@30: | SgiStr of string * sgn adamc@59: | SgiSgn of string * sgn adamc@58: | SgiInclude of sgn adamc@88: | SgiConstraint of con * con adamc@563: | SgiClassAbs of string * kind adamc@563: | SgiClass of string * kind * con adamc@30: adamc@30: and sgn' = adamc@30: SgnConst of sgn_item list adamc@30: | SgnVar of string adamc@40: | SgnFun of string * sgn * sgn adamc@42: | SgnWhere of sgn * string * con adamc@59: | SgnProj of string * string list * string adamc@30: adamc@706: and pat' = adamc@706: PWild adamc@706: | PVar of string adamc@706: | PPrim of Prim.t adamc@706: | PCon of string list * string * pat option adamc@706: | PRecord of (string * pat) list * bool adamc@30: adamc@706: and exp' = adamc@706: EAnnot of exp * con adamc@170: adamc@706: | EPrim of Prim.t adamc@706: | EVar of string list * string * inference adamc@706: | EApp of exp * exp adamc@706: | EAbs of string * con option * exp adamc@706: | ECApp of exp * con adamc@706: | ECAbs of explicitness * string * kind * exp adamc@706: | EDisjoint of con * con * exp adamc@706: | EDisjointApp of exp adamc@170: adamc@706: | EKAbs of string * exp adamc@403: adamc@706: | ERecord of (con * exp) list adamc@706: | EField of exp * con adamc@706: | EConcat of exp * exp adamc@706: | ECut of exp * con adamc@706: | ECutMulti of exp * con adamc@34: adamc@706: | EWild adamc@34: adamc@706: | ECase of exp * (pat * exp) list adamc@623: adamc@706: | ELet of edecl list * exp adamc@446: adamc@446: and edecl' = adamc@446: EDVal of string * con option * exp adamc@446: | EDValRec of (string * con option * exp) list adamc@446: adamc@706: withtype sgn_item = sgn_item' located adamc@706: and sgn = sgn' located adamc@706: and pat = pat' located adamc@706: and exp = exp' located adamc@446: and edecl = edecl' located adamc@34: adamc@706: adamc@706: adamc@1: datatype decl' = adamc@1: DCon of string * kind option * con adamc@191: | DDatatype of string * string list * (string * con option) list adamc@156: | DDatatypeImp of string * string list * string adamc@8: | DVal of string * con option * exp adamc@123: | DValRec of (string * con option * exp) list adamc@30: | DSgn of string * sgn adamc@30: | DStr of string * sgn option * str adamc@48: | DFfiStr of string * sgn adamc@61: | DOpen of string * string list adamc@88: | DConstraint of con * con adamc@88: | DOpenConstraints of string * string list adamc@109: | DExport of str adamc@704: | DTable of string * con * exp adamc@338: | DSequence of string adamc@563: | DClass of string * kind * con adamc@271: | DDatabase of string adamc@459: | DCookie of string * con adamc@30: adamc@30: and str' = adamc@30: StrConst of decl list adamc@30: | StrVar of string adamc@34: | StrProj of str * string adamc@40: | StrFun of string * sgn * sgn option * str adamc@44: | StrApp of str * str adamc@1: adamc@1: withtype decl = decl' located adamc@30: and str = str' located adamc@1: adamc@1: type file = decl list adamc@1: adamc@0: end