adamc@38: (* Copyright (c) 2008, Adam Chlipala adamc@38: * All rights reserved. adamc@38: * adamc@38: * Redistribution and use in source and binary forms, with or without adamc@38: * modification, are permitted provided that the following conditions are met: adamc@38: * adamc@38: * - Redistributions of source code must retain the above copyright notice, adamc@38: * this list of conditions and the following disclaimer. adamc@38: * - Redistributions in binary form must reproduce the above copyright notice, adamc@38: * this list of conditions and the following disclaimer in the documentation adamc@38: * and/or other materials provided with the distribution. adamc@38: * - The names of contributors may not be used to endorse or promote products adamc@38: * derived from this software without specific prior written permission. adamc@38: * adamc@38: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" adamc@38: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE adamc@38: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE adamc@38: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE adamc@38: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR adamc@38: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF adamc@38: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS adamc@38: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN adamc@38: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) adamc@38: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE adamc@38: * POSSIBILITY OF SUCH DAMAGE. adamc@38: *) adamc@38: adamc@38: structure Expl = struct adamc@38: adamc@38: type 'a located = 'a ErrorMsg.located adamc@38: adamc@38: datatype kind' = adamc@38: KType adamc@38: | KArrow of kind * kind adamc@38: | KName adamc@87: | KUnit adamc@213: | KTuple of kind list adamc@38: | KRecord of kind adamc@38: adamc@624: | KRel of int adamc@624: | KFun of string * kind adamc@624: adamc@38: withtype kind = kind' located adamc@38: adamc@38: datatype con' = adamc@38: TFun of con * con adamc@38: | TCFun of string * kind * con adamc@38: | TRecord of con adamc@38: adamc@38: | CRel of int adamc@38: | CNamed of int adamc@38: | CModProj of int * string list * string adamc@38: | CApp of con * con adamc@38: | CAbs of string * kind * con adamc@38: adamc@624: | CKAbs of string * con adamc@624: | CKApp of con * kind adamc@624: | TKFun of string * con adamc@624: adamc@38: | CName of string adamc@38: adamc@38: | CRecord of kind * (con * con) list adamc@38: | CConcat of con * con adamc@621: | CMap of kind * kind adamc@38: adamc@87: | CUnit adamc@87: adamc@213: | CTuple of con list adamc@213: | CProj of con * int adamc@213: adamc@38: withtype con = con' located adamc@38: adamc@731: datatype datatype_kind = datatype DatatypeKind.datatype_kind adamc@188: adamc@176: datatype patCon = adamc@176: PConVar of int adamc@176: | PConProj of int * string list * string adamc@176: adamc@176: datatype pat' = adamc@176: PWild adamc@182: | PVar of string * con adamc@176: | PPrim of Prim.t adamc@191: | PCon of datatype_kind * patCon * con list * pat option adamc@182: | PRecord of (string * pat * con) list adamc@176: adamc@176: withtype pat = pat' located adamc@176: adamc@38: datatype exp' = adamc@38: EPrim of Prim.t adamc@38: | ERel of int adamc@38: | ENamed of int adamc@38: | EModProj of int * string list * string adamc@38: | EApp of exp * exp adamc@38: | EAbs of string * con * con * exp adamc@38: | ECApp of exp * con adamc@38: | ECAbs of string * kind * exp adamc@38: adamc@624: | EKAbs of string * exp adamc@624: | EKApp of exp * kind adamc@624: adamc@38: | ERecord of (con * exp * con) list adamc@38: | EField of exp * con * { field : con, rest : con } adamc@445: | EConcat of exp * con * exp * con adamc@149: | ECut of exp * con * { field : con, rest : con } adamc@493: | ECutMulti of exp * con * { rest : con } adamc@38: adamc@182: | ECase of exp * (pat * exp) list * { disc : con, result : con } adamc@176: adamc@109: | EWrite of exp adamc@109: adamc@449: | ELet of string * con * exp * exp adamc@449: adamc@38: withtype exp = exp' located adamc@38: adamc@38: datatype sgn_item' = adamc@38: SgiConAbs of string * int * kind adamc@38: | SgiCon of string * int * kind * con adamc@806: | SgiDatatype of (string * int * string list * (string * int * con option) list) list adamc@191: | SgiDatatypeImp of string * int * int * string list * string * string list * (string * int * con option) list adamc@38: | SgiVal of string * int * con adamc@64: | SgiSgn of string * int * sgn adamc@38: | SgiStr of string * int * sgn adamc@38: adamc@38: and sgn' = adamc@38: SgnConst of sgn_item list adamc@38: | SgnVar of int adamc@45: | SgnFun of string * int * sgn * sgn adam@1864: | SgnWhere of sgn * string list * string * con adamc@64: | SgnProj of int * string list * string adamc@38: adamc@38: withtype sgn_item = sgn_item' located adamc@38: and sgn = sgn' located adamc@38: adamc@38: datatype decl' = adamc@38: DCon of string * int * kind * con adamc@806: | DDatatype of (string * int * string list * (string * int * con option) list) list adamc@191: | DDatatypeImp of string * int * int * string list * string * string list * (string * int * con option) list adamc@38: | DVal of string * int * con * exp adamc@124: | DValRec of (string * int * con * exp) list adamc@38: | DSgn of string * int * sgn adamc@38: | DStr of string * int * sgn * str adamc@48: | DFfiStr of string * int * sgn adamc@109: | DExport of int * sgn * str adamc@707: | DTable of int * string * int * con * exp * con * exp * con adamc@338: | DSequence of int * string * int adamc@754: | DView of int * string * int * exp * con adamc@271: | DDatabase of string adamc@460: | DCookie of int * string * int * con adamc@720: | DStyle of int * string * int adamc@1075: | DTask of exp * exp adamc@1199: | DPolicy of exp adam@1294: | DOnError of int * string list * string adam@2010: | DFfi of string * int * Source.ffi_mode list * con adamc@38: adamc@38: and str' = adamc@38: StrConst of decl list adamc@38: | StrVar of int adamc@38: | StrProj of str * string adamc@45: | StrFun of string * int * sgn * sgn * str adamc@45: | StrApp of str * str adamc@38: adamc@38: withtype decl = decl' located adamc@38: and str = str' located adamc@38: adamc@38: type file = decl list adamc@38: adamc@38: end