Improve index syntax
This commit is contained in:
parent
c86f61e1cd
commit
567c20a5bc
@ -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)))))))
|
||||
|
@ -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,
|
||||
|
@ -1233,8 +1233,15 @@
|
||||
]
|
||||
},
|
||||
"function_call": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "built_in_function"
|
||||
@ -1242,8 +1249,13 @@
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_context_defined_function"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"_context_defined_function": {
|
||||
"type": "PREC_RIGHT",
|
||||
|
@ -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
Loading…
Reference in New Issue
Block a user