fix binary operators

This commit is contained in:
mhoffm
2021-06-19 18:10:47 +02:00
parent 6cc5e7b721
commit d61fefced0
7 changed files with 8772 additions and 8265 deletions

View File

@@ -71,7 +71,6 @@ module.exports = grammar({
expression: $ => choice(
$._expr_term,
$.operation,
$.conditional,
),
@@ -82,6 +81,7 @@ module.exports = grammar({
$.variable_expr,
$.function_call,
$.for_expr,
$.operation,
seq($._expr_term, $.index),
seq($._expr_term, $.get_attr),
seq($._expr_term, $.splat),
@@ -224,8 +224,8 @@ module.exports = grammar({
$._function_call_end,
),
_function_call_start: $ => token('('),
_function_call_end: $ => token(')'),
_function_call_start: $ => '(',
_function_call_end: $ => ')',
function_arguments: $ => prec.right(seq(
optional($._newline),

View File

@@ -174,10 +174,6 @@
"type": "SYMBOL",
"name": "_expr_term"
},
{
"type": "SYMBOL",
"name": "operation"
},
{
"type": "SYMBOL",
"name": "conditional"
@@ -211,6 +207,10 @@
"type": "SYMBOL",
"name": "for_expr"
},
{
"type": "SYMBOL",
"name": "operation"
},
{
"type": "SEQ",
"members": [
@@ -947,18 +947,12 @@
]
},
"_function_call_start": {
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "("
}
"type": "STRING",
"value": "("
},
"_function_call_end": {
"type": "TOKEN",
"content": {
"type": "STRING",
"value": ")"
}
"type": "STRING",
"value": ")"
},
"function_arguments": {
"type": "PREC_RIGHT",

View File

@@ -69,6 +69,10 @@
"type": "literal_value",
"named": true
},
{
"type": "operation",
"named": true
},
{
"type": "splat",
"named": true
@@ -681,6 +685,10 @@
"type": "literal_value",
"named": true
},
{
"type": "operation",
"named": true
},
{
"type": "splat",
"named": true

16952
src/parser.c

File diff suppressed because it is too large Load Diff

View File

@@ -218,9 +218,7 @@ bool scanner_scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
}
// handle all other quoted template or string literal characters
if (
valid_symbols[TEMPLATE_LITERAL_CHUNK]
) {
if (valid_symbols[TEMPLATE_LITERAL_CHUNK] && scanner->in_quoted_context) {
return accept_and_advance(lexer, TEMPLATE_LITERAL_CHUNK);
}

View File

@@ -53,3 +53,31 @@ foo = 1+2
(numeric_lit))
(literal_value
(numeric_lit))))))))
================================================================================
precedence in binary operators
================================================================================
foo = a != b && c == d
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(operation
(binary_operation
(operation
(binary_operation
(variable_expr
(identifier))
(variable_expr
(identifier))))
(operation
(binary_operation
(variable_expr
(identifier))
(variable_expr
(identifier))))))))))

View File

@@ -343,13 +343,20 @@ resource "azurerm_storage_blob" "proxy_cert" {
(expression
(operation
(binary_operation
(variable_expr
(identifier))
(operation
(binary_operation
(operation
(binary_operation
(variable_expr
(identifier))
(get_attr
(identifier))
(template_expr
(quoted_template))))
(variable_expr
(identifier))))
(get_attr
(identifier))
(ERROR
(template_expr
(quoted_template)))
(template_expr
(quoted_template)))))
(expression