1structure Asynt = struct 2datatype Lab = 3 INTlab of int 4 | STRINGlab of string 5 6fun mkTupleRow' n [] = [] 7 | mkTupleRow' n (x :: xs) = 8 (INTlab n, x) :: mkTupleRow' (n+1) xs 9 10fun mkTupleRow xs = mkTupleRow' 1 xs; 11 12type QualifiedIdent = 13{ 14 id: string, 15 qual: string 16}; 17 18type 'a global = 19{ 20 info: 'a, (* Description *) 21 qualid: QualifiedIdent (* Full name *) 22}; 23 24type Location = (int * int) * (int * int); 25fun xxLR ((a, b), _) ((c, d), _) = (a, d); 26 27type IdDesc = 28{ 29 idLoc : Location, 30 withOp : bool 31}; 32 33type IdInfo = IdDesc global; 34 35fun mkIdInfo (loc, qualid) withOp = 36 { qualid = qualid, 37 info = { idLoc=loc, withOp=withOp }} 38; 39 40 41type TyVar = IdInfo; 42 43type 'a Row = (Lab * 'a) list; 44 45datatype Ty' = 46 TYVARty of TyVar 47 | RECty of Ty Row 48 | CONty of Ty list * IdInfo 49 | FNty of Ty * Ty 50withtype Ty = Location * Ty'; 51 52fun tupleTy [t] = t 53 | tupleTy ts = 54 let open List 55 val loc = xxLR (hd ts) (last ts) 56 in 57 (loc, RECty (mkTupleRow ts)) 58 end 59 60datatype TyNameEqu = FALSEequ | TRUEequ | REFequ; 61 62datatype ConBind = ConBind of IdInfo * Ty option 63 64type TypBind = TyVar list * IdInfo * Ty 65 66and TypDesc = TyVar list * IdInfo 67 68and DatBind = TyVar list * IdInfo * ConBind list 69 70and PrimValBind = IdInfo * Ty * int * string 71 72type ValDesc = IdInfo * Ty; 73type ExDesc = IdInfo * Ty option; 74 75type LocString = Location * string; 76type ModId = LocString; 77type SigId = LocString; 78 79datatype Spec' = 80 VALspec of ValDesc list 81 | PRIM_VALspec of PrimValBind list 82 | TYPEDESCspec of TyNameEqu * TypDesc list 83 | TYPEspec of TypBind list 84 | DATATYPEspec of DatBind list * TypBind list option 85 | DATATYPErepspec of IdInfo * IdInfo 86 | EXCEPTIONspec of ExDesc list 87 | LOCALspec of Spec * Spec 88 | OPENspec of string list 89 | INCLUDEspecs of string list 90 | INCLUDEspec of SigExp 91 | EMPTYspec 92 | SEQspec of Spec * Spec 93 | STRUCTUREspec of ModDesc 94and ModDesc = MODDESCmoddesc of ModId * SigExp 95and SigExp' = SIGIDsigexp of SigId 96 | AnonSigThing of Spec list 97withtype Spec = Location * Spec' 98and SigExp = Location * SigExp' * TypBind list; 99 100datatype Sig = 101 NamedSig of {locsigid : LocString, specs : Spec list} 102 | AnonSig of Spec list; 103 104end 105