Improve index syntax

This commit is contained in:
Jeff 2023-11-14 18:56:44 -05:00
parent c86f61e1cd
commit 567c20a5bc
5 changed files with 26442 additions and 26012 deletions

View File

@ -90,3 +90,25 @@ Nested Indexes
(expression
(value
(integer)))))))
================================================================================
Function Call Index
================================================================================
x:(y):0
--------------------------------------------------------------------------------
(root
(statement
(expression
(index
(expression
(index
(expression
(identifier))
(expression
(function_call))))
(expression
(value
(integer)))))))

View File

@ -114,19 +114,13 @@ module.exports = grammar({
index: $ => prec.left(seq(
$.expression,
':',
$._index_expression,
$.expression,
optional(seq(
'..',
$._index_expression,
$.expression,
)),
)),
_index_expression: $ => prec(1,choice(
$.integer,
$.identifier,
$.function_call,
)),
math: $ => prec.left(seq(
$.expression,
$.math_operator,
@ -298,10 +292,12 @@ module.exports = grammar({
field('body', $.block),
),
function_call: $ => choice(
function_call: $ => prec.right(choice(
'(',
$.built_in_function,
$._context_defined_function,
),
')',
)),
_context_defined_function: $ => prec.right(seq(
$.identifier,

View File

@ -1233,17 +1233,29 @@
]
},
"function_call": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "built_in_function"
},
{
"type": "SYMBOL",
"name": "_context_defined_function"
}
]
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "built_in_function"
},
{
"type": "SYMBOL",
"name": "_context_defined_function"
},
{
"type": "STRING",
"value": ")"
}
]
}
},
"_context_defined_function": {
"type": "PREC_RIGHT",

View File

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

File diff suppressed because it is too large Load Diff