Add custom syntax.
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::any::Dynamic;
|
||||
use crate::calc_fn_hash;
|
||||
use crate::engine::{Engine, Imports, KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_PRINT, KEYWORD_TYPE_OF};
|
||||
use crate::module::Module;
|
||||
use crate::parser::{map_dynamic_to_expr, Expr, ReturnType, ScriptFnDef, Stmt, AST};
|
||||
use crate::parser::{map_dynamic_to_expr, CustomExpr, Expr, ReturnType, ScriptFnDef, Stmt, AST};
|
||||
use crate::scope::{Entry as ScopeEntry, EntryType as ScopeEntryType, Scope};
|
||||
use crate::utils::StaticVec;
|
||||
|
||||
@@ -598,6 +598,14 @@ fn optimize_expr(expr: Expr, state: &mut State) -> Expr {
|
||||
state.find_constant(&name).expect("should find constant in scope!").clone().set_position(pos)
|
||||
}
|
||||
|
||||
// Custom syntax
|
||||
Expr::Custom(x) => Expr::Custom(Box::new((
|
||||
CustomExpr(
|
||||
(x.0).0.into_iter().map(|expr| optimize_expr(expr, state)).collect(),
|
||||
(x.0).1),
|
||||
x.1
|
||||
))),
|
||||
|
||||
// All other expressions - skip
|
||||
expr => expr,
|
||||
}
|
||||
|
Reference in New Issue
Block a user