new compiler/parser
This commit is contained in:
parent
35bad08a0d
commit
7efa99d064
16 changed files with 419 additions and 302 deletions
31
src/parser.h
31
src/parser.h
|
|
@ -2,11 +2,34 @@
|
|||
#define PARSER_H
|
||||
|
||||
#include "common.h"
|
||||
#include "vendor/mpc.h"
|
||||
#include "lexer.h"
|
||||
#include "vendor/yar.h"
|
||||
|
||||
V parser_init(V);
|
||||
V parser_deinit(V);
|
||||
enum {
|
||||
AST_PROGRAM,
|
||||
AST_INT,
|
||||
AST_STR,
|
||||
AST_WORD,
|
||||
AST_LIST,
|
||||
AST_TABLE,
|
||||
AST_QUOTE,
|
||||
AST_DEF,
|
||||
AST_CMD,
|
||||
AST_PRAGMA,
|
||||
};
|
||||
|
||||
extern mpc_parser_t *Program;
|
||||
typedef struct Ast {
|
||||
I type;
|
||||
char *name;
|
||||
I int_val;
|
||||
struct {
|
||||
struct Ast **items;
|
||||
Z count, capacity;
|
||||
} children;
|
||||
I line, col;
|
||||
} Ast;
|
||||
|
||||
Ast *parser_parse(Lx *lx);
|
||||
void ast_free(Ast *ast);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue