Improve index syntax
This commit is contained in:
parent
c86f61e1cd
commit
567c20a5bc
@ -90,3 +90,25 @@ Nested Indexes
|
|||||||
(expression
|
(expression
|
||||||
(value
|
(value
|
||||||
(integer)))))))
|
(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(
|
index: $ => prec.left(seq(
|
||||||
$.expression,
|
$.expression,
|
||||||
':',
|
':',
|
||||||
$._index_expression,
|
$.expression,
|
||||||
optional(seq(
|
optional(seq(
|
||||||
'..',
|
'..',
|
||||||
$._index_expression,
|
$.expression,
|
||||||
)),
|
)),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
_index_expression: $ => prec(1,choice(
|
|
||||||
$.integer,
|
|
||||||
$.identifier,
|
|
||||||
$.function_call,
|
|
||||||
)),
|
|
||||||
|
|
||||||
math: $ => prec.left(seq(
|
math: $ => prec.left(seq(
|
||||||
$.expression,
|
$.expression,
|
||||||
$.math_operator,
|
$.math_operator,
|
||||||
@ -298,10 +292,12 @@ module.exports = grammar({
|
|||||||
field('body', $.block),
|
field('body', $.block),
|
||||||
),
|
),
|
||||||
|
|
||||||
function_call: $ => choice(
|
function_call: $ => prec.right(choice(
|
||||||
|
'(',
|
||||||
$.built_in_function,
|
$.built_in_function,
|
||||||
$._context_defined_function,
|
$._context_defined_function,
|
||||||
),
|
')',
|
||||||
|
)),
|
||||||
|
|
||||||
_context_defined_function: $ => prec.right(seq(
|
_context_defined_function: $ => prec.right(seq(
|
||||||
$.identifier,
|
$.identifier,
|
||||||
|
@ -1233,17 +1233,29 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"function_call": {
|
"function_call": {
|
||||||
"type": "CHOICE",
|
"type": "PREC_RIGHT",
|
||||||
"members": [
|
"value": 0,
|
||||||
{
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "CHOICE",
|
||||||
"name": "built_in_function"
|
"members": [
|
||||||
},
|
{
|
||||||
{
|
"type": "STRING",
|
||||||
"type": "SYMBOL",
|
"value": "("
|
||||||
"name": "_context_defined_function"
|
},
|
||||||
}
|
{
|
||||||
]
|
"type": "SYMBOL",
|
||||||
|
"name": "built_in_function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_context_defined_function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ")"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"_context_defined_function": {
|
"_context_defined_function": {
|
||||||
"type": "PREC_RIGHT",
|
"type": "PREC_RIGHT",
|
||||||
|
@ -255,7 +255,7 @@
|
|||||||
"fields": {},
|
"fields": {},
|
||||||
"children": {
|
"children": {
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"required": true,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "built_in_function",
|
"type": "built_in_function",
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user