#ifndef PARSER_H #define PARSER_H #include #include #include #include "Token.h" #include "Context.h" #include "AST/AllTypesOfASTNodes.h" #include "AST/AST.h" using namespace std; class Parser { public: Parser(Context * context); Context * context; virtual ~Parser(); void interpret(); string report_message; string error_message; void add_tokens(vector tokens); string show_tokens(); AST tree; ProgramNode * program; void erase_all(); bool is_function_name(); protected: private: Token current_token; string tok_value; vector token_stream; unsigned int position_in_stream; bool in_statement; bool read_next(); bool peek(string s); bool accept(string s); bool expect(string s); bool is_type(); void error(string s); void report(string s); ASTStatement * statement(ASTNode * node); ASTExpression * mul_expr(ASTNode * node); ASTExpression * add_expr(ASTNode * node); ASTExpression * prim_expr(ASTNode * node); ASTExpression * postfix_expr(ASTNode * node); ASTExpression * rel_expr(ASTNode * node); ASTExpression * eq_expr(ASTNode * node); ASTExpression * expr(ASTNode * node); }; #endif // PARSER_H