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", {
10 {"std::string", "path"},
11 {"std::vector<Node *> *", "decls"},
16 {"Type", "Node", "Represent a type", {
17 {"std::string", "name"},
22 {"Number", "Type", "Represent an abstract number", {
27 {"Integer", "Number", "Represent an integer", {
32 {"Float", "Number", "Represent a float", {
37 {"Pointer", "Type", "Represent a pointer", {
43 {"Enum", "Type", "Represent an enum", {
45 {"unsigned", "count"},
51 {"Array", "Type", "Represent an array", {
57 {"VarDecl", "Node", "Represent a variable declaration", {
58 {"std::string", "name"},
65 {"Exp", "Node", "Represent an abstract expression", {
70 {"AssignExp", "Exp", "Represent an assignment expression", {
71 {"std::string", "name"},
76 {"BinaryExp", "Exp", "Base class for binary expression", {
82 {"EqExp", "BinaryExp", "Expression `=='", {
87 {"NeqExp", "BinaryExp", "Expression `!='", {
92 {"LtExp", "BinaryExp", "Expression `<'", {
97 {"LtEqExp", "BinaryExp", "Expression `<='", {
102 {"GtExp", "BinaryExp", "Expression `>'", {
107 {"GtEqExp", "BinaryExp", "Expression `>='", {
112 {"AddExp", "BinaryExp", "Expression `+'", {
117 {"SubExp", "BinaryExp", "Expression `-'", {
122 {"MulExp", "BinaryExp", "Expression `*'", {
127 {"DivExp", "BinaryExp", "Expression `/'", {
132 {"ModExp", "BinaryExp", "Expression `%'", {
137 {"NumberExp", "Exp", "A number", {
142 {"IdExp", "Exp", "An identifier", {
143 {"std::string", "name"}
148 {"Block", "Node", "Represent a block with a new scope", {
149 {"Scope *", "scope"},
150 {"std::vector<VarDecl *> *", "varDecls"},
151 {"std::vector<Node *> *", "instrs"},
157 {"Function", "Node", "Represent a function declaration", {
158 {"std::string", "name"},
159 {"Type *", "returnType"},
160 {"std::vector<Type *> *", "params"},
161 {"Block *", "block"},
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 {"", "", "", {{"", ""}}}