From c86f61e1cdb0f99925915192c768657b1d9546df Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 13 Nov 2023 15:41:55 -0500 Subject: [PATCH] Modify index syntax; Clean up --- src/abstract_tree/index.rs | 2 -- tree-sitter-dust/grammar.js | 10 ++++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/abstract_tree/index.rs b/src/abstract_tree/index.rs index 772bfcc..59b6ab3 100644 --- a/src/abstract_tree/index.rs +++ b/src/abstract_tree/index.rs @@ -35,8 +35,6 @@ impl AbstractTree for Index { fn run(&self, source: &str, context: &mut Map) -> Result { let value = self.collection.run(source, context)?; - println!("{self:?}"); - match value { Value::List(list) => { let index = self.index.run(source, context)?.as_integer()? as usize; diff --git a/tree-sitter-dust/grammar.js b/tree-sitter-dust/grammar.js index 0b08d0a..bd38561 100644 --- a/tree-sitter-dust/grammar.js +++ b/tree-sitter-dust/grammar.js @@ -114,13 +114,19 @@ module.exports = grammar({ index: $ => prec.left(seq( $.expression, ':', - $.expression, + $._index_expression, optional(seq( '..', - $.expression, + $._index_expression, )), )), + _index_expression: $ => prec(1,choice( + $.integer, + $.identifier, + $.function_call, + )), + math: $ => prec.left(seq( $.expression, $.math_operator,