34 lines
841 B
C
34 lines
841 B
C
#ifndef __PARSER_H__
|
|
#define __PARSER_H__
|
|
|
|
#include "../frontend.h"
|
|
#include "../lexer/lexer.h"
|
|
// #include "symbol_table/symtab.h"
|
|
// #include "ast/ast.h"
|
|
|
|
#define PARSER_MAX_TOKEN_QUEUE 16
|
|
|
|
struct Parser {
|
|
struct ASTNode* root;
|
|
struct ASTNode* cur_node;
|
|
|
|
struct Lexer* lexer;
|
|
struct SymbolTable* symtab;
|
|
int cur_idx;
|
|
int peek_idx;
|
|
int end_idx;
|
|
int size;
|
|
struct Token TokenBuffer[PARSER_MAX_TOKEN_QUEUE];
|
|
int err_level;
|
|
};
|
|
|
|
void init_parser(struct Parser* parser, struct Lexer* lexer, struct SymbolTable* symtab);
|
|
void run_parser(struct Parser* parser);
|
|
void flushpeektok(struct Parser* parser);
|
|
int poptok(struct Parser* parser);
|
|
struct Token* peektok(struct Parser* parser);
|
|
enum TokenType peektoktype(struct Parser* parser);
|
|
void expecttok(struct Parser* parser, enum TokenType type);
|
|
|
|
#endif
|