Artifact 79741a318661128808458af9a3d74b5ee2dae560
1 /**
2 * Authors: k.inaba
3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/
4 *
5 * Syntax tree for Polemy programming language.
6 */
7 module polemy.ast;
8 import polemy._common;
9 import polemy.lex : LexPosition;
10
11 alias Statement[] Program;
12
13 abstract class Statement
14 {
15 immutable LexPosition pos;
16 mixin SimpleConstructor;
17 }
18
19 class DeclStatement : Statement
20 {
21 string var;
22 Expression expr;
23 mixin SimpleConstructor;
24 mixin SimpleCompare; // do not take "pos" into account
25 }
26
27 class ExprStatement : Statement
28 {
29 Expression expr;
30 mixin SimpleConstructor;
31 mixin SimpleCompare; // do not take "pos" into account
32 }
33
34 abstract class Expression
35 {
36 immutable LexPosition pos;
37 mixin SimpleConstructor;
38 mixin SimpleCompare; // do not take "pos" into account
39 }
40
41 class StrLiteralExpression : Expression
42 {
43 string data;
44 mixin SimpleConstructor;
45 mixin SimpleCompare; // do not take "pos" into account
46 }
47
48 class IntLiteralExpression : Expression
49 {
50 BigInt data;
51 mixin SimpleConstructor;
52 mixin SimpleCompare; // do not take "pos" into account
53 }
54
55 class VarExpression : Expression
56 {
57 string var;
58 mixin SimpleConstructor;
59 mixin SimpleCompare; // do not take "pos" into account
60 }
61
62 class AssignExpression : Expression
63 {
64 Expression lhs;
65 Expression rhs;
66 mixin SimpleConstructor;
67 mixin SimpleCompare; // do not take "pos" into account
68 }
69
70 class FuncallExpression : Expression
71 {
72 Expression fun;
73 Expression[] args;
74 this(immutable LexPosition pos, Expression fun, Expression[] args...)
75 { super(pos); this.fun=fun; this.args=args.dup; }
76 mixin SimpleCompare; // do not take "pos" into account
77 }
78
79 class FunLiteralExpression : Expression
80 {
81 string[] params;
82 Program funbody;
83 mixin SimpleConstructor;
84 mixin SimpleCompare; // do not take "pos" into account
85 }