#ifndef PARSER_H #define PARSER_H #include #include #include "Token.h" #include "AST.h" #include "../AST/AllTypesOfASTNodes.h" using namespace std; class Parser { public: Parser(); virtual ~Parser(); void interpret(); string report_message; string error_message; void add_tokens(vector tokens); string show_tokens(); protected: private: Token current_token; string tok_value; vector token_stream; int position_in_stream; AST tree; ProgramNode * program; 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); //TODO change functions below to use AST nodes 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