Artifact Content
Not logged in

Artifact 9b22488b3393157f8a276d5c40d20c612e8d36f5


/**
 * Authors: k.inaba
 * License: NYSL 0.9982 http://www.kmonos.net/nysl/
 *
 * Syntax tree for Polemy programming language.
 */
module polemy.ast;
import polemy._common;
import polemy.lex : LexPosition;

alias Statement[] Program;

abstract class Statement
{
	immutable LexPosition pos;
	mixin SimpleConstructor;
}

class DeclStatement : Statement
{
	string     var;
	Expression expr;
	mixin SimpleConstructor;
	mixin SimpleCompare;
}

class ExprStatement : Statement
{
	Expression expr;
	mixin SimpleConstructor;
	mixin SimpleCompare;
}

abstract class Expression
{
	immutable LexPosition pos;
	mixin SimpleConstructor;
	mixin SimpleCompare;
}

class StrLiteralExpression : Expression
{
	string data;
	mixin SimpleConstructor;
	mixin SimpleCompare;
}

class IntLiteralExpression : Expression
{
	BigInt data;
	mixin SimpleConstructor;
	mixin SimpleCompare;
}

class VarExpression : Expression
{
	string var;
	mixin SimpleConstructor;
	mixin SimpleCompare;
}

class AssignExpression : Expression
{
	Expression lhs;
	Expression rhs;
	mixin SimpleConstructor;
	mixin SimpleCompare;
}

class FuncallExpression : Expression
{
	Expression   fun;
	Expression[] args;
	this(immutable LexPosition pos, Expression fun, Expression[] args...)
		{ super(pos); this.fun=fun; this.args=args.dup; }
	mixin SimpleCompare;
}

class FunLiteralExpression : Expression
{
	string[] params;
	Program  funbody;
	mixin SimpleConstructor;
	mixin SimpleCompare;
}