wip make sure that heredoc identifier sits on a line of its own

This commit is contained in:
mhoffm
2021-06-26 10:31:33 +02:00
parent 77b51d1b78
commit bc0b3f1eb0
2 changed files with 14 additions and 8 deletions

View File

@@ -20,15 +20,10 @@ To run tests simply run `nix-shell --run 'tree-sitter test'`.
The directory `example/real_world_stuff` contains a corpus of hcl files that I found with the github query `language:HCL` for users `coreos`, `hashicorp`, `oracle` and `terraform-community-modules`.
Given that some language features are still missing ( see TODO ) there are some expected parse errors:
```bash
tree-sitter parse --quiet --stat example/real_world_stuff/*/*
example/real_world_stuff/oracle/oracle%opengrok%opengrok-indexer%src%test%resources%analysis%terraform%sample.tf 1 ms (ERROR [205, 8] - [214, 1])
Total parses: 2015; successful parses: 2014; failed parses: 1; success percentage: 99.95%
Total parses: 1892; successful parses: 1892; failed parses: 0; success percentage: 100.00%
```
The aim is to build unit testcases from selected failure classes and slowly get to 100%.

View File

@@ -137,8 +137,19 @@ public:
return accept_and_advance(lexer, TEMPLATE_LITERAL_CHUNK);
}
}
context_stack.pop_back();
return accept_and_advance(lexer, HEREDOC_IDENTIFIER);
// check if the identifier is on a line of its own
lexer->mark_end(lexer);
while (iswspace(lexer->lookahead) && lexer->lookahead != '\n') {
advance(lexer);
}
if (lexer->lookahead == '\n') {
context_stack.pop_back();
return accept_and_advance(lexer, HEREDOC_IDENTIFIER);
} else {
advance(lexer);
lexer->mark_end(lexer);
return accept_inplace(lexer, TEMPLATE_LITERAL_CHUNK);
}
}
// manage template literal chunks