diff --git a/src/grammar.json b/src/grammar.json index f176867..77b9fb2 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -1945,7 +1945,7 @@ }, { "type": "STRING", - "value": "&&" + "value": "&" }, { "type": "SYMBOL", @@ -1966,7 +1966,7 @@ }, { "type": "STRING", - "value": "||" + "value": "|" }, { "type": "SYMBOL", @@ -1978,6 +1978,48 @@ { "type": "PREC_LEFT", "value": 11, + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "STRING", + "value": "&&" + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + } + }, + { + "type": "PREC_LEFT", + "value": 10, + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "expression" + }, + { + "type": "STRING", + "value": "||" + }, + { + "type": "SYMBOL", + "name": "expression" + } + ] + } + }, + { + "type": "PREC_LEFT", + "value": 9, "content": { "type": "SEQ", "members": [ @@ -4286,7 +4328,7 @@ }, "as_pattern": { "type": "PREC", - "value": 9, + "value": 7, "content": { "type": "SEQ", "members": [ @@ -4307,7 +4349,7 @@ }, "or_pattern": { "type": "PREC_RIGHT", - "value": 10, + "value": 8, "content": { "type": "SEQ", "members": [ diff --git a/src/node-types.json b/src/node-types.json index 306939e..d6c5047 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -2581,6 +2581,10 @@ "type": "%", "named": false }, + { + "type": "&", + "named": false + }, { "type": "&&", "named": false diff --git a/src/parser.c b/src/parser.c index 7bae45c..159de8b 100644 Binary files a/src/parser.c and b/src/parser.c differ diff --git a/test/corpus/expression.txt b/test/corpus/expression.txt index b8d99b1..0fa73b7 100644 --- a/test/corpus/expression.txt +++ b/test/corpus/expression.txt @@ -1001,3 +1001,60 @@ fn init { (atomic_expression (literal (integer_literal)))))))))))))))))) + +================================================================================ +apply expression with labeled argument +================================================================================ +fn main { + let a = 1 | 2 && 3 & 4 || 5 +} +-------------------------------------------------------------------------------- + +(structure + (structure_item + (function_definition + (function_identifier + (lowercase_identifier)) + (block_expression + (statement_expression + (let_expression + (pattern + (simple_pattern + (lowercase_identifier))) + (expression + (simple_expression + (binary_expression + (expression + (simple_expression + (binary_expression + (expression + (simple_expression + (binary_expression + (expression + (simple_expression + (atomic_expression + (literal + (integer_literal))))) + (expression + (simple_expression + (atomic_expression + (literal + (integer_literal)))))))) + (expression + (simple_expression + (binary_expression + (expression + (simple_expression + (atomic_expression + (literal + (integer_literal))))) + (expression + (simple_expression + (atomic_expression + (literal + (integer_literal))))))))))) + (expression + (simple_expression + (atomic_expression + (literal + (integer_literal))))))))))))))