stage1 重构代码 语法上重新实现解包语法
This commit is contained in:
1 parent
2a84b61e3d
commit
54425a50c7
10 files changed
+2681
-2478
No files matched your search
+11
-4
@@ -15,6 +15,7 @@
|
||||
#include "spl_diag.h"
|
||||
#include "spl_ir2vm.h"
|
||||
#include "spl_lexer.h"
|
||||
#include "spl_parser.h"
|
||||
#include "spl_sema.h"
|
||||
#include "spl_tok.h"
|
||||
|
||||
@@ -141,8 +142,11 @@ static spl_ast_t *driver_load(void *user, const char *from_fname, const char *pa
|
||||
spl_tok_vec_t toks = spl_lex(src, key);
|
||||
spl_ast_t *ast = malloc(sizeof *ast);
|
||||
spl_ast_init(ast, &toks);
|
||||
ast->diag = diag;
|
||||
spl_ast_parse(ast);
|
||||
spl_parser_t parser;
|
||||
spl_parser_init(&parser);
|
||||
parser.diag = diag;
|
||||
spl_ast_parse(&parser, ast);
|
||||
spl_parser_drop(&parser);
|
||||
|
||||
vec_at(d->modules, idx).ast = ast;
|
||||
vec_at(d->modules, idx).src = src;
|
||||
@@ -161,7 +165,6 @@ static int compile_spl(const char *src, const char *fname, const char *outpath,
|
||||
drv.main_path = strdup(fname);
|
||||
drv.main_toks = spl_lex(src, drv.main_path);
|
||||
spl_ast_init(&drv.main_ast, &drv.main_toks);
|
||||
drv.main_ast.diag = &diag;
|
||||
map_init(drv.path_to_idx, MAP_HASH_STR, MAP_CMP_STR);
|
||||
vec_init(drv.modules);
|
||||
|
||||
@@ -190,7 +193,11 @@ static int compile_spl(const char *src, const char *fname, const char *outpath,
|
||||
int sema_ok = 0, a2ir_ok = 0, irb_ok = 0, ir2vm_ok = 0;
|
||||
|
||||
spl_diag_set_stage(&diag, SPL_STAGE_PARSE);
|
||||
spl_ast_parse(&drv.main_ast);
|
||||
spl_parser_t parser;
|
||||
spl_parser_init(&parser);
|
||||
parser.diag = &diag;
|
||||
spl_ast_parse(&parser, &drv.main_ast);
|
||||
spl_parser_drop(&parser);
|
||||
if (spl_diag_has_error(&diag) || spl_diag_has_fatal(&diag)) {
|
||||
spl_diag_summary(&diag);
|
||||
rc = 1;
|
||||
|
||||
Reference in new issue
Block a user