diff --git a/src/evaluator.rs b/src/evaluator.rs index a80687d..5249c6c 100644 --- a/src/evaluator.rs +++ b/src/evaluator.rs @@ -59,10 +59,10 @@ pub fn evaluate_with_context(source: &str, context: &mut Map) -> Result { /// /// The Evaluator turns a tree sitter concrete syntax tree into a vector of /// abstract trees called [Item][]s that can be run to execute the source code. -pub struct Evaluator<'context, 'code> { +pub struct Evaluator<'c, 's> { _parser: Parser, - context: &'context mut Map, - source: &'code str, + context: &'c mut Map, + source: &'s str, syntax_tree: TSTree, } @@ -72,8 +72,8 @@ impl Debug for Evaluator<'_, '_> { } } -impl<'context, 'code> Evaluator<'context, 'code> { - pub fn new(mut parser: Parser, context: &'context mut Map, source: &'code str) -> Self { +impl<'c, 's> Evaluator<'c, 's> { + pub fn new(mut parser: Parser, context: &'c mut Map, source: &'s str) -> Self { let syntax_tree = parser.parse(source, None).unwrap(); Evaluator { diff --git a/tree-sitter-dust/grammar.js b/tree-sitter-dust/grammar.js index 46967eb..6fb499c 100644 --- a/tree-sitter-dust/grammar.js +++ b/tree-sitter-dust/grammar.js @@ -41,17 +41,6 @@ module.exports = grammar({ ), optional(';'), )), - - yield: $ => prec.left(seq( - $.expression, - '->', - '(', - choice( - $.built_in_function, - $._context_defined_function, - ), - ')', - )), expression: $ => prec.right(choice( $._expression_kind, @@ -330,6 +319,17 @@ module.exports = grammar({ optional($._expression_list), )), + yield: $ => prec.left(seq( + $.expression, + '->', + '(', + choice( + $.built_in_function, + $._context_defined_function, + ), + ')', + )), + _built_in_function_name: $ => choice( // General 'assert',