diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-13 14:42:11 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-13 14:42:11 +0000 |
commit | 494894c2072494f199214acc5855155baae6d174 (patch) | |
tree | b9d38c7e078f2d25177d4758faf246314df00183 /c_parser/src | |
parent | da008507b6e0409b7a06984194a5eb9b149caac9 (diff) | |
download | Compiler-494894c2072494f199214acc5855155baae6d174.tar.gz Compiler-494894c2072494f199214acc5855155baae6d174.zip |
Working kind of
Diffstat (limited to 'c_parser/src')
-rw-r--r-- | c_parser/src/#parser_main.cpp# | 13 | ||||
-rw-r--r-- | c_parser/src/c_parser.y | 10 | ||||
-rw-r--r-- | c_parser/src/parser_main.cpp | 2 |
3 files changed, 6 insertions, 19 deletions
diff --git a/c_parser/src/#parser_main.cpp# b/c_parser/src/#parser_main.cpp# deleted file mode 100644 index 3dff644..0000000 --- a/c_parser/src/#parser_main.cpp# +++ /dev/null @@ -1,13 +0,0 @@ -#include "ast.hpp" - -#include <iostream> - -int main(int argc, char *argv[]) { - - const Expression *ast = parseAST(); - ast->print(); - - std::cout << std::endl; - - return 0; -} diff --git a/c_parser/src/c_parser.y b/c_parser/src/c_parser.y index 7d36fc6..351cbf2 100644 --- a/c_parser/src/c_parser.y +++ b/c_parser/src/c_parser.y @@ -1,7 +1,7 @@ %code requires{ #include "ast.hpp" -extern const Expression *g_root; // A way of getting the AST out +extern const ast_Base *g_root; // A way of getting the AST out //! This is to fix problems when generating C++ // We are declaring the functions provided by Flex, so @@ -14,7 +14,7 @@ void yyerror(const char *); // Represents the value associated with any kind of // AST node. %union{ - const Expression *expr; + const ast_Base *expr; // double number; std::string *string; } @@ -36,13 +36,13 @@ STMNT_LIST : STMNT { $$ = $1; } STMNT : DCLRTN { $$ = $1; } -DCLRTN : T_KEYWORD T_IDENTIFIER T_SC { $$ = new Declaration(*$2); } +DCLRTN : T_KEYWORD T_IDENTIFIER T_SC { $$ = new ast_Declaration(*$2); } %% -const Expression *g_root; // Definition of variable (to match declaration earlier) +const ast_Base *g_root; // Definition of variable (to match declaration earlier) -const Expression *parseAST() { +const ast_Base *parseAST() { g_root = 0; yyparse(); return g_root; diff --git a/c_parser/src/parser_main.cpp b/c_parser/src/parser_main.cpp index 3dff644..4dd25eb 100644 --- a/c_parser/src/parser_main.cpp +++ b/c_parser/src/parser_main.cpp @@ -4,7 +4,7 @@ int main(int argc, char *argv[]) { - const Expression *ast = parseAST(); + const ast_Base *ast = parseAST(); ast->print(); std::cout << std::endl; |