diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2014-12-23 10:53:38 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2014-12-23 10:53:38 -0800 |
commit | bf80b0db1976cdeffc8481d335b1940fb8d522fc (patch) | |
tree | e0410f33a4fcaf00ddb27c5a41334bee385091e1 /parse_tree.cpp | |
parent | ebfaa8cc9582f8f56813f0a5f9ed829a419c9eec (diff) |
Fix to avoid generating multiple error nodes on parse error
Diffstat (limited to 'parse_tree.cpp')
-rw-r--r-- | parse_tree.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/parse_tree.cpp b/parse_tree.cpp index 61f703ab..39cee258 100644 --- a/parse_tree.cpp +++ b/parse_tree.cpp @@ -1341,7 +1341,12 @@ bool parse_tree_from_string(const wcstring &str, parse_tree_flags_t parse_flags, if (parse_flags & parse_flag_continue_after_error) { /* Hack hack hack. Typically the parse error is due to the first token. However, if it's a tokenizer error, then has_fatal_error was set due to the check above; in that case the second token is what matters. */ - size_t error_token_idx = (queue[1].type == parse_special_type_tokenizer_error ? 1 : 0); + size_t error_token_idx = 0; + if (queue[1].type == parse_special_type_tokenizer_error) + { + error_token_idx = (queue[1].type == parse_special_type_tokenizer_error ? 1 : 0); + token_count = -1; // so that it will be 0 after incrementing, and our tokenizer error will be ignored + } /* Mark a special error token, and then keep going */ const parse_token_t token = {parse_special_type_parse_error, parse_keyword_none, false, false, queue[error_token_idx].source_start, queue[error_token_idx].source_length}; |