1 #include "generator.hh"
3 namespace ag
= ast::generator
;
5 const ag::Node
ag::nodes
[] = {
6 {"Node", "gc", "The root node", {
7 {"core::id_t", "nodeType"}
11 {"File", "Node", "Represent a file", {
13 {"std::string", "path"},
14 {"std::vector<Node *> *", "decls"},
18 {"Symbol", "Node", "Represent a symbol", {
19 {"std::string", "name"},
21 {"Address *", "address"}
25 {"Address", "Node", "Represent an address", {
30 {"RegisterAddress", "Address", "Represent a register address", {
31 {"std::string", "name"}
35 {"MemoryAddress", "Address", "Represent a memory address", {
36 {"std::string", "name"}
41 {"Type", "Node", "Represent a type", {
42 {"std::string", "name"}, ///< @todo remove this
47 {"VoidType", "Type", "Represent the void type", {
52 {"NumberType", "Type", "Represent an abstract number", {
57 {"BoolType", "NumberType", "Represent a boolean value", {
62 {"IntegerType", "NumberType", "Represent an integer", {
68 {"FloatType", "NumberType", "Represent a float", {
73 {"DoubleType", "NumberType", "Represent a float", {
78 {"PointerType", "Type", "Represent a pointer", {
84 {"ReferenceType", "Type", "Represent a reference", {
90 {"EnumType", "Type", "Represent an enum", {
92 {"unsigned", "count"},
98 {"ArrayType", "Type", "Represent an array", {
100 {"uint16_t", "size"},
105 {"FunctionType", "Type", "Represent a function", {
106 {"Type *", "returnType"},
107 {"std::vector<Type *> *", "argsType"},
112 {"VarDecl", "Node", "Represent a variable declaration", {
113 {"std::string", "name"},
120 {"Exp", "Node", "Represent an abstract expression", {
125 {"VoidExp", "Exp", "Represent a void expression", {
131 {"AssignExp", "Exp", "Represent an assignment expression", {
132 {"Symbol *", "dest"},
137 {"UnaryExp", "Exp", "Base class for unary expression", {
142 {"NegExp", "UnaryExp", "Unary expression `-'", {
147 {"BangExp", "UnaryExp", "Unary expression `!'", {
152 {"NotExp", "UnaryExp", "Unary expression `~'", {
157 {"CastExp", "UnaryExp", "A cast from exp->type to type", {
162 {"DereferenceExp", "UnaryExp", "Derefence a pointer", {
167 {"BinaryExp", "Exp", "Base class for binary expression", {
173 {"EqExp", "BinaryExp", "Expression `=='", {
178 {"NeqExp", "BinaryExp", "Expression `!='", {
183 {"LtExp", "BinaryExp", "Expression `<'", {
188 {"LtEqExp", "BinaryExp", "Expression `<='", {
193 {"GtExp", "BinaryExp", "Expression `>'", {
198 {"GtEqExp", "BinaryExp", "Expression `>='", {
203 {"AddExp", "BinaryExp", "Expression `+'", {
208 {"SubExp", "BinaryExp", "Expression `-'", {
213 {"MulExp", "BinaryExp", "Expression `*'", {
218 {"DivExp", "BinaryExp", "Expression `/'", {
223 {"ModExp", "BinaryExp", "Expression `%'", {
228 {"AndExp", "BinaryExp", "Expression `&'", {
233 {"OrExp", "BinaryExp", "Expression `|'", {
238 {"XorExp", "BinaryExp", "Expression `^'", {
243 {"AndAndExp", "BinaryExp", "Expression `&&'", {
248 {"OrOrExp", "BinaryExp", "Expression `||'", {
253 {"ShlExp", "BinaryExp", "Expression `>>'", {
258 {"AShrExp", "BinaryExp", "Expression `<<'", {
263 {"LShrExp", "BinaryExp", "Expression `<<<'", {
268 {"NumberExp", "Exp", "A number", {
273 {"IdExp", "Exp", "An identifier", {
274 {"Symbol *", "symbol"}
278 {"CallExp", "Exp", "A call to a function", {
279 {"std::string", "id"},
280 {"std::vector<Exp *> *", "args"},
281 {"FunctionType *", "ftype"}
286 {"Block", "Node", "Represent a block with a new scope", {
287 {"Scope *", "scope"},
288 {"std::vector<VarDecl *> *", "varDecls"},
289 {"std::vector<Node *> *", "statements"},
294 {"EmptyStatement", "Node", "An empty statement", {
299 {"Label", "Node", "A label", {
300 {"std::string", "name"}
304 {"Goto", "Node", "goto statement", {
305 {"std::string", "label"}
309 {"Return", "Node", "return statement", {
314 {"ConditionalBranch", "Node", "Factorisation code for loops", {
316 {"Label *", "trueLabel"},
317 {"Label *", "falseLabel"},
321 {"If", "Node", "If statement", {
322 {"ConditionalBranch *", "branch"},
323 {"Node *", "trueBlock"},
324 {"Node *", "falseBlock"},
325 {"Label *", "endLabel"}
329 {"While", "Node", "While statement", {
330 {"ConditionalBranch *", "branch"},
332 {"Label *", "beginLabel"}
336 {"DoWhile", "Node", "Do while statement", {
337 {"ConditionalBranch *", "branch"},
343 {"Function", "Node", "Represent a function declaration", {
344 {"std::string", "name"},
345 {"Type *", "returnType"},
346 {"std::vector<VarDecl *> *", "args"},
347 {"Scope *", "scope"},
348 {"Block *", "block"},
353 /* 3 address decomposition */
354 {"LoadVar", "Node", "A temporary result, used for 3 address", {
356 {"std::string", "to"}
360 {"StoreVar", "Node", "A temporary result, used for 3 address", {
361 {"std::string", "name"},
362 {"Exp *", "value"}, // must be IdExp or NumberExp
366 {"", "", "", {{"", ""}}}