Modify index syntax; Clean up
This commit is contained in:
parent
e9e4e92f68
commit
c86f61e1cd
@ -35,8 +35,6 @@ impl AbstractTree for Index {
|
|||||||
fn run(&self, source: &str, context: &mut Map) -> Result<Value> {
|
fn run(&self, source: &str, context: &mut Map) -> Result<Value> {
|
||||||
let value = self.collection.run(source, context)?;
|
let value = self.collection.run(source, context)?;
|
||||||
|
|
||||||
println!("{self:?}");
|
|
||||||
|
|
||||||
match value {
|
match value {
|
||||||
Value::List(list) => {
|
Value::List(list) => {
|
||||||
let index = self.index.run(source, context)?.as_integer()? as usize;
|
let index = self.index.run(source, context)?.as_integer()? as usize;
|
||||||
|
@ -114,13 +114,19 @@ module.exports = grammar({
|
|||||||
index: $ => prec.left(seq(
|
index: $ => prec.left(seq(
|
||||||
$.expression,
|
$.expression,
|
||||||
':',
|
':',
|
||||||
$.expression,
|
$._index_expression,
|
||||||
optional(seq(
|
optional(seq(
|
||||||
'..',
|
'..',
|
||||||
$.expression,
|
$._index_expression,
|
||||||
)),
|
)),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
|
_index_expression: $ => prec(1,choice(
|
||||||
|
$.integer,
|
||||||
|
$.identifier,
|
||||||
|
$.function_call,
|
||||||
|
)),
|
||||||
|
|
||||||
math: $ => prec.left(seq(
|
math: $ => prec.left(seq(
|
||||||
$.expression,
|
$.expression,
|
||||||
$.math_operator,
|
$.math_operator,
|
||||||
|
Loading…
Reference in New Issue
Block a user