import java.io.*; import edu.neu.ccs.demeterf.*; import edu.neu.ccs.demeterf.util.Util; import edu.neu.ccs.demeterf.control.*; public Main = Exp. public Exp: Var | Num | If | Lambda | Call | Op | Bool | LetRec. //************** //* LetRec is as defined below. Extend the TypeChecker, and //* AddressTranslation to handle LetRec buy modifying the //* LetrecTypeChecker.java and LetrecAddrTrans.java files //* in the 'extra' directory. //* The evaluator is ready to handle them once the Syms are //* translated into Addrs correctly //************** public LetRec = "(letrec" *s "(" Arg *s Exp ")" *s Exp ")". //** Single Argument Lambda... Comment this and uncomment the //* multiargs version when you're ready public Lambda = "(lambda" *s "(" Arg ")" *s Exp ")". //** Here's the Multiple Arg Syntax... It's sommented out so //* you can get LetRec Working first //public Lambda = "(lambda" *s "(" ArgList ")" *s Exp ")". public Var: Sym | Addr. public Sym = Ident. public Addr = "{" Integer "}" extends Var. public Arg = Type *s Sym. public Num = Integer. public Bool: True | False. public True = "#t". public False = "#f". public If = "(if" *s Exp *s Exp *s Exp ")". public Call = "(" Exp *s ExpList ")". public Op: Plus | Minus | Mult | Div | Less | Greater | Or | And | Eq | Print common implements Val. public Plus = "+". public Minus = "-". public Div = "/". public Mult = "*". public Less = "<". public Greater = ">". public Or = "or". public And = "and". public Eq = "=". public Print = "print<" Type ">". public Type: BoolT | NumT | FuncT. public BoolT = "bool". public NumT = "int". public FuncT = "(" TypeList "-> " Type ")". public SymList: SymCons | SymEmpty. public SymCons = Sym *s SymList implements ConsList. public SymEmpty = implements EmptyList. public ArgList: ArgCons | ArgEmpty. public ArgCons = "(" Arg ")" *s ArgList implements ConsList. public ArgEmpty = implements EmptyList. public ExpList: ExpCons | ExpEmpty. public ExpCons = Exp *s ExpList implements ConsList. public ExpEmpty = implements EmptyList. public TypeList: TypeCons | TypeEmpty. public TypeCons = Type *s TypeList implements ConsList. public TypeEmpty = implements EmptyList. noparse // Values public interface Val:. public LambdaVal = Lambda ValList implements Val. public NumVal = int implements Val. public ValList: ValCons | ValEmpty. public ValCons = Val ValList implements ConsList. public ValEmpty = implements EmptyList. public TEnv: TEnvCons | TEnvEmpty. public TEnvCons = Sym Type *s TEnv. public TEnvEmpty = . public interface ConsList:. public interface EmptyList:. public RE = extends RuntimeException. public TE = extends RuntimeException.