class Node(object): pass class Program(Node): def __init__(self, functions, lineno = None): self.functions = functions self.lineno = lineno class Function(Node): def __init__(self, name, params, statements, lineno = None): self.name = name self.params = params self.statements = statements self.lineno = lineno def __repr__(self): return "" % (name, lineno) class Statement(Node): pass class IfStatement(Statement): def __init__(self, expression, true_statements, false_statements, lineno = None): self.expression = expression self.true_statements = true_statements self.false_statements = false_statements self.lineno = lineno def __repr__(self): return "" % lineno class WhileStatement(Statement): def __init__(self, expression, statements, lineno = None): self.expression = expression self.statements = statements self.lineno = lineno def __repr__(self): return "" % lineno class ReturnStatement(Statement): def __init__(self, expression, lineno = None): self.expression = expression self.lineno = lineno def __repr__(self): return "" % lineno class AssignStatement(Statement): def __init__(self, ident, expression, lineno = None): self.ident = ident self.expression = expression self.lineno = lineno def __repr__(self): return "" % (ident, lineno) class FunctionCall(Statement): def __init__(self, ident, arguments, lineno = None): self.ident = ident self.arguments = arguments self.lineno = lineno def __repr__(self): return "" % (ident, lineno) class Expression(Node): pass class UnaryExpression(Expression): def __init__(self, op, right, lineno = None): self.op = op self.right = right self.lineno = lineno def __repr__(self): return "" % (op, right, lineno) class BinaryExpression(Expression): def __init__(self, left, op, right, lineno = None): self.left = left self.op = op self.right = right self.lineno = lineno def __repr__(self): return "" % (op, left, right, lineno)