46 lines
863 B
C++
46 lines
863 B
C++
#ifndef PARSER_H
|
|
#define PARSER_H
|
|
#include <string>
|
|
#include <vector>
|
|
#include "Token.h"
|
|
|
|
|
|
using namespace std;
|
|
class Parser
|
|
{
|
|
public:
|
|
Parser(vector<Token> tokens);
|
|
virtual ~Parser();
|
|
void interpret();
|
|
string report_message;
|
|
string error_message;
|
|
|
|
|
|
protected:
|
|
private:
|
|
Token current_token;
|
|
string tok_value;
|
|
vector<Token> token_stream;
|
|
int position_in_stream;
|
|
|
|
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);
|
|
|
|
void statement();
|
|
|
|
void add_expr();
|
|
void prim_expr();
|
|
void postfix_expr();
|
|
void rel_expr();
|
|
void eq_expr();
|
|
void expr();
|
|
};
|
|
|
|
#endif // PARSER_H
|