| author | |
| committer | |
| log | 68c4f617edc2afd4f9b201b6b67248d6cb80e69d |
| tree | ef48637e2e49976c5fda6ba23b2c9f4e01e5f127 |
| parent | 1645fa681f5cca05125b5aeba2bc76701c20f6bb |
no more nondeterministic error messages
closes #654 files changed, 12 insertions(+), 6 deletions(-)
src/all_types.hpp+1| ... | ... | @@ -890,6 +890,7 @@ struct CodeGen { |
| 890 | 890 | LLVMValueRef memcpy_fn_val; |
| 891 | 891 | LLVMValueRef memset_fn_val; |
| 892 | 892 | bool error_during_imports; |
| 893 | uint32_t next_node_index; | |
| 893 | 894 | }; |
| 894 | 895 | |
| 895 | 896 | struct VariableTableEntry { |
src/codegen.cpp+2-1| ... | ... | @@ -2658,7 +2658,8 @@ static ImportTableEntry *codegen_add_code(CodeGen *g, Buf *abs_full_path, |
| 2658 | 2658 | import_entry->path = full_path; |
| 2659 | 2659 | import_entry->fn_table.init(32); |
| 2660 | 2660 | |
| 2661 | import_entry->root = ast_parse(source_code, tokenization.tokens, import_entry, g->err_color); | |
| 2661 | import_entry->root = ast_parse(source_code, tokenization.tokens, import_entry, g->err_color, | |
| 2662 | &g->next_node_index); | |
| 2662 | 2663 | assert(import_entry->root); |
| 2663 | 2664 | if (g->verbose) { |
| 2664 | 2665 | ast_print(import_entry->root, 0); |
src/parser.cpp+7-4| ... | ... | @@ -401,7 +401,7 @@ struct ParseContext { |
| 401 | 401 | ZigList<AstNode *> *directive_list; |
| 402 | 402 | ImportTableEntry *owner; |
| 403 | 403 | ErrColor err_color; |
| 404 | uint32_t next_create_index; | |
| 404 | uint32_t *next_node_index; | |
| 405 | 405 | }; |
| 406 | 406 | |
| 407 | 407 | __attribute__ ((format (printf, 4, 5))) |
| ... | ... | @@ -457,8 +457,8 @@ static AstNode *ast_create_node_no_line_info(ParseContext *pc, NodeType type) { |
| 457 | 457 | AstNode *node = allocate<AstNode>(1); |
| 458 | 458 | node->type = type; |
| 459 | 459 | node->owner = pc->owner; |
| 460 | node->create_index = pc->next_create_index; | |
| 461 | pc->next_create_index += 1; | |
| 460 | node->create_index = *pc->next_node_index; | |
| 461 | *pc->next_node_index += 1; | |
| 462 | 462 | return node; |
| 463 | 463 | } |
| 464 | 464 | |
| ... | ... | @@ -2724,12 +2724,15 @@ static AstNode *ast_parse_root(ParseContext *pc, int *token_index) { |
| 2724 | 2724 | return node; |
| 2725 | 2725 | } |
| 2726 | 2726 | |
| 2727 | AstNode *ast_parse(Buf *buf, ZigList<Token> *tokens, ImportTableEntry *owner, ErrColor err_color) { | |
| 2727 | AstNode *ast_parse(Buf *buf, ZigList<Token> *tokens, ImportTableEntry *owner, | |
| 2728 | ErrColor err_color, uint32_t *next_node_index) | |
| 2729 | { | |
| 2728 | 2730 | ParseContext pc = {0}; |
| 2729 | 2731 | pc.err_color = err_color; |
| 2730 | 2732 | pc.owner = owner; |
| 2731 | 2733 | pc.buf = buf; |
| 2732 | 2734 | pc.tokens = tokens; |
| 2735 | pc.next_node_index = next_node_index; | |
| 2733 | 2736 | int token_index = 0; |
| 2734 | 2737 | pc.root = ast_parse_root(&pc, &token_index); |
| 2735 | 2738 | return pc.root; |
src/parser.hpp+2-1| ... | ... | @@ -17,7 +17,8 @@ void ast_token_error(Token *token, const char *format, ...); |
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | // This function is provided by generated code, generated by parsergen.cpp |
| 20 | AstNode * ast_parse(Buf *buf, ZigList<Token> *tokens, ImportTableEntry *owner, ErrColor err_color); | |
| 20 | AstNode * ast_parse(Buf *buf, ZigList<Token> *tokens, ImportTableEntry *owner, ErrColor err_color, | |
| 21 | uint32_t *next_node_index); | |
| 21 | 22 | |
| 22 | 23 | const char *node_type_str(NodeType node_type); |
| 23 | 24 |