Closed feroldi closed 7 years ago
-dump-ast makes the compiler dump the generated AST from translation units to stderr.
-dump-ast
The AST would be broken down to entity and display:
int var;
var
Syntax could be similar to libclang's:
int main() { int i = 42; return i; }
Would generate:
- FunctionDefinition(int(), main) - Operator(=) - VarDeclaration(int, i) - Constant(42) - Return(i)
This is just an illustration, and it can/will change.
edit-1:
Stick to the current general AST. Example:
$ cat src.c int main(int argc, char** argv) { return 0; } $ ccompiler -dump-ast src.c compilation unit: function definition: declaration specifiers: type specifier(int) direct declarator: identifier(main) parameter list: parameter declaration: declaration specifiers: type specifier(int) identifier(argc) parameter declaration: declaration specifiers: type specifier(char) declarator: pointer declarator(*): pointer declarator(*) identifier(argv) compound statement({): jump statement(return): integer constant(0)
There will be another compiler option to emit the intermediate language (IR).
Maybe use ipr for the syntax?
Make it dump the AST produced from semantics analyses instead of the generic one.
-dump-ast
makes the compiler dump the generated AST from translation units to stderr.The AST would be broken down to entity and display:Entity is the expression name (e.g. IfCondition, Operator etc).Display is a user-define name (e.g. inint var;
, VariableDeclaration is the entity name, andvar
is the display name).Syntax could be similar to libclang's:Would generate:This is just an illustration, and it can/will change.edit-1:
Stick to the current general AST. Example:
There will be another compiler option to emit the intermediate language (IR).