1
0
This commit is contained in:
Jeff 2023-11-15 21:52:49 -05:00
parent a21aa5e37b
commit 7445ebec34
2 changed files with 16 additions and 16 deletions

View File

@ -59,10 +59,10 @@ pub fn evaluate_with_context(source: &str, context: &mut Map) -> Result<Value> {
/// ///
/// The Evaluator turns a tree sitter concrete syntax tree into a vector of /// 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. /// 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, _parser: Parser,
context: &'context mut Map, context: &'c mut Map,
source: &'code str, source: &'s str,
syntax_tree: TSTree, syntax_tree: TSTree,
} }
@ -72,8 +72,8 @@ impl Debug for Evaluator<'_, '_> {
} }
} }
impl<'context, 'code> Evaluator<'context, 'code> { impl<'c, 's> Evaluator<'c, 's> {
pub fn new(mut parser: Parser, context: &'context mut Map, source: &'code str) -> Self { pub fn new(mut parser: Parser, context: &'c mut Map, source: &'s str) -> Self {
let syntax_tree = parser.parse(source, None).unwrap(); let syntax_tree = parser.parse(source, None).unwrap();
Evaluator { Evaluator {

View File

@ -42,17 +42,6 @@ module.exports = grammar({
optional(';'), optional(';'),
)), )),
yield: $ => prec.left(seq(
$.expression,
'->',
'(',
choice(
$.built_in_function,
$._context_defined_function,
),
')',
)),
expression: $ => prec.right(choice( expression: $ => prec.right(choice(
$._expression_kind, $._expression_kind,
seq('(', $._expression_kind, ')'), seq('(', $._expression_kind, ')'),
@ -330,6 +319,17 @@ module.exports = grammar({
optional($._expression_list), optional($._expression_list),
)), )),
yield: $ => prec.left(seq(
$.expression,
'->',
'(',
choice(
$.built_in_function,
$._context_defined_function,
),
')',
)),
_built_in_function_name: $ => choice( _built_in_function_name: $ => choice(
// General // General
'assert', 'assert',