Fix bugs in handling multiple simultaneous ambiguities
This commit is contained in:
parent
0955f660d0
commit
500533476b
5 changed files with 3377 additions and 2852 deletions
22
spec/fixtures/corpus/cpp/statements.txt
vendored
22
spec/fixtures/corpus/cpp/statements.txt
vendored
|
|
@ -31,7 +31,7 @@ int main() {
|
|||
(expression_statement (call_expression (identifier) (string) (string)))))))
|
||||
|
||||
==================================================
|
||||
template / relational expression ambiguities
|
||||
template function / relational expression ambiguities
|
||||
==================================================
|
||||
|
||||
int main() {
|
||||
|
|
@ -53,3 +53,23 @@ int main() {
|
|||
(call_expression
|
||||
(template_call (identifier) (type_id (type_specifier (identifier))))
|
||||
(identifier)))))))
|
||||
|
||||
==================================================
|
||||
template class / relational expression ambiguities
|
||||
==================================================
|
||||
|
||||
int main() {
|
||||
SomeTemplate<SomeType> someVariable = 1;
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(translation_unit (function_definition
|
||||
(type_specifier (identifier))
|
||||
(declarator (direct_declarator (direct_declarator (identifier))))
|
||||
(function_body (compound_statement
|
||||
(simple_declaration
|
||||
(type_specifier (template_call (identifier) (identifier)))
|
||||
(init_declarator
|
||||
(declarator (direct_declarator (identifier)))
|
||||
(initializer (initializer_clause (number)))))))))
|
||||
|
|
|
|||
5
spec/fixtures/grammars/cpp.cc
vendored
5
spec/fixtures/grammars/cpp.cc
vendored
|
|
@ -138,6 +138,7 @@ extern const Grammar cpp = Grammar({
|
|||
|
||||
{ "type_specifier", choice({
|
||||
sym("scoped_identifier"),
|
||||
sym("template_call"),
|
||||
sym("identifier") }) },
|
||||
|
||||
{ "compound_statement", seq({
|
||||
|
|
@ -214,9 +215,9 @@ extern const Grammar cpp = Grammar({
|
|||
sym("comment"),
|
||||
pattern("[ \t\r\n]"),
|
||||
}).expected_conflicts({
|
||||
{ "template_call", "_expression" },
|
||||
{ "type_specifier", "_expression" },
|
||||
{ "template_argument", "relational_expression" },
|
||||
{ "template_call", "_expression" },
|
||||
{ "template_call", "relational_expression" },
|
||||
});
|
||||
|
||||
} // namespace tree_sitter_examples
|
||||
|
|
|
|||
6194
spec/fixtures/parsers/cpp.c
vendored
6194
spec/fixtures/parsers/cpp.c
vendored
File diff suppressed because it is too large
Load diff
|
|
@ -22,7 +22,7 @@ static const char *empty_chunk = "";
|
|||
|
||||
static void ts_lexer__get_chunk(TSLexer *self) {
|
||||
TSInput input = self->input;
|
||||
if (self->current_position.bytes != self->chunk_start + self->chunk_size)
|
||||
if (!self->chunk || self->current_position.bytes != self->chunk_start + self->chunk_size)
|
||||
input.seek_fn(input.payload, self->current_position);
|
||||
|
||||
self->chunk_start = self->current_position.bytes;
|
||||
|
|
@ -113,6 +113,7 @@ void ts_lexer_reset(TSLexer *self, TSLength position) {
|
|||
self->token_end_position = position;
|
||||
self->current_position = position;
|
||||
self->chunk = 0;
|
||||
self->chunk_start = 0;
|
||||
self->chunk_size = 0;
|
||||
self->lookahead_size = 0;
|
||||
self->lookahead = 0;
|
||||
|
|
|
|||
|
|
@ -168,9 +168,8 @@ static int ts_stack__find_or_add_head(Stack *self, StackNode *node) {
|
|||
|
||||
void ts_stack_remove_head(Stack *self, int head_index) {
|
||||
stack_node_release(self->heads[head_index]);
|
||||
for (int i = head_index; i < self->head_count - 1; i++) {
|
||||
self->heads[head_index] = self->heads[head_index + 1];
|
||||
}
|
||||
for (int i = head_index; i < self->head_count - 1; i++)
|
||||
self->heads[i] = self->heads[i + 1];
|
||||
self->head_count--;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue