Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (61 sloc) 2.48 KB
-- A (typed) tree language for Cool abstract syntax trees
module COOL[] begin
type Symbol;
type Boolean;
phylum Program;
phylum Class_;
phylum Classes = LIST[Class_];
phylum Feature;
phylum Features = LIST[Feature];
phylum Formal;
phylum Formals = LIST[Formal];
phylum Expression;
phylum Expressions = LIST[Expression];
phylum Case;
phylum Cases = LIST[Case];
constructor program(classes : Classes) : Program;
constructor class_(name : Symbol; parent: Symbol;
features : Features; filename : Symbol): Class_;
-- Features:
constructor method(name : Symbol;
formals : Formals;
return_type : Symbol;
expr: Expression) : Feature;
constructor attr(name, type_decl : Symbol;
init : Expression) : Feature;
-- Formals
constructor formal(name, type_decl: Symbol) : Formal;
-- Case
constructor branch(name, type_decl: Symbol; expr: Expression): Case;
-- Expressions
constructor assign(name : Symbol; expr : Expression) : Expression;
constructor static_dispatch(expr: Expression;
type_name : Symbol;
name : Symbol;
actual : Expressions) : Expression;
constructor dispatch(expr : Expression;
name : Symbol;
actual : Expressions) : Expression;
constructor cond(pred, then_exp, else_exp : Expression): Expression;
constructor loop(pred, body: Expression) : Expression;
constructor typcase(expr: Expression; cases: Cases): Expression;
constructor block(body: Expressions) : Expression;
constructor let(identifier, type_decl: Symbol;
init, body: Expression): Expression;
constructor plus(e1, e2: Expression) : Expression;
constructor sub(e1, e2: Expression) : Expression;
constructor mul(e1, e2: Expression) : Expression;
constructor divide(e1, e2: Expression) : Expression;
constructor neg(e1: Expression) : Expression;
constructor lt(e1, e2: Expression) : Expression;
constructor eq(e1, e2: Expression) : Expression;
constructor leq(e1, e2: Expression) : Expression;
constructor comp(e1: Expression) : Expression;
constructor int_const(token: Symbol) : Expression;
constructor bool_const(val: Boolean) : Expression;
constructor string_const(token: Symbol) : Expression;
constructor new_(type_name: Symbol): Expression;
constructor isvoid(e1: Expression): Expression;
constructor no_expr(): Expression;
constructor object(name: Symbol): Expression;
end;
You can’t perform that action at this time.