Generates llvm assembly code for additions :-)
[ozulis.git] / src / ast / generator-data.cc
blob8a23e84b2bbc717074a6b88cf4d2690c93d599e5
1 #include "generator.hh"
3 namespace ag = ast::generator;
5 const ag::Node ag::nodes[] = {
6 {"Node", "", "The root node", {{"", ""}}},
8 {"File", "Node", "Represent a file", {
9 {"Scope *", "scope"},
10 {"std::string", "path"},
11 {"std::vector<Node *> *", "decls"},
15 /* Types */
16 {"Type", "Node", "Represent a type", {
17 {"std::string", "name"},
18 {"bool", "isConst"}
22 {"Number", "Type", "Represent an abstract number", {
23 {"", ""}
27 {"Integer", "Number", "Represent an integer", {
28 {"", ""}
32 {"Float", "Number", "Represent a float", {
33 {"", ""}
37 {"Pointer", "Type", "Represent a pointer", {
38 {"Type *", "type"},
39 {"", ""}
43 {"Enum", "Type", "Represent an enum", {
44 {"Type *", "type"},
45 {"unsigned", "count"},
46 /* FIXME: elements */
47 {"", ""}
51 {"Array", "Type", "Represent an array", {
52 {"Type *", "type"},
53 {"", ""}
57 {"VarDecl", "Node", "Represent a variable declaration", {
58 {"std::string", "name"},
59 {"Type *", "type"},
60 {"", ""}
64 /* Expressions */
65 {"Exp", "Node", "Represent an abstract expression", {
66 {"", ""}
70 {"AssignExp", "Exp", "Represent an assignment expression", {
71 {"std::string", "name"},
72 {"Exp *", "value"},
76 {"BinaryExp", "Exp", "Base class for binary expression", {
77 {"Exp *", "left"},
78 {"Exp *", "right"},
82 {"EqExp", "BinaryExp", "Expression `=='", {
83 {"", ""}
87 {"NeqExp", "BinaryExp", "Expression `!='", {
88 {"", ""}
92 {"LtExp", "BinaryExp", "Expression `<'", {
93 {"", ""}
97 {"LtEqExp", "BinaryExp", "Expression `<='", {
98 {"", ""}
102 {"GtExp", "BinaryExp", "Expression `>'", {
103 {"", ""}
107 {"GtEqExp", "BinaryExp", "Expression `>='", {
108 {"", ""}
112 {"AddExp", "BinaryExp", "Expression `+'", {
113 {"", ""}
117 {"SubExp", "BinaryExp", "Expression `-'", {
118 {"", ""}
122 {"MulExp", "BinaryExp", "Expression `*'", {
123 {"", ""}
127 {"DivExp", "BinaryExp", "Expression `/'", {
128 {"", ""}
132 {"ModExp", "BinaryExp", "Expression `%'", {
133 {"", ""}
137 {"NumberExp", "Exp", "A number", {
138 {"int", "number"}
142 {"IdExp", "Exp", "An identifier", {
143 {"std::string", "name"}
147 /* Block */
148 {"Block", "Node", "Represent a block with a new scope", {
149 {"Scope *", "scope"},
150 {"std::vector<VarDecl *> *", "varDecls"},
151 {"std::vector<Node *> *", "instrs"},
152 {"", ""}
156 /* Functions */
157 {"Function", "Node", "Represent a function declaration", {
158 {"std::string", "name"},
159 {"Type *", "returnType"},
160 {"std::vector<Type *> *", "params"},
161 {"Block *", "block"},
162 {"", ""}
166 /* 3 address decomposition */
167 {"TmpResultExp", "Exp", "A temporary result, used for 3 address", {
168 {"std::string", "name"}
172 {"LoadVar", "Node", "A temporary result, used for 3 address", {
173 {"std::string", "name"},
174 {"std::string", "to"}
178 {"StoreVar", "Node", "A temporary result, used for 3 address", {
179 {"std::string", "name"},
180 {"Exp *", "value"}, // must be TmpResultExp or NumberExp
184 {"", "", "", {{"", ""}}}