File Annotation
Not logged in
820e7198cc 2010-11-07        kinaba: /**
4198578702 2010-11-07        kinaba:  * Authors: k.inaba
4198578702 2010-11-07        kinaba:  * License: NYSL 0.9982 http://www.kmonos.net/nysl/
4198578702 2010-11-07        kinaba:  *
4198578702 2010-11-07        kinaba:  * Syntax tree for Polemy programming language.
423f308350 2010-11-07        kinaba:  */
4198578702 2010-11-07        kinaba: module polemy.ast;
4198578702 2010-11-07        kinaba: import polemy._common;
80ff567c75 2010-11-08        kinaba: import polemy.lex;
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: alias Statement[] Program;
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: abstract class Statement
423f308350 2010-11-07        kinaba: {
423f308350 2010-11-07        kinaba: 	immutable LexPosition pos;
423f308350 2010-11-07        kinaba: 	mixin SimpleConstructor;
423f308350 2010-11-07        kinaba: }
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: class DeclStatement : Statement
423f308350 2010-11-07        kinaba: {
423f308350 2010-11-07        kinaba: 	string     var;
423f308350 2010-11-07        kinaba: 	Expression expr;
80ff567c75 2010-11-08        kinaba: 	mixin SimpleClass;
423f308350 2010-11-07        kinaba: }
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: class ExprStatement : Statement
423f308350 2010-11-07        kinaba: {
423f308350 2010-11-07        kinaba: 	Expression expr;
80ff567c75 2010-11-08        kinaba: 	mixin SimpleClass;
423f308350 2010-11-07        kinaba: }
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: abstract class Expression
423f308350 2010-11-07        kinaba: {
423f308350 2010-11-07        kinaba: 	immutable LexPosition pos;
423f308350 2010-11-07        kinaba: 	mixin SimpleConstructor;
423f308350 2010-11-07        kinaba: }
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: class StrLiteralExpression : Expression
423f308350 2010-11-07        kinaba: {
423f308350 2010-11-07        kinaba: 	string data;
80ff567c75 2010-11-08        kinaba: 	mixin SimpleClass;
423f308350 2010-11-07        kinaba: }
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: class IntLiteralExpression : Expression
423f308350 2010-11-07        kinaba: {
423f308350 2010-11-07        kinaba: 	BigInt data;
80ff567c75 2010-11-08        kinaba: 	mixin SimpleClass;
423f308350 2010-11-07        kinaba: }
423f308350 2010-11-07        kinaba: 
423f308350 2010-11-07        kinaba: class VarExpression : Expression
423f308350 2010-11-07        kinaba: {
423f308350 2010-11-07        kinaba: 	string var;
80ff567c75 2010-11-08        kinaba: 	mixin SimpleClass;
423f308350 2010-11-07        kinaba: }
423f308350 2010-11-07        kinaba: 
5d4cb856d8 2010-11-07        kinaba: class AssignExpression : Expression
423f308350 2010-11-07        kinaba: {
423f308350 2010-11-07        kinaba: 	Expression lhs;
423f308350 2010-11-07        kinaba: 	Expression rhs;
80ff567c75 2010-11-08        kinaba: 	mixin SimpleClass;
5d4cb856d8 2010-11-07        kinaba: }
3f5dc76a75 2010-11-07        kinaba: 
5d4cb856d8 2010-11-07        kinaba: class FuncallExpression : Expression
5d4cb856d8 2010-11-07        kinaba: {
5d4cb856d8 2010-11-07        kinaba: 	Expression   fun;
5d4cb856d8 2010-11-07        kinaba: 	Expression[] args;
5d4cb856d8 2010-11-07        kinaba: 	this(immutable LexPosition pos, Expression fun, Expression[] args...)
5d4cb856d8 2010-11-07        kinaba: 		{ super(pos); this.fun=fun; this.args=args.dup; }
80ff567c75 2010-11-08        kinaba: 	mixin SimpleClass;
3f5dc76a75 2010-11-07        kinaba: }
3f5dc76a75 2010-11-07        kinaba: 
3f5dc76a75 2010-11-07        kinaba: class FunLiteralExpression : Expression
3f5dc76a75 2010-11-07        kinaba: {
3f5dc76a75 2010-11-07        kinaba: 	string[] params;
3f5dc76a75 2010-11-07        kinaba: 	Program  funbody;
80ff567c75 2010-11-08        kinaba: 	mixin SimpleClass;
80ff567c75 2010-11-08        kinaba: }
80ff567c75 2010-11-08        kinaba: 
80ff567c75 2010-11-08        kinaba: /// Handy Generator for AST nodes. To use this, mixin EasyAst;
80ff567c75 2010-11-08        kinaba: 
80ff567c75 2010-11-08        kinaba: /*mixin*/
80ff567c75 2010-11-08        kinaba: template EasyAst()
80ff567c75 2010-11-08        kinaba: {
80ff567c75 2010-11-08        kinaba: 	template genEast(T)
80ff567c75 2010-11-08        kinaba: 		{ T genEast(P...)(P ps) { return new T(LexPosition.dummy, ps); } }
80ff567c75 2010-11-08        kinaba: 
80ff567c75 2010-11-08        kinaba: 	alias genEast!DeclStatement decl;
80ff567c75 2010-11-08        kinaba: 	alias genEast!ExprStatement expr;
80ff567c75 2010-11-08        kinaba: 	alias genEast!VarExpression var;
80ff567c75 2010-11-08        kinaba: 	alias genEast!FuncallExpression funcall;
80ff567c75 2010-11-08        kinaba: 	alias genEast!IntLiteralExpression intl;
80ff567c75 2010-11-08        kinaba: 	alias genEast!StrLiteralExpression strl;
80ff567c75 2010-11-08        kinaba: 	alias genEast!FunLiteralExpression fun;
423f308350 2010-11-07        kinaba: }