adamc@16: (* Copyright (c) 2008, Adam Chlipala
adamc@16:  * All rights reserved.
adamc@16:  *
adamc@16:  * Redistribution and use in source and binary forms, with or without
adamc@16:  * modification, are permitted provided that the following conditions are met:
adamc@16:  *
adamc@16:  * - Redistributions of source code must retain the above copyright notice,
adamc@16:  *   this list of conditions and the following disclaimer.
adamc@16:  * - Redistributions in binary form must reproduce the above copyright notice,
adamc@16:  *   this list of conditions and the following disclaimer in the documentation
adamc@16:  *   and/or other materials provided with the distribution.
adamc@16:  * - The names of contributors may not be used to endorse or promote products
adamc@16:  *   derived from this software without specific prior written permission.
adamc@16:  *
adamc@16:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
adamc@16:  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
adamc@16:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
adamc@16:  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
adamc@16:  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
adamc@16:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
adamc@16:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
adamc@16:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
adamc@16:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
adamc@16:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
adamc@16:  * POSSIBILITY OF SUCH DAMAGE.
adamc@16:  *)
adamc@16: 
adamc@16: structure Core = struct
adamc@16: 
adamc@16: type 'a located = 'a ErrorMsg.located
adamc@16: 
adamc@16: datatype kind' =
adamc@16:          KType
adamc@16:        | KArrow of kind * kind
adamc@16:        | KName
adamc@16:        | KRecord of kind
adamc@87:        | KUnit
adamc@214:        | KTuple of kind list
adamc@16: 
adamc@626:        | KRel of int
adamc@626:        | KFun of string * kind
adamc@626: 
adamc@16: withtype kind = kind' located
adamc@16: 
adamc@16: datatype con' =
adamc@16:          TFun of con * con
adamc@16:        | TCFun of string * kind * con
adamc@16:        | TRecord of con
adamc@16: 
adamc@16:        | CRel of int
adamc@16:        | CNamed of int
adamc@48:        | CFfi of string * string
adamc@16:        | CApp of con * con
adamc@16:        | CAbs of string * kind * con
adamc@16: 
adamc@626:        | CKAbs of string * con
adamc@626:        | CKApp of con * kind
adamc@626:        | TKFun of string * con
adamc@626: 
adamc@16:        | CName of string
adamc@16: 
adamc@16:        | CRecord of kind * (con * con) list
adamc@16:        | CConcat of con * con
adamc@621:        | CMap of kind * kind
adamc@16: 
adamc@87:        | CUnit
adamc@87: 
adamc@214:        | CTuple of con list
adamc@214:        | CProj of con * int
adamc@214: 
adamc@16: withtype con = con' located
adamc@16: 
adamc@731: datatype datatype_kind = datatype DatatypeKind.datatype_kind
adamc@188: 
adamc@177: datatype patCon =
adamc@177:          PConVar of int
adamc@192:        | PConFfi of {mod : string, datatyp : string, params : string list,
adamc@192:                      con : string, arg : con option, kind : datatype_kind}
adamc@177: 
adamc@177: datatype pat' =
adamc@177:          PWild
adamc@182:        | PVar of string * con
adamc@177:        | PPrim of Prim.t
adamc@192:        | PCon of datatype_kind * patCon * con list * pat option
adamc@182:        | PRecord of (string * pat * con) list
adamc@177: 
adamc@177: withtype pat = pat' located
adamc@177: 
adamc@16: datatype exp' =
adamc@16:          EPrim of Prim.t
adamc@16:        | ERel of int
adamc@16:        | ENamed of int
adamc@192:        | ECon of datatype_kind * patCon * con list * exp option
adamc@48:        | EFfi of string * string
adam@1663:        | EFfiApp of string * string * (exp * con) list
adamc@16:        | EApp of exp * exp
adamc@26:        | EAbs of string * con * con * exp
adamc@16:        | ECApp of exp * con
adamc@16:        | ECAbs of string * kind * exp
adamc@16: 
adamc@626:        | EKAbs of string * exp
adamc@626:        | EKApp of exp * kind
adamc@626: 
adamc@29:        | ERecord of (con * exp * con) list
adamc@16:        | 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@16: 
adamc@182:        | ECase of exp * (pat * exp) list * { disc : con, result : con }
adamc@177: 
adamc@102:        | EWrite of exp
adamc@102: 
adamc@110:        | EClosure of int * exp list
adamc@110: 
adamc@450:        | ELet of string * con * exp * exp
adamc@450: 
adamc@1020:        | EServerCall of int * exp list * con
adamc@607: 
adamc@16: withtype exp = exp' located
adamc@16: 
adamc@731: datatype effect = datatype Export.effect
adamc@731: datatype export_kind = datatype Export.export_kind
adamc@144: 
adamc@16: datatype decl' =
adamc@16:          DCon of string * int * kind * con
adamc@807:        | DDatatype of (string * int * string list * (string * int * con option) list) list
adamc@109:        | DVal of string * int * con * exp * string
adamc@125:        | DValRec of (string * int * con * exp * string) list
adamc@1104:        | DExport of export_kind * int * bool
adamc@707:        | DTable of string * int * con * string * exp * con * exp * con
adamc@338:        | DSequence of string * int * string
adamc@754:        | DView of string * int * string * exp * con
adamc@271:        | DDatabase of string
adamc@461:        | DCookie of string * int * con * string
adamc@720:        | DStyle of string * int * string
adamc@1075:        | DTask of exp * exp
adamc@1199:        | DPolicy of exp
adam@1294:        | DOnError of int
adamc@16: 
adamc@16: withtype decl = decl' located
adamc@16: 
adamc@16: type file = decl list
adamc@16: 
adamc@16: end