1% Signature file for abstract syntax of Bobcat language. 2 3sig bobabsyn. 4 5kind texp type. % basic type of all tiger expressions. 6kind tvar type. 7kind ttype type. % meta-level type of tiger types 8kind tdec type. 9kind tfieldexp, tfield type. 10 11% Based on "Modern Compiler Implementation in Java" page 103. 12 13type simplevar string -> tvar. % x 14type fieldvar tvar -> string -> tvar. % x.y 15type subscriptvar tvar -> texp -> tvar. % x[i+j] 16 17type varexp tvar -> texp. 18type nilexp, breakexp texp. 19type intexp int -> texp. 20type stringexp string -> texp. 21type callexp tvar -> (list texp) -> texp. %string changed to tvar (bob) 22type opexp string -> texp -> texp -> texp. % using strings. 23type dummyexp texp. % dummy expression (null) 24type recordexp string -> (list tfieldexp) -> texp. 25type seqexp (list texp) -> texp. 26type assignexp tvar -> texp -> texp. 27type ifexp texp -> texp -> texp -> texp. % use dummy 28type whileexp texp -> texp -> texp. 29type forexp tdec -> texp -> texp -> texp. 30type arrayexp string -> texp -> texp -> texp. 31type fletexp (list tdec) -> texp -> texp. % foas version 32 33type namety string -> ttype. 34type recordty (list tfield) -> ttype. 35type arrayty string -> ttype. 36type dummytype ttype. 37 38type typedec string -> ttype -> tdec. 39type vardec string -> ttype -> texp -> tdec. 40type functiondec string -> (list tfield) -> ttype -> texp -> tdec. 41type classdec string -> (list tfield) -> (list tdec) -> tdec. 42 43% dependent types would be convenient. 44 45% higher-order version records arity and target type. 46% must implement Currying here 47type hfuncdec string -> int -> ttype -> (texp -> texp) -> tdec. 48 49type etpair texp -> ttype -> tfield. % exp - type pair 50type eepair texp -> texp -> tfieldexp. % exp - exp pair 51type depair tdec -> texp -> texp. 52 53% Higher order abstract syntax version. 54% The extra "absterm" is necessary for Currying. 55% All declarations are for strings, which will be abstracted over. 56% Function declaration must include argument and return types. 57% letexp expects nameterms. fixptdec expects absterms. 58% The callexp form will be retained in abstract syntax - it will be 59% curried during interpretation/compilation. 60 61 62type letexp tdec -> texp -> texp. 63%type letexp tdec -> (string -> texp) -> texp. 64type fixptdec string -> (string -> texp) -> (list ttype) -> ttype -> tdec. 65type absterm (texp -> texp) -> texp. 66type nameterm (string -> texp) -> texp. 67 68% needed for allowing mutually recursive declarations: 69type decabs (string -> tdec) -> tdec. 70type declist (list tdec) -> tdec. % type coersion 71 72type coercexp tdec -> texp. 73 74% meta-level predicates for reasoning with abstract syntax: 75 76type copyexp texp -> texp -> o. 77type copyty ttype -> ttype -> o. 78type copyvar tvar -> tvar -> o. % don't really need to be this complicated 79type copystr string -> string -> o. 80type copydec tdec -> tdec -> o. 81 82type hastype texp -> ttype -> o. 83% etc ... 84 85% moved from kitty.sig 8/03 86type fixdec2 string -> texp -> (list ttype) -> ttype -> tdec. 87type let2 texp -> texp. 88type changelet (list string) -> tdec -> texp -> texp -> o. 89type changelet0 texp -> texp -> o. 90 91 92% simple let expression for testing 93type let0 texp -> (texp -> texp) -> texp. 94type lamexp (texp -> texp) -> texp. 95