fix: precedence of unary operators and expressions

Signed-off-by: Michael Hoffmann <mhoffm@posteo.de>
This commit is contained in:
Michael Hoffmann
2025-03-30 13:33:58 +02:00
parent 009def4ae3
commit 28e327cd3f
15 changed files with 7189 additions and 6812 deletions

View File

@@ -124,7 +124,8 @@
"members": [
{
"type": "PATTERN",
"value": "\\p{ID_Start}"
"value": "\\p{ID_Start}",
"flags": "u"
},
{
"type": "STRING",
@@ -139,7 +140,8 @@
"members": [
{
"type": "PATTERN",
"value": "\\p{ID_Continue}"
"value": "\\p{ID_Continue}",
"flags": "u"
},
{
"type": "STRING",
@@ -204,43 +206,55 @@
"name": "operation"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expr_term"
},
{
"type": "SYMBOL",
"name": "index"
}
]
"type": "PREC_RIGHT",
"value": 8,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expr_term"
},
{
"type": "SYMBOL",
"name": "index"
}
]
}
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expr_term"
},
{
"type": "SYMBOL",
"name": "get_attr"
}
]
"type": "PREC_RIGHT",
"value": 8,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expr_term"
},
{
"type": "SYMBOL",
"name": "get_attr"
}
]
}
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expr_term"
},
{
"type": "SYMBOL",
"name": "splat"
}
]
"type": "PREC_RIGHT",
"value": 8,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expr_term"
},
{
"type": "SYMBOL",
"name": "splat"
}
]
}
},
{
"type": "SEQ",
@@ -1784,4 +1798,4 @@
"inline": [],
"supertypes": [],
"reserved": {}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -129,7 +129,7 @@ static unsigned serialize(Scanner *scanner, char *buf) {
memcpy(&buf[size], &(scanner->context_stack.len), sizeof(uint32_t));
size += sizeof(uint32_t);
for (int i = 0; i < scanner->context_stack.len; i++) {
for (uint32_t i = 0; i < scanner->context_stack.len; i++) {
Context *context = &scanner->context_stack.data[i];
if (size + sizeof(ContextType) + sizeof(uint32_t) + context->heredoc_identifier.len >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) {
return 0;
@@ -413,7 +413,7 @@ bool tree_sitter_terraform_external_scanner_scan(void *payload, TSLexer *lexer,
void tree_sitter_terraform_external_scanner_destroy(void *payload) {
Scanner *scanner = (Scanner *)payload;
for (int i = 0; i < scanner->context_stack.len; i++) {
for (uint32_t i = 0; i < scanner->context_stack.len; i++) {
STRING_FREE(scanner->context_stack.data[i].heredoc_identifier);
}
VEC_FREE(scanner->context_stack);