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@38: | KRecord of kind adamc@38: 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@38: | CName of string adamc@38: adamc@38: | CRecord of kind * (con * con) list adamc@38: | CConcat of con * con adamc@68: | CFold of kind * kind adamc@38: adamc@87: | CUnit adamc@87: adamc@38: withtype con = con' located adamc@38: 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@38: | ERecord of (con * exp * con) list adamc@38: | EField of exp * con * { field : con, rest : con } adamc@72: | EFold of kind adamc@38: 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@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 adamc@45: | SgnWhere of sgn * 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@38: | DVal of string * int * con * exp adamc@38: | DSgn of string * int * sgn adamc@38: | DStr of string * int * sgn * str adamc@48: | DFfiStr of string * int * sgn 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