1
0

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
--------------------------------------------------------------------------------
@ -34,14 +33,4 @@ assert_equal random_integer 4
(built_in_function)))
(expression
(value
(integer)))))))
(statement
(expression
(function_call
(built_in_function
(expression
(function_call
(built_in_function
(expression
(value
(integer)))))))))))
(integer))))))))

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff