aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-14 15:27:42 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-14 15:27:42 -0700
commit68c4f617edc2afd4f9b201b6b67248d6cb80e69d (patch)
treeef48637e2e49976c5fda6ba23b2c9f4e01e5f127 /src/parser.cpp
parent1645fa681f5cca05125b5aeba2bc76701c20f6bb (diff)
downloadzig-68c4f617edc2afd4f9b201b6b67248d6cb80e69d.tar.gz
zig-68c4f617edc2afd4f9b201b6b67248d6cb80e69d.zip
fix next_node_index on wrong struct
no more nondeterministic error messages closes #65
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 1215e82855..2886c5e8f7 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -401,7 +401,7 @@ struct ParseContext {
ZigList<AstNode *> *directive_list;
ImportTableEntry *owner;
ErrColor err_color;
- uint32_t next_create_index;
+ uint32_t *next_node_index;
};
__attribute__ ((format (printf, 4, 5)))
@@ -457,8 +457,8 @@ static AstNode *ast_create_node_no_line_info(ParseContext *pc, NodeType type) {
AstNode *node = allocate<AstNode>(1);
node->type = type;
node->owner = pc->owner;
- node->create_index = pc->next_create_index;
- pc->next_create_index += 1;
+ node->create_index = *pc->next_node_index;
+ *pc->next_node_index += 1;
return node;
}
@@ -2724,12 +2724,15 @@ static AstNode *ast_parse_root(ParseContext *pc, int *token_index) {
return node;
}
-AstNode *ast_parse(Buf *buf, ZigList<Token> *tokens, ImportTableEntry *owner, ErrColor err_color) {
+AstNode *ast_parse(Buf *buf, ZigList<Token> *tokens, ImportTableEntry *owner,
+ ErrColor err_color, uint32_t *next_node_index)
+{
ParseContext pc = {0};
pc.err_color = err_color;
pc.owner = owner;
pc.buf = buf;
pc.tokens = tokens;
+ pc.next_node_index = next_node_index;
int token_index = 0;
pc.root = ast_parse_root(&pc, &token_index);
return pc.root;