sencha-lang/Sencha-lang/Parser.h

60 lines
1.4 KiB
C
Raw Normal View History

#ifndef PARSER_H
#define PARSER_H
#include <string>
2012-12-06 17:41:16 +00:00
#include <vector>
#include <cstdlib>
#include "Token.h"
2012-12-08 19:59:05 +00:00
#include "Context.h"
2012-12-06 17:41:16 +00:00
#include "AST/AllTypesOfASTNodes.h"
#include "AST/AST.h"
using namespace std;
2012-12-03 22:40:47 +00:00
class Parser
{
public:
2012-12-08 19:59:05 +00:00
Parser(Context * context);
Context * context;
virtual ~Parser();
void interpret();
string report_message;
string error_message;
2012-11-08 20:16:00 +00:00
void add_tokens(vector<Token> tokens);
string show_tokens();
AST tree;
ProgramNode * program;
void erase_all();
bool is_function_name();
2012-12-03 22:40:47 +00:00
protected:
2012-12-03 22:40:47 +00:00
private:
Token current_token;
string tok_value;
vector<Token> token_stream;
2012-12-08 19:59:05 +00:00
unsigned int position_in_stream;
2012-11-08 20:16:00 +00:00
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);
2012-12-08 19:59:05 +00:00
ASTStatement * statement(ASTNode * node);
2012-11-04 16:16:02 +00:00
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