Improve function call syntax

This commit is contained in:
Jeff 2023-11-14 19:22:26 -05:00
parent 567c20a5bc
commit ec1f059d16
7 changed files with 12801 additions and 31102 deletions

View File

@ -20,7 +20,6 @@ Nested Function Call
================================================================================ ================================================================================
(assert_equal (random_integer) 4) (assert_equal (random_integer) 4)
assert_equal random_integer 4
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -34,14 +33,4 @@ assert_equal random_integer 4
(built_in_function))) (built_in_function)))
(expression (expression
(value (value
(integer))))))) (integer))))))))
(statement
(expression
(function_call
(built_in_function
(expression
(function_call
(built_in_function
(expression
(value
(integer)))))))))))

View File

@ -3,7 +3,7 @@ Simple For Loop
================================================================================ ================================================================================
for i in [1, 2, 3] { for i in [1, 2, 3] {
output(i) (output i)
} }
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -38,7 +38,7 @@ Nested For Loop
for list in list_of_lists { for list in list_of_lists {
for item in list { for item in list {
output(item) (output item)
} }
} }

View File

@ -108,7 +108,8 @@ x:(y):0
(expression (expression
(identifier)) (identifier))
(expression (expression
(function_call)))) (function_call
(identifier)))))
(expression (expression
(value (value
(integer))))))) (integer)))))))

View File

@ -46,14 +46,14 @@ module.exports = grammar({
seq('(', $._expression_kind, ')'), seq('(', $._expression_kind, ')'),
)), )),
_expression_kind: $ => prec(1, choice( _expression_kind: $ => choice(
$.function_call, $.function_call,
$.identifier, $.identifier,
$.index, $.index,
$.logic, $.logic,
$.math, $.math,
$.value, $.value,
)), ),
_expression_list: $ => repeat1(prec.right(seq( _expression_list: $ => repeat1(prec.right(seq(
$.expression, $.expression,
@ -292,14 +292,16 @@ module.exports = grammar({
field('body', $.block), field('body', $.block),
), ),
function_call: $ => prec.right(choice( function_call: $ => prec.right(seq(
'(', '(',
choice(
$.built_in_function, $.built_in_function,
$._context_defined_function, $._context_defined_function,
),
')', ')',
)), )),
_context_defined_function: $ => prec.right(seq( _context_defined_function: $ => prec.right(1, seq(
$.identifier, $.identifier,
optional($._expression_list), optional($._expression_list),
)), )),

View File

@ -162,9 +162,6 @@
} }
}, },
"_expression_kind": { "_expression_kind": {
"type": "PREC",
"value": 1,
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -192,7 +189,6 @@
"name": "value" "name": "value"
} }
] ]
}
}, },
"_expression_list": { "_expression_list": {
"type": "REPEAT1", "type": "REPEAT1",
@ -1236,12 +1232,15 @@
"type": "PREC_RIGHT", "type": "PREC_RIGHT",
"value": 0, "value": 0,
"content": { "content": {
"type": "CHOICE", "type": "SEQ",
"members": [ "members": [
{ {
"type": "STRING", "type": "STRING",
"value": "(" "value": "("
}, },
{
"type": "CHOICE",
"members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "built_in_function" "name": "built_in_function"
@ -1249,6 +1248,8 @@
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_context_defined_function" "name": "_context_defined_function"
}
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -1259,7 +1260,7 @@
}, },
"_context_defined_function": { "_context_defined_function": {
"type": "PREC_RIGHT", "type": "PREC_RIGHT",
"value": 0, "value": 1,
"content": { "content": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [

View File

@ -255,7 +255,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "built_in_function", "type": "built_in_function",

File diff suppressed because it is too large Load Diff