1
0

Modify index syntax; Clean up

This commit is contained in:
Jeff 2023-11-13 15:41:55 -05:00
parent e9e4e92f68
commit c86f61e1cd
2 changed files with 8 additions and 4 deletions

View File

@ -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;

View File

@ -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,