feat add func call and rewrite codes
This commit is contained in:
@@ -2,32 +2,24 @@
|
||||
#define __PARSER_H__
|
||||
|
||||
#include "../frontend.h"
|
||||
#include "../lexer/lexer.h"
|
||||
// #include "symbol_table/symtab.h"
|
||||
// #include "ast/ast.h"
|
||||
|
||||
#include "../lexer/lexer.h"
|
||||
typedef struct lexer lexer_t;
|
||||
typedef struct symtab symtab_t;
|
||||
#define PARSER_MAX_TOKEN_QUEUE 16
|
||||
|
||||
struct Parser {
|
||||
typedef 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];
|
||||
lexer_t* lexer;
|
||||
symtab_t* symtab;
|
||||
tok_buf_t tokbuf;
|
||||
tok_t TokenBuffer[PARSER_MAX_TOKEN_QUEUE];
|
||||
int err_level;
|
||||
};
|
||||
} parser_t;
|
||||
|
||||
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);
|
||||
void init_parser(parser_t* parser, lexer_t* lexer, symtab_t* symtab);
|
||||
void run_parser(parser_t* parser);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user