diff --git a/Cargo.lock b/Cargo.lock index 1858f1825e..3dcdc81665 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1537,13 +1537,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "fastn-grammar" -version = "0.1.0" -dependencies = [ - "serde", -] - [[package]] name = "fastn-issues" version = "0.1.0" @@ -1557,7 +1550,7 @@ dependencies = [ name = "fastn-js" version = "0.1.0" dependencies = [ - "fastn-grammar", + "fastn-type", "indoc", "itertools 0.13.0", "prettify-js", @@ -1608,7 +1601,6 @@ dependencies = [ name = "fastn-type" version = "0.1.0" dependencies = [ - "fastn-grammar", "serde", ] @@ -1727,7 +1719,6 @@ dependencies = [ "comrak", "css-color-parser", "diffy", - "fastn-grammar", "fastn-js", "fastn-type", "format_num", diff --git a/Cargo.toml b/Cargo.toml index 9f3e0ac367..2f6e8fb431 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ members = [ "fastn-core", "fastn-ds", "fastn-expr", - "fastn-grammar", "fastn-issues", "fastn-js", "fastn-lang", @@ -99,7 +98,6 @@ fastn-utils.path = "fastn-utils" fastn-runtime.path = "fastn-runtime" fastn-wasm.path = "fastn-wasm" fbt-lib.path = "fbt_lib" -fastn-grammar.path = "fastn-grammar" fastn-expr.path = "fastn-expr" format_num = "0.1" ftd.path = "ftd" diff --git a/fastn-grammar/Cargo.toml b/fastn-grammar/Cargo.toml deleted file mode 100644 index 9fa8d958ca..0000000000 --- a/fastn-grammar/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "fastn-grammar" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - - -[dependencies] -serde.workspace = true - - -#[dev-dependencies] -#ron.workspace = true diff --git a/fastn-grammar/src/lib.rs b/fastn-grammar/src/lib.rs deleted file mode 100644 index f960184b9d..0000000000 --- a/fastn-grammar/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![deny(unused_crate_dependencies)] - -extern crate self as fastn_grammar; - -pub mod evalexpr; diff --git a/fastn-js/Cargo.toml b/fastn-js/Cargo.toml index 28f33acf00..d835947782 100644 --- a/fastn-js/Cargo.toml +++ b/fastn-js/Cargo.toml @@ -13,7 +13,7 @@ homepage.workspace = true pretty.workspace = true itertools.workspace = true indoc.workspace = true -fastn-grammar.workspace = true +fastn-type.workspace = true prettify-js.workspace = true thiserror.workspace = true diff --git a/fastn-js/src/conditional_component.rs b/fastn-js/src/conditional_component.rs index b257f7ab17..a7e740bda9 100644 --- a/fastn-js/src/conditional_component.rs +++ b/fastn-js/src/conditional_component.rs @@ -1,7 +1,7 @@ #[derive(Debug)] pub struct ConditionalComponent { pub deps: Vec, - pub condition: fastn_grammar::evalexpr::ExprNode, + pub condition: fastn_type::evalexpr::ExprNode, pub statements: Vec, pub parent: String, pub should_return: bool, diff --git a/fastn-js/src/property.rs b/fastn-js/src/property.rs index d2dfc343b7..5e7c0cb27f 100644 --- a/fastn-js/src/property.rs +++ b/fastn-js/src/property.rs @@ -123,7 +123,7 @@ impl Formula { #[derive(Debug)] pub struct ConditionalValue { - pub condition: Option, + pub condition: Option, pub expression: SetPropertyValue, } diff --git a/fastn-js/src/to_js.rs b/fastn-js/src/to_js.rs index 7d51a57c94..8b8fd26422 100644 --- a/fastn-js/src/to_js.rs +++ b/fastn-js/src/to_js.rs @@ -886,13 +886,13 @@ impl UDFStatement { pub struct ExpressionGenerator; impl ExpressionGenerator { - pub fn to_js(&self, node: &fastn_grammar::evalexpr::ExprNode) -> String { + pub fn to_js(&self, node: &fastn_type::evalexpr::ExprNode) -> String { self.to_js_(node, true, &[], false) } pub fn to_js_( &self, - node: &fastn_grammar::evalexpr::ExprNode, + node: &fastn_type::evalexpr::ExprNode, root: bool, arguments: &[(String, Option)], no_getter: bool, @@ -1010,12 +1010,12 @@ impl ExpressionGenerator { if let Some(mut operator) = self.has_operator(node.operator()) { // Todo: if node.children().len() != 2 {throw error} let first = node.children().first().unwrap(); //todo remove unwrap() - if matches!(node.operator(), fastn_grammar::evalexpr::Operator::Not) - || matches!(node.operator(), fastn_grammar::evalexpr::Operator::Neg) + if matches!(node.operator(), fastn_type::evalexpr::Operator::Not) + || matches!(node.operator(), fastn_type::evalexpr::Operator::Neg) { return [operator, self.to_js_(first, false, arguments, false)].join(""); } - if matches!(node.operator(), fastn_grammar::evalexpr::Operator::Neq) { + if matches!(node.operator(), fastn_type::evalexpr::Operator::Neq) { // For js conversion operator = "!==".to_string(); } @@ -1073,56 +1073,54 @@ impl ExpressionGenerator { } } - pub fn has_value(&self, operator: &fastn_grammar::evalexpr::Operator) -> Option { + pub fn has_value(&self, operator: &fastn_type::evalexpr::Operator) -> Option { match operator { - fastn_grammar::evalexpr::Operator::Const { .. } - | fastn_grammar::evalexpr::Operator::VariableIdentifierRead { .. } - | fastn_grammar::evalexpr::Operator::VariableIdentifierWrite { .. } => { + fastn_type::evalexpr::Operator::Const { .. } + | fastn_type::evalexpr::Operator::VariableIdentifierRead { .. } + | fastn_type::evalexpr::Operator::VariableIdentifierWrite { .. } => { Some(operator.to_string()) } _ => None, } } - pub fn has_function(&self, operator: &fastn_grammar::evalexpr::Operator) -> Option { + pub fn has_function(&self, operator: &fastn_type::evalexpr::Operator) -> Option { match operator { - fastn_grammar::evalexpr::Operator::FunctionIdentifier { .. } => { - Some(operator.to_string()) - } + fastn_type::evalexpr::Operator::FunctionIdentifier { .. } => Some(operator.to_string()), _ => None, } } - pub fn is_assignment(&self, operator: &fastn_grammar::evalexpr::Operator) -> bool { - matches!(operator, fastn_grammar::evalexpr::Operator::Assign) + pub fn is_assignment(&self, operator: &fastn_type::evalexpr::Operator) -> bool { + matches!(operator, fastn_type::evalexpr::Operator::Assign) } - pub fn is_chain(&self, operator: &fastn_grammar::evalexpr::Operator) -> bool { - matches!(operator, fastn_grammar::evalexpr::Operator::Chain) + pub fn is_chain(&self, operator: &fastn_type::evalexpr::Operator) -> bool { + matches!(operator, fastn_type::evalexpr::Operator::Chain) } - pub fn is_tuple(&self, operator: &fastn_grammar::evalexpr::Operator) -> bool { - matches!(operator, fastn_grammar::evalexpr::Operator::Tuple) + pub fn is_tuple(&self, operator: &fastn_type::evalexpr::Operator) -> bool { + matches!(operator, fastn_type::evalexpr::Operator::Tuple) } - pub fn is_null(&self, operator: &fastn_grammar::evalexpr::Operator) -> bool { + pub fn is_null(&self, operator: &fastn_type::evalexpr::Operator) -> bool { matches!( operator, - fastn_grammar::evalexpr::Operator::Const { - value: fastn_grammar::evalexpr::Value::Empty, + fastn_type::evalexpr::Operator::Const { + value: fastn_type::evalexpr::Value::Empty, } ) } - pub fn function_name(&self, operator: &fastn_grammar::evalexpr::Operator) -> Option { - if let fastn_grammar::evalexpr::Operator::FunctionIdentifier { identifier } = operator { + pub fn function_name(&self, operator: &fastn_type::evalexpr::Operator) -> Option { + if let fastn_type::evalexpr::Operator::FunctionIdentifier { identifier } = operator { Some(identifier.to_string()) } else { None } } - pub fn has_operator(&self, operator: &fastn_grammar::evalexpr::Operator) -> Option { + pub fn has_operator(&self, operator: &fastn_type::evalexpr::Operator) -> Option { if self.has_value(operator).is_none() && self.has_function(operator).is_none() && !self.is_chain(operator) @@ -1136,8 +1134,8 @@ impl ExpressionGenerator { } } - pub fn is_root(&self, operator: &fastn_grammar::evalexpr::Operator) -> bool { - matches!(operator, fastn_grammar::evalexpr::Operator::RootNode) + pub fn is_root(&self, operator: &fastn_type::evalexpr::Operator) -> bool { + matches!(operator, fastn_type::evalexpr::Operator::RootNode) } } diff --git a/fastn-js/src/udf.rs b/fastn-js/src/udf.rs index 6f2136d127..7f51ed315c 100644 --- a/fastn-js/src/udf.rs +++ b/fastn-js/src/udf.rs @@ -3,13 +3,13 @@ pub struct UDF { pub name: String, pub params: Vec, pub args: Vec<(String, fastn_js::SetPropertyValue)>, - pub body: Vec, + pub body: Vec, pub is_external_js_present: bool, } pub fn udf_with_arguments( name: &str, - body: Vec, + body: Vec, args: Vec<(String, fastn_js::SetPropertyValue)>, is_external_js_present: bool, ) -> fastn_js::Ast { diff --git a/fastn-type/Cargo.toml b/fastn-type/Cargo.toml index 26b2cac72a..7835073e30 100644 --- a/fastn-type/Cargo.toml +++ b/fastn-type/Cargo.toml @@ -11,4 +11,3 @@ homepage.workspace = true [dependencies] serde.workspace = true # serde_json.workspace = true -fastn-grammar.workspace = true diff --git a/fastn-grammar/src/evalexpr/context/mod.rs b/fastn-type/src/evalexpr/context/mod.rs similarity index 98% rename from fastn-grammar/src/evalexpr/context/mod.rs rename to fastn-type/src/evalexpr/context/mod.rs index c174c9d38c..40cb0d5e95 100644 --- a/fastn-grammar/src/evalexpr/context/mod.rs +++ b/fastn-type/src/evalexpr/context/mod.rs @@ -6,7 +6,7 @@ use std::{collections::HashMap, iter}; -use fastn_grammar::evalexpr::{ +use fastn_type::evalexpr::{ function::Function, value::{value_type::ValueType, Value}, EvalexprError, EvalexprResult, @@ -176,9 +176,9 @@ impl<'a> IterateVariablesContext<'a> for HashMapContext { /// # Examples /// /// ```rust -/// use fastn_grammar::evalexpr::*; +/// use fastn_type::evalexpr::*; /// -/// let ctx = fastn_grammar::context_map! { +/// let ctx = fastn_type::context_map! { /// "x" => 8, /// "f" => Function::new(|_| Ok(42.into())) /// }.unwrap(); // Do proper error handling here diff --git a/fastn-grammar/src/evalexpr/context/predefined/mod.rs b/fastn-type/src/evalexpr/context/predefined/mod.rs similarity index 84% rename from fastn-grammar/src/evalexpr/context/predefined/mod.rs rename to fastn-type/src/evalexpr/context/predefined/mod.rs index 3203e36cb9..02b313e794 100644 --- a/fastn-grammar/src/evalexpr/context/predefined/mod.rs +++ b/fastn-type/src/evalexpr/context/predefined/mod.rs @@ -4,7 +4,7 @@ #[macro_export] macro_rules! math_consts_context { () => { - $fastn_grammar::evalexpr::math_consts_context!( + $fastn_type::evalexpr::math_consts_context!( PI, TAU, FRAC_PI_2, @@ -27,8 +27,8 @@ macro_rules! math_consts_context { ) }; ($($name:ident),*) => {{ - use $fastn_grammar::evalexpr::ContextWithMutableVariables; - $fastn_grammar::evalexpr::context_map! { + use $fastn_type::evalexpr::ContextWithMutableVariables; + $fastn_type::evalexpr::context_map! { $( stringify!($name) => core::f64::consts::$name, )* diff --git a/fastn-grammar/src/evalexpr/error/display.rs b/fastn-type/src/evalexpr/error/display.rs similarity index 98% rename from fastn-grammar/src/evalexpr/error/display.rs rename to fastn-type/src/evalexpr/error/display.rs index 3d2b101116..25602e7847 100644 --- a/fastn-grammar/src/evalexpr/error/display.rs +++ b/fastn-type/src/evalexpr/error/display.rs @@ -1,10 +1,10 @@ use std::fmt; -use fastn_grammar::evalexpr::EvalexprError; +use fastn_type::evalexpr::EvalexprError; impl fmt::Display for EvalexprError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - use fastn_grammar::evalexpr::EvalexprError::*; + use fastn_type::evalexpr::EvalexprError::*; match self { WrongOperatorArgumentAmount { expected, actual } => write!( f, diff --git a/fastn-grammar/src/evalexpr/error/mod.rs b/fastn-type/src/evalexpr/error/mod.rs similarity index 98% rename from fastn-grammar/src/evalexpr/error/mod.rs rename to fastn-type/src/evalexpr/error/mod.rs index 56c0dfbd94..00952caea0 100644 --- a/fastn-grammar/src/evalexpr/error/mod.rs +++ b/fastn-type/src/evalexpr/error/mod.rs @@ -5,9 +5,9 @@ //! The module also contains some helper functions starting with `expect_` that check for a condition and return `Err(_)` if the condition is not fulfilled. //! They are meant as shortcuts to not write the same error checking code everywhere. -use fastn_grammar::evalexpr::{token::PartialToken, value::value_type::ValueType}; +use fastn_type::evalexpr::{token::PartialToken, value::value_type::ValueType}; -use fastn_grammar::evalexpr::{operator::Operator, value::Value}; +use fastn_type::evalexpr::{operator::Operator, value::Value}; // Exclude error display code from test coverage, as the code does not make sense to test. mod display; @@ -368,7 +368,7 @@ pub type EvalexprResult = Result; #[cfg(test)] mod tests { - use fastn_grammar::evalexpr::{EvalexprError, Value, ValueType}; + use fastn_type::evalexpr::{EvalexprError, Value, ValueType}; /// Tests whose only use is to bring test coverage of trivial lines up, like trivial constructors. #[test] diff --git a/fastn-grammar/src/evalexpr/feature_serde/mod.rs b/fastn-type/src/evalexpr/feature_serde/mod.rs similarity index 91% rename from fastn-grammar/src/evalexpr/feature_serde/mod.rs rename to fastn-type/src/evalexpr/feature_serde/mod.rs index 53e7a43d27..b82a1bc25f 100644 --- a/fastn-grammar/src/evalexpr/feature_serde/mod.rs +++ b/fastn-type/src/evalexpr/feature_serde/mod.rs @@ -1,4 +1,4 @@ -use fastn_grammar::evalexpr::{interface::build_operator_tree, ExprNode}; +use fastn_type::evalexpr::{interface::build_operator_tree, ExprNode}; use serde::{de, Deserialize, Deserializer}; use std::fmt; diff --git a/fastn-grammar/src/evalexpr/function/builtin.rs b/fastn-type/src/evalexpr/function/builtin.rs similarity index 99% rename from fastn-grammar/src/evalexpr/function/builtin.rs rename to fastn-type/src/evalexpr/function/builtin.rs index 24abfd5be8..3df4c3fa48 100644 --- a/fastn-grammar/src/evalexpr/function/builtin.rs +++ b/fastn-type/src/evalexpr/function/builtin.rs @@ -1,4 +1,4 @@ -use fastn_grammar::evalexpr::{ +use fastn_type::evalexpr::{ value::{FloatType, IntType}, EvalexprError, Function, Value, ValueType, }; diff --git a/fastn-grammar/src/evalexpr/function/mod.rs b/fastn-type/src/evalexpr/function/mod.rs similarity index 94% rename from fastn-grammar/src/evalexpr/function/mod.rs rename to fastn-type/src/evalexpr/function/mod.rs index 28911c01ad..78f7c07905 100644 --- a/fastn-grammar/src/evalexpr/function/mod.rs +++ b/fastn-type/src/evalexpr/function/mod.rs @@ -1,6 +1,6 @@ use std::fmt; -use fastn_grammar::evalexpr::{error::EvalexprResult, value::Value}; +use fastn_type::evalexpr::{error::EvalexprResult, value::Value}; pub(crate) mod builtin; @@ -30,7 +30,7 @@ where /// # Examples /// /// ```rust -/// use fastn_grammar::evalexpr::*; +/// use fastn_type::evalexpr::*; /// /// let mut context = HashMapContext::new(); /// context.set_function("id".into(), Function::new(|argument| { diff --git a/fastn-grammar/src/evalexpr/interface/mod.rs b/fastn-type/src/evalexpr/interface/mod.rs similarity index 98% rename from fastn-grammar/src/evalexpr/interface/mod.rs rename to fastn-type/src/evalexpr/interface/mod.rs index 4885c993a4..1b631c85a7 100644 --- a/fastn-grammar/src/evalexpr/interface/mod.rs +++ b/fastn-type/src/evalexpr/interface/mod.rs @@ -1,4 +1,4 @@ -use fastn_grammar::evalexpr::{ +use fastn_type::evalexpr::{ token, tree, value::TupleType, Context, ContextWithMutableVariables, EmptyType, EvalexprError, EvalexprResult, ExprNode, FloatType, HashMapContext, IntType, Value, EMPTY_VALUE, }; @@ -8,7 +8,7 @@ use fastn_grammar::evalexpr::{ /// # Examples /// /// ```rust -/// use fastn_grammar::evalexpr::*; +/// use fastn_type::evalexpr::*; /// /// assert_eq!(eval("1 + 2 + 3"), Ok(Value::from(6))); /// ``` @@ -23,7 +23,7 @@ pub fn eval(string: &str) -> EvalexprResult { /// # Examples /// /// ```rust -/// use fastn_grammar::evalexpr::*; +/// use fastn_type::evalexpr::*; /// /// let mut context = HashMapContext::new(); /// context.set_value("one".into(), 1.into()).unwrap(); // Do proper error handling here @@ -42,7 +42,7 @@ pub fn eval_with_context(string: &str, context: &C) -> EvalexprResul /// # Examples /// /// ```rust -/// use fastn_grammar::evalexpr::*; +/// use fastn_type::evalexpr::*; /// /// let mut context = HashMapContext::new(); /// context.set_value("one".into(), 1.into()).unwrap(); // Do proper error handling here @@ -67,7 +67,7 @@ pub fn eval_with_context_mut( /// # Examples /// /// ```rust -/// use fastn_grammar::evalexpr::*; +/// use fastn_type::evalexpr::*; /// /// let precomputed = build_operator_tree("one + two + three").unwrap(); // Do proper error handling here /// diff --git a/fastn-grammar/src/evalexpr/mod.rs b/fastn-type/src/evalexpr/mod.rs similarity index 97% rename from fastn-grammar/src/evalexpr/mod.rs rename to fastn-type/src/evalexpr/mod.rs index 4c1de672b2..4cc7a36e4b 100644 --- a/fastn-grammar/src/evalexpr/mod.rs +++ b/fastn-type/src/evalexpr/mod.rs @@ -11,7 +11,7 @@ //! Then you can use `evalexpr` to **evaluate expressions** like this: //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! //! assert_eq!(eval("1 + 2 + 3"), Ok(Value::from(6))); //! // `eval` returns a variant of the `Value` enum, @@ -26,7 +26,7 @@ //! You can **chain** expressions and **assign** to variables like this: //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! //! let mut context = HashMapContext::new(); //! // Assign 5 to a like this @@ -45,9 +45,9 @@ //! And you can use **variables** and **functions** in expressions like this: //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! -//! let context = fastn_grammar::context_map! { +//! let context = fastn_type::context_map! { //! "five" => 5, //! "twelve" => 12, //! "f" => Function::new(|argument| { @@ -81,11 +81,11 @@ //! You can also **precompile** expressions like this: //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! //! let precompiled = build_operator_tree("a * b - c > 5").unwrap(); // Do proper error handling here //! -//! let mut context = fastn_grammar::context_map! { +//! let mut context = fastn_type::context_map! { //! "a" => 6, //! "b" => 2, //! "c" => 3 @@ -153,7 +153,7 @@ //! Example: //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! //! assert_eq!(eval("1 / 2"), Ok(Value::from(0))); //! assert_eq!(eval("1.0 / 2"), Ok(Value::from(0.5))); @@ -168,7 +168,7 @@ //! Example: //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! //! assert_eq!(eval("1, \"b\", 3"), //! Ok(Value::from(vec![Value::from(1), Value::from("b"), Value::from(3)]))); @@ -177,7 +177,7 @@ //! To create nested tuples, use parentheses: //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! //! assert_eq!(eval("1, 2, (true, \"b\")"), Ok(Value::from(vec![ //! Value::from(1), @@ -198,7 +198,7 @@ //! That means that if an identifier is assigned a value of a type once, it cannot be assigned a value of another type. //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! //! let mut context = HashMapContext::new(); //! assert_eq!(eval_with_context("a = 5", &context), Err(EvalexprError::ContextNotMutable)); @@ -213,7 +213,7 @@ //! Here are some examples: //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! //! assert_eq!(eval_int("a = 2; a *= 2; a += 2; a"), Ok(6)); //! assert_eq!(eval_float("a = 2.2; a /= 2.0 / 4 + 1; a"), Ok(2.2 / (2.0 / 4.0 + 1.0))); @@ -229,7 +229,7 @@ //! Expression chaining is useful together with assignment to create small scripts. //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! //! let mut context = HashMapContext::new(); //! assert_eq!(eval("1;2;3;4;"), Ok(Value::Empty)); @@ -255,7 +255,7 @@ //! Here is a simple example to show the difference between preserving and not preserving context between evaluations: //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! //! assert_eq!(eval("a = 5;"), Ok(Value::from(()))); //! // The context is not preserved between eval calls @@ -287,7 +287,7 @@ //! Take a look at the following example: //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! //! let mut context = HashMapContext::new(); //! // We can set variables in code like this... @@ -305,9 +305,9 @@ //! Those can be passed one by one with the `set_function` method, but it might be more convenient to use the `context_map!` macro instead: //! //! ```rust -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! -//! let context = fastn_grammar::context_map!{ +//! let context = fastn_type::context_map!{ //! "f" => Function::new(|args| Ok(Value::from(args.as_int()? + 5))), //! }.unwrap_or_else(|error| panic!("Error creating context: {}", error)); //! assert_eq!(eval_int_with_context("f 5", &context), Ok(10)); @@ -492,9 +492,9 @@ //! ```rust //! # #[cfg(feature = "serde_support")] { //! extern crate ron; -//! use fastn_grammar::evalexpr::*; +//! use fastn_type::evalexpr::*; //! -//! let mut context = fastn_grammar::context_map!{ +//! let mut context = fastn_type::context_map!{ //! "five" => 5 //! }.unwrap(); // Do proper error handling here //! @@ -523,7 +523,7 @@ #![deny(missing_docs)] #![forbid(unsafe_code)] -pub use fastn_grammar::evalexpr::{ +pub use fastn_type::evalexpr::{ context::{ Context, ContextWithMutableFunctions, ContextWithMutableVariables, EmptyContext, HashMapContext, IterateVariablesContext, diff --git a/fastn-grammar/src/evalexpr/operator/display.rs b/fastn-type/src/evalexpr/operator/display.rs similarity index 93% rename from fastn-grammar/src/evalexpr/operator/display.rs rename to fastn-type/src/evalexpr/operator/display.rs index 8106702c91..899c398f72 100644 --- a/fastn-grammar/src/evalexpr/operator/display.rs +++ b/fastn-type/src/evalexpr/operator/display.rs @@ -1,10 +1,10 @@ use std::fmt::{Display, Error, Formatter}; -use fastn_grammar::evalexpr::operator::*; +use fastn_type::evalexpr::operator::*; impl Display for Operator { fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { - use fastn_grammar::evalexpr::operator::Operator::*; + use fastn_type::evalexpr::operator::Operator::*; match self { RootNode => Ok(()), Add => write!(f, "+"), diff --git a/fastn-grammar/src/evalexpr/operator/mod.rs b/fastn-type/src/evalexpr/operator/mod.rs similarity index 97% rename from fastn-grammar/src/evalexpr/operator/mod.rs rename to fastn-type/src/evalexpr/operator/mod.rs index 0828450432..96b2fc7234 100644 --- a/fastn-grammar/src/evalexpr/operator/mod.rs +++ b/fastn-type/src/evalexpr/operator/mod.rs @@ -1,8 +1,6 @@ -use fastn_grammar::evalexpr::function::builtin::builtin_function; +use fastn_type::evalexpr::function::builtin::builtin_function; -use fastn_grammar::evalexpr::{ - context::Context, error::*, value::Value, ContextWithMutableVariables, -}; +use fastn_type::evalexpr::{context::Context, error::*, value::Value, ContextWithMutableVariables}; mod display; @@ -118,7 +116,7 @@ impl Operator { /// Returns the precedence of the operator. /// A high precedence means that the operator has priority to be deeper in the tree. pub(crate) const fn precedence(&self) -> i32 { - use fastn_grammar::evalexpr::operator::Operator::*; + use fastn_type::evalexpr::operator::Operator::*; match self { RootNode => 200, @@ -148,13 +146,13 @@ impl Operator { /// and false if they should be evaluated right-to-left. /// Left-to-right chaining has priority if operators with different order but same precedence are chained. pub(crate) const fn is_left_to_right(&self) -> bool { - use fastn_grammar::evalexpr::operator::Operator::*; + use fastn_type::evalexpr::operator::Operator::*; !matches!(self, Assign | FunctionIdentifier { .. }) } /// Returns true if chains of this operator should be flattened into one operator with many arguments. pub(crate) const fn is_sequence(&self) -> bool { - use fastn_grammar::evalexpr::operator::Operator::*; + use fastn_type::evalexpr::operator::Operator::*; matches!(self, Tuple | Chain) } @@ -166,7 +164,7 @@ impl Operator { /// Returns the maximum amount of arguments required by this operator. pub(crate) const fn max_argument_amount(&self) -> Option { - use fastn_grammar::evalexpr::operator::Operator::*; + use fastn_type::evalexpr::operator::Operator::*; match self { Add | Sub | Mul | Div | Mod | Exp | Eq | Neq | Gt | Lt | Geq | Leq | And | Or | Assign | AddAssign | SubAssign | MulAssign | DivAssign | ModAssign | ExpAssign @@ -185,7 +183,7 @@ impl Operator { arguments: &[Value], context: &C, ) -> EvalexprResult { - use fastn_grammar::evalexpr::operator::Operator::*; + use fastn_type::evalexpr::operator::Operator::*; match self { RootNode => { if let Some(first) = arguments.first() { @@ -479,7 +477,7 @@ impl Operator { arguments: &[Value], context: &mut C, ) -> EvalexprResult { - use fastn_grammar::evalexpr::operator::Operator::*; + use fastn_type::evalexpr::operator::Operator::*; match self { Assign => { expect_operator_argument_amount(arguments.len(), 2)?; diff --git a/fastn-grammar/src/evalexpr/token/display.rs b/fastn-type/src/evalexpr/token/display.rs similarity index 97% rename from fastn-grammar/src/evalexpr/token/display.rs rename to fastn-type/src/evalexpr/token/display.rs index 61e1415004..0a262cafe9 100644 --- a/fastn-grammar/src/evalexpr/token/display.rs +++ b/fastn-type/src/evalexpr/token/display.rs @@ -1,6 +1,6 @@ use std::fmt; -use fastn_grammar::evalexpr::token::{PartialToken, Token}; +use fastn_type::evalexpr::token::{PartialToken, Token}; impl fmt::Display for Token { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { diff --git a/fastn-grammar/src/evalexpr/token/mod.rs b/fastn-type/src/evalexpr/token/mod.rs similarity index 99% rename from fastn-grammar/src/evalexpr/token/mod.rs rename to fastn-type/src/evalexpr/token/mod.rs index 0f4ace0f10..e0759030de 100644 --- a/fastn-grammar/src/evalexpr/token/mod.rs +++ b/fastn-type/src/evalexpr/token/mod.rs @@ -1,4 +1,4 @@ -use fastn_grammar::evalexpr::{ +use fastn_type::evalexpr::{ error::{EvalexprError, EvalexprResult}, value::{FloatType, IntType}, }; @@ -446,7 +446,7 @@ pub(crate) fn tokenize(string: &str) -> EvalexprResult> { #[cfg(test)] mod tests { - use fastn_grammar::evalexpr::token::{char_to_partial_token, tokenize, Token}; + use fastn_type::evalexpr::token::{char_to_partial_token, tokenize, Token}; use std::fmt::Write; #[test] diff --git a/fastn-grammar/src/evalexpr/tree/display.rs b/fastn-type/src/evalexpr/tree/display.rs similarity index 87% rename from fastn-grammar/src/evalexpr/tree/display.rs rename to fastn-type/src/evalexpr/tree/display.rs index cc95bc4e93..846890003d 100644 --- a/fastn-grammar/src/evalexpr/tree/display.rs +++ b/fastn-type/src/evalexpr/tree/display.rs @@ -1,4 +1,4 @@ -use fastn_grammar::evalexpr::ExprNode; +use fastn_type::evalexpr::ExprNode; use std::fmt::{Display, Error, Formatter}; impl Display for ExprNode { diff --git a/fastn-grammar/src/evalexpr/tree/iter.rs b/fastn-type/src/evalexpr/tree/iter.rs similarity index 97% rename from fastn-grammar/src/evalexpr/tree/iter.rs rename to fastn-type/src/evalexpr/tree/iter.rs index 3971db96d9..8a505e60a6 100644 --- a/fastn-grammar/src/evalexpr/tree/iter.rs +++ b/fastn-type/src/evalexpr/tree/iter.rs @@ -1,4 +1,4 @@ -use fastn_grammar::evalexpr::ExprNode; +use fastn_type::evalexpr::ExprNode; use std::slice::Iter; /// An iterator that traverses an operator tree in pre-order. diff --git a/fastn-grammar/src/evalexpr/tree/mod.rs b/fastn-type/src/evalexpr/tree/mod.rs similarity index 99% rename from fastn-grammar/src/evalexpr/tree/mod.rs rename to fastn-type/src/evalexpr/tree/mod.rs index 9132e753ad..73154499fb 100644 --- a/fastn-grammar/src/evalexpr/tree/mod.rs +++ b/fastn-type/src/evalexpr/tree/mod.rs @@ -1,10 +1,10 @@ -use fastn_grammar::evalexpr::{ +use fastn_type::evalexpr::{ token::Token, value::{TupleType, EMPTY_VALUE}, Context, ContextWithMutableVariables, EmptyType, FloatType, HashMapContext, IntType, }; -use fastn_grammar::evalexpr::{ +use fastn_type::evalexpr::{ error::{EvalexprError, EvalexprResult}, operator::*, value::Value, @@ -24,7 +24,7 @@ mod iter; /// # Examples /// /// ```rust -/// use fastn_grammar::evalexpr::*; +/// use fastn_type::evalexpr::*; /// /// let mut context = HashMapContext::new(); /// context.set_value("alpha".into(), 2.into()).unwrap(); // Do proper error handling here @@ -67,7 +67,7 @@ impl ExprNode { /// # Examples /// /// ```rust - /// use fastn_grammar::evalexpr::*; + /// use fastn_type::evalexpr::*; /// /// let tree = build_operator_tree("a + b + c * f()").unwrap(); // Do proper error handling here /// let mut iter = tree.iter_identifiers(); @@ -92,7 +92,7 @@ impl ExprNode { /// # Examples /// /// ```rust - /// use fastn_grammar::evalexpr::*; + /// use fastn_type::evalexpr::*; /// /// let tree = build_operator_tree("a + f(b + c)").unwrap(); // Do proper error handling here /// let mut iter = tree.iter_variable_identifiers(); @@ -115,7 +115,7 @@ impl ExprNode { /// # Examples /// /// ```rust - /// use fastn_grammar::evalexpr::*; + /// use fastn_type::evalexpr::*; /// /// let tree = build_operator_tree("d = a + f(b + c)").unwrap(); // Do proper error handling here /// let mut iter = tree.iter_read_variable_identifiers(); @@ -137,7 +137,7 @@ impl ExprNode { /// # Examples /// /// ```rust - /// use fastn_grammar::evalexpr::*; + /// use fastn_type::evalexpr::*; /// /// let tree = build_operator_tree("d = a + f(b + c)").unwrap(); // Do proper error handling here /// let mut iter = tree.iter_write_variable_identifiers(); @@ -157,7 +157,7 @@ impl ExprNode { /// # Examples /// /// ```rust - /// use fastn_grammar::evalexpr::*; + /// use fastn_type::evalexpr::*; /// /// let tree = build_operator_tree("a + f(b + c)").unwrap(); // Do proper error handling here /// let mut iter = tree.iter_function_identifiers(); diff --git a/fastn-grammar/src/evalexpr/value/display.rs b/fastn-type/src/evalexpr/value/display.rs similarity index 95% rename from fastn-grammar/src/evalexpr/value/display.rs rename to fastn-type/src/evalexpr/value/display.rs index 9112f7d077..97be2b2f7c 100644 --- a/fastn-grammar/src/evalexpr/value/display.rs +++ b/fastn-type/src/evalexpr/value/display.rs @@ -1,6 +1,6 @@ use std::fmt::{Display, Error, Formatter}; -use fastn_grammar::evalexpr::Value; +use fastn_type::evalexpr::Value; impl Display for Value { fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { diff --git a/fastn-grammar/src/evalexpr/value/mod.rs b/fastn-type/src/evalexpr/value/mod.rs similarity index 98% rename from fastn-grammar/src/evalexpr/value/mod.rs rename to fastn-type/src/evalexpr/value/mod.rs index dbadccdada..e9736a424d 100644 --- a/fastn-grammar/src/evalexpr/value/mod.rs +++ b/fastn-type/src/evalexpr/value/mod.rs @@ -1,4 +1,4 @@ -use fastn_grammar::evalexpr::error::{EvalexprError, EvalexprResult}; +use fastn_type::evalexpr::error::{EvalexprError, EvalexprResult}; use std::convert::TryFrom; mod display; @@ -267,7 +267,7 @@ impl TryFrom for () { #[cfg(test)] mod tests { - use fastn_grammar::evalexpr::value::{TupleType, Value}; + use fastn_type::evalexpr::value::{TupleType, Value}; #[test] fn test_value_conversions() { diff --git a/fastn-grammar/src/evalexpr/value/value_type.rs b/fastn-type/src/evalexpr/value/value_type.rs similarity index 96% rename from fastn-grammar/src/evalexpr/value/value_type.rs rename to fastn-type/src/evalexpr/value/value_type.rs index c90b985789..7b1464e119 100644 --- a/fastn-grammar/src/evalexpr/value/value_type.rs +++ b/fastn-type/src/evalexpr/value/value_type.rs @@ -1,4 +1,4 @@ -use fastn_grammar::evalexpr::Value; +use fastn_type::evalexpr::Value; /// The type of a `Value`. #[derive(Clone, Copy, Eq, PartialEq, Debug)] diff --git a/fastn-type/src/expression.rs b/fastn-type/src/expression.rs index 1f1539162b..7bbcbf03de 100644 --- a/fastn-type/src/expression.rs +++ b/fastn-type/src/expression.rs @@ -1,13 +1,13 @@ #[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)] pub struct Expression { - pub expression: fastn_grammar::evalexpr::ExprNode, + pub expression: fastn_type::evalexpr::ExprNode, pub references: fastn_type::Map, pub line_number: usize, } impl Expression { pub fn new( - expression: fastn_grammar::evalexpr::ExprNode, + expression: fastn_type::evalexpr::ExprNode, references: fastn_type::Map, line_number: usize, ) -> Expression { diff --git a/fastn-type/src/lib.rs b/fastn-type/src/lib.rs index 3b5731a92f..3f636ee72a 100644 --- a/fastn-type/src/lib.rs +++ b/fastn-type/src/lib.rs @@ -4,37 +4,31 @@ extern crate self as fastn_type; +mod component; +pub mod evalexpr; +mod expression; mod function; -pub use function::{Function, FunctionCall, FunctionExpression}; -mod value; -pub use value::{PropertyValue, PropertyValueSource, Value}; mod kind; -pub use kind::{Kind, KindData}; +mod module_thing; +mod or_type; +mod record; +mod value; +mod variable; +mod web_component; -mod component; pub use component::{ Argument, ComponentDefinition, ComponentInvocation, ComponentSource, Event, EventName, Loop, Property, PropertySource, }; - -mod expression; pub use expression::Expression; - -mod record; -pub use record::{AccessModifier, Field, Record}; - -mod module_thing; +pub use function::{Function, FunctionCall, FunctionExpression}; +pub use kind::{Kind, KindData}; pub use module_thing::ModuleThing; - -mod variable; +pub use or_type::{OrType, OrTypeVariant}; +pub use record::{AccessModifier, Field, Record}; +pub use value::{PropertyValue, PropertyValueSource, Value}; pub use variable::{ConditionalValue, Variable}; - -mod web_component; pub use web_component::WebComponentDefinition; - -mod or_type; -pub use or_type::{OrType, OrTypeVariant}; - pub type Map = std::collections::BTreeMap; #[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] diff --git a/ftd/Cargo.toml b/ftd/Cargo.toml index 537185a6d2..57a831ff07 100644 --- a/ftd/Cargo.toml +++ b/ftd/Cargo.toml @@ -38,7 +38,6 @@ thiserror.workspace = true #tokio = { workspace = true, optional = true } tracing.workspace = true fastn-js.workspace = true -fastn-grammar.workspace = true indexmap.workspace = true fastn-type.workspace = true diff --git a/ftd/src/executor/main.rs b/ftd/src/executor/main.rs index 8abe6d98a4..5effb5dbb7 100644 --- a/ftd/src/executor/main.rs +++ b/ftd/src/executor/main.rs @@ -199,7 +199,8 @@ impl ExecuteDoc<'_> { parent_container: &[usize], start_index: usize, inherited_variables: &mut ftd::VecMap<(String, Vec)>, - ) -> ftd::executor::Result, Vec, fastn_type::ComponentInvocation)>> { + ) -> ftd::executor::Result, Vec, fastn_type::ComponentInvocation)>> + { use ftd::js::fastn_type_functions::ComponentExt; if instruction.is_loop() { @@ -361,7 +362,8 @@ impl ExecuteDoc<'_> { parent_container: &[usize], start_index: usize, inherited_variables: &mut ftd::VecMap<(String, Vec)>, - ) -> ftd::executor::Result, Vec, fastn_type::ComponentInvocation)>> { + ) -> ftd::executor::Result, Vec, fastn_type::ComponentInvocation)>> + { use ftd::interpreter::LoopExt; let iteration = if let Some(iteration) = instruction.iteration.as_ref() { @@ -1069,28 +1071,23 @@ impl Device { } fn add_condition(&self, instruction: &mut fastn_type::ComponentInvocation, line_number: usize) { - let expression = - fastn_grammar::evalexpr::ExprNode::new(fastn_grammar::evalexpr::Operator::Eq) - .add_children(vec![ - fastn_grammar::evalexpr::ExprNode::new( - fastn_grammar::evalexpr::Operator::VariableIdentifierRead { - identifier: "ftd.device".to_string(), - }, - ), - fastn_grammar::evalexpr::ExprNode::new( - fastn_grammar::evalexpr::Operator::Const { - value: fastn_grammar::evalexpr::Value::String( - self.to_str().to_string(), - ), - }, - ), - ]); + let expression = fastn_type::evalexpr::ExprNode::new(fastn_type::evalexpr::Operator::Eq) + .add_children(vec![ + fastn_type::evalexpr::ExprNode::new( + fastn_type::evalexpr::Operator::VariableIdentifierRead { + identifier: "ftd.device".to_string(), + }, + ), + fastn_type::evalexpr::ExprNode::new(fastn_type::evalexpr::Operator::Const { + value: fastn_type::evalexpr::Value::String(self.to_str().to_string()), + }), + ]); if let Some(condition) = instruction.condition.as_mut() { let expression = - fastn_grammar::evalexpr::ExprNode::new(fastn_grammar::evalexpr::Operator::RootNode) - .add_children(vec![fastn_grammar::evalexpr::ExprNode::new( - fastn_grammar::evalexpr::Operator::And, + fastn_type::evalexpr::ExprNode::new(fastn_type::evalexpr::Operator::RootNode) + .add_children(vec![fastn_type::evalexpr::ExprNode::new( + fastn_type::evalexpr::Operator::And, ) .add_children(vec![expression, condition.expression.to_owned()])]); @@ -1108,7 +1105,7 @@ impl Device { ); } else { let expression = - fastn_grammar::evalexpr::ExprNode::new(fastn_grammar::evalexpr::Operator::RootNode) + fastn_type::evalexpr::ExprNode::new(fastn_type::evalexpr::Operator::RootNode) .add_children(vec![expression]); let condition = fastn_type::Expression { diff --git a/ftd/src/executor/utils.rs b/ftd/src/executor/utils.rs index e44e5735ea..3299002b28 100644 --- a/ftd/src/executor/utils.rs +++ b/ftd/src/executor/utils.rs @@ -93,11 +93,11 @@ pub(crate) fn update_condition_in_component( reference }; let new_condition = fastn_type::Expression { - expression: fastn_grammar::evalexpr::ExprNode::new( - fastn_grammar::evalexpr::Operator::RootNode, + expression: fastn_type::evalexpr::ExprNode::new( + fastn_type::evalexpr::Operator::RootNode, ) - .add_children(vec![fastn_grammar::evalexpr::ExprNode::new( - fastn_grammar::evalexpr::Operator::And, + .add_children(vec![fastn_type::evalexpr::ExprNode::new( + fastn_type::evalexpr::Operator::And, ) .add_children(vec![ outer_condition.expression, diff --git a/ftd/src/html/functions.rs b/ftd/src/html/functions.rs index 3edec4349d..0355618d8f 100644 --- a/ftd/src/html/functions.rs +++ b/ftd/src/html/functions.rs @@ -26,7 +26,7 @@ impl FunctionGenerator { pub fn get_function(&self, function: fastn_type::Function) -> ftd::html::Result { use itertools::Itertools; - /*let node = dbg!(fastn_grammar::evalexpr::build_operator_tree( + /*let node = dbg!(fastn_type::evalexpr::build_operator_tree( "a = a+b+f(a, b)+(j, k) + (a+b + g(a+j, k)); a" ) .unwrap()); //TODO: remove unwrap @@ -39,8 +39,7 @@ impl FunctionGenerator { .map(|v| (v.name.to_string(), v.mutable)) .collect_vec(); for expression in function.expression { - let node = - fastn_grammar::evalexpr::build_operator_tree(expression.expression.as_str())?; + let node = fastn_type::evalexpr::build_operator_tree(expression.expression.as_str())?; result.push(ftd::html::utils::trim_brackets( ExpressionGenerator .to_string(&node, true, arguments.as_slice()) @@ -79,7 +78,7 @@ pub struct ExpressionGenerator; impl ExpressionGenerator { pub fn to_string( &self, - node: &fastn_grammar::evalexpr::ExprNode, + node: &fastn_type::evalexpr::ExprNode, root: bool, arguments: &[(String, bool)], ) -> String { @@ -88,7 +87,7 @@ impl ExpressionGenerator { pub fn to_string_( &self, - node: &fastn_grammar::evalexpr::ExprNode, + node: &fastn_type::evalexpr::ExprNode, root: bool, arguments: &[(String, bool)], extra_args: bool, @@ -190,8 +189,8 @@ impl ExpressionGenerator { if let Some(operator) = self.has_operator(node.operator()) { // Todo: if node.children().len() != 2 {throw error} let first = node.children().first().unwrap(); //todo remove unwrap() - if matches!(node.operator(), fastn_grammar::evalexpr::Operator::Not) - || matches!(node.operator(), fastn_grammar::evalexpr::Operator::Neg) + if matches!(node.operator(), fastn_type::evalexpr::Operator::Not) + || matches!(node.operator(), fastn_type::evalexpr::Operator::Neg) { return [ operator, @@ -233,56 +232,54 @@ impl ExpressionGenerator { ) } - pub fn has_value(&self, operator: &fastn_grammar::evalexpr::Operator) -> Option { + pub fn has_value(&self, operator: &fastn_type::evalexpr::Operator) -> Option { match operator { - fastn_grammar::evalexpr::Operator::Const { .. } - | fastn_grammar::evalexpr::Operator::VariableIdentifierRead { .. } - | fastn_grammar::evalexpr::Operator::VariableIdentifierWrite { .. } => { + fastn_type::evalexpr::Operator::Const { .. } + | fastn_type::evalexpr::Operator::VariableIdentifierRead { .. } + | fastn_type::evalexpr::Operator::VariableIdentifierWrite { .. } => { Some(operator.to_string()) } _ => None, } } - pub fn has_function(&self, operator: &fastn_grammar::evalexpr::Operator) -> Option { + pub fn has_function(&self, operator: &fastn_type::evalexpr::Operator) -> Option { match operator { - fastn_grammar::evalexpr::Operator::FunctionIdentifier { .. } => { - Some(operator.to_string()) - } + fastn_type::evalexpr::Operator::FunctionIdentifier { .. } => Some(operator.to_string()), _ => None, } } - pub fn is_assignment(&self, operator: &fastn_grammar::evalexpr::Operator) -> bool { - matches!(operator, fastn_grammar::evalexpr::Operator::Assign) + pub fn is_assignment(&self, operator: &fastn_type::evalexpr::Operator) -> bool { + matches!(operator, fastn_type::evalexpr::Operator::Assign) } - pub fn is_chain(&self, operator: &fastn_grammar::evalexpr::Operator) -> bool { - matches!(operator, fastn_grammar::evalexpr::Operator::Chain) + pub fn is_chain(&self, operator: &fastn_type::evalexpr::Operator) -> bool { + matches!(operator, fastn_type::evalexpr::Operator::Chain) } - pub fn is_tuple(&self, operator: &fastn_grammar::evalexpr::Operator) -> bool { - matches!(operator, fastn_grammar::evalexpr::Operator::Tuple) + pub fn is_tuple(&self, operator: &fastn_type::evalexpr::Operator) -> bool { + matches!(operator, fastn_type::evalexpr::Operator::Tuple) } - pub fn is_null(&self, operator: &fastn_grammar::evalexpr::Operator) -> bool { + pub fn is_null(&self, operator: &fastn_type::evalexpr::Operator) -> bool { matches!( operator, - fastn_grammar::evalexpr::Operator::Const { - value: fastn_grammar::evalexpr::Value::Empty, + fastn_type::evalexpr::Operator::Const { + value: fastn_type::evalexpr::Value::Empty, } ) } - pub fn function_name(&self, operator: &fastn_grammar::evalexpr::Operator) -> Option { - if let fastn_grammar::evalexpr::Operator::FunctionIdentifier { identifier } = operator { + pub fn function_name(&self, operator: &fastn_type::evalexpr::Operator) -> Option { + if let fastn_type::evalexpr::Operator::FunctionIdentifier { identifier } = operator { Some(identifier.to_string()) } else { None } } - pub fn has_operator(&self, operator: &fastn_grammar::evalexpr::Operator) -> Option { + pub fn has_operator(&self, operator: &fastn_type::evalexpr::Operator) -> Option { if self.has_value(operator).is_none() && self.has_function(operator).is_none() && !self.is_chain(operator) @@ -296,8 +293,8 @@ impl ExpressionGenerator { } } - pub fn is_root(&self, operator: &fastn_grammar::evalexpr::Operator) -> bool { - matches!(operator, fastn_grammar::evalexpr::Operator::RootNode) + pub fn is_root(&self, operator: &fastn_type::evalexpr::Operator) -> bool { + matches!(operator, fastn_type::evalexpr::Operator::RootNode) } } diff --git a/ftd/src/html/mod.rs b/ftd/src/html/mod.rs index 6d57cb7fbc..0f33d3aaab 100644 --- a/ftd/src/html/mod.rs +++ b/ftd/src/html/mod.rs @@ -32,7 +32,7 @@ pub enum Error { }, #[error("InterpretEvalexprErrorerError: {}", _0)] - EvalexprError(#[from] fastn_grammar::evalexpr::EvalexprError), + EvalexprError(#[from] fastn_type::evalexpr::EvalexprError), } pub type Result = std::result::Result; diff --git a/ftd/src/interpreter/mod.rs b/ftd/src/interpreter/mod.rs index 1993cc4f61..897ba15a91 100644 --- a/ftd/src/interpreter/mod.rs +++ b/ftd/src/interpreter/mod.rs @@ -110,7 +110,7 @@ pub enum Error { }, #[error("EvalexprError: {}", _0)] - EvalexprError(#[from] fastn_grammar::evalexpr::EvalexprError), + EvalexprError(#[from] fastn_type::evalexpr::EvalexprError), #[error("serde error: {source}")] Serde { diff --git a/ftd/src/interpreter/test.rs b/ftd/src/interpreter/test.rs index 0a84ccd404..cc8409dab0 100644 --- a/ftd/src/interpreter/test.rs +++ b/ftd/src/interpreter/test.rs @@ -137,15 +137,15 @@ fn filename_with_second_last_extension_replaced_with_json( #[test] fn evalexpr_test() { - use fastn_grammar::evalexpr::*; + use fastn_type::evalexpr::*; let mut context = ftd::interpreter::default::default_context().unwrap(); - dbg!(fastn_grammar::evalexpr::build_operator_tree("$a >= $b").unwrap()); - dbg!(fastn_grammar::evalexpr::build_operator_tree( + dbg!(fastn_type::evalexpr::build_operator_tree("$a >= $b").unwrap()); + dbg!(fastn_type::evalexpr::build_operator_tree( "(e = \"\"; ftd.is_empty(e)) && (d = \ 4; d > 7) && (6 > 7)" ) .unwrap()); - dbg!(fastn_grammar::evalexpr::build_operator_tree("(6 > 7) && (true)").unwrap()); + dbg!(fastn_type::evalexpr::build_operator_tree("(6 > 7) && (true)").unwrap()); assert_eq!( eval_with_context_mut( "(e = \"\"; ftd.is_empty(e)) && (d = 4; d > 7)", diff --git a/ftd/src/interpreter/things/default.rs b/ftd/src/interpreter/things/default.rs index 68f65385e4..350eb5a2de 100644 --- a/ftd/src/interpreter/things/default.rs +++ b/ftd/src/interpreter/things/default.rs @@ -1,4 +1,4 @@ -use fastn_grammar::evalexpr::ContextWithMutableFunctions; +use fastn_type::evalexpr::ContextWithMutableFunctions; /** * The `default_aliases` function is intended to provide default aliases for the `ftd` module, @@ -30,8 +30,8 @@ enable light mode in the application. enable system mode in the application, which means the application will use the system's default color scheme. */ -pub fn default_functions() -> ftd::Map { - use fastn_grammar::evalexpr::*; +pub fn default_functions() -> ftd::Map { + use fastn_type::evalexpr::*; std::iter::IntoIterator::into_iter([ ( @@ -50,7 +50,7 @@ pub fn default_functions() -> ftd::Map { } else if let Ok(tuple) = argument.as_tuple() { if tuple.len().ne(&2) { Err( - fastn_grammar::evalexpr::error::EvalexprError::WrongFunctionArgumentAmount { + fastn_type::evalexpr::error::EvalexprError::WrongFunctionArgumentAmount { expected: 2, actual: tuple.len(), }, @@ -72,7 +72,7 @@ pub fn default_functions() -> ftd::Map { } } } else { - Err(fastn_grammar::evalexpr::error::EvalexprError::ExpectedString { + Err(fastn_type::evalexpr::error::EvalexprError::ExpectedString { actual: argument.clone(), }) } @@ -98,7 +98,7 @@ pub fn default_functions() -> ftd::Map { if let Ok(s) = argument.as_tuple() { if s.len() != 2 { Err( - fastn_grammar::evalexpr::error::EvalexprError::WrongFunctionArgumentAmount { + fastn_type::evalexpr::error::EvalexprError::WrongFunctionArgumentAmount { expected: 2, actual: s.len(), }, @@ -130,8 +130,8 @@ pub fn default_functions() -> ftd::Map { .collect() } -pub fn default_context() -> ftd::interpreter::Result { - let mut context = fastn_grammar::evalexpr::HashMapContext::new(); +pub fn default_context() -> ftd::interpreter::Result { + let mut context = fastn_type::evalexpr::HashMapContext::new(); for (key, function) in default_functions() { context.set_function(key, function)?; } diff --git a/ftd/src/interpreter/things/expression.rs b/ftd/src/interpreter/things/expression.rs index df6c9e1f84..9c0e5bb3d3 100644 --- a/ftd/src/interpreter/things/expression.rs +++ b/ftd/src/interpreter/things/expression.rs @@ -12,14 +12,14 @@ pub(crate) trait ExpressionExt { doc: &mut ftd::interpreter::TDoc, ) -> ftd::interpreter::Result>; fn scan_references( - node: &mut fastn_grammar::evalexpr::ExprNode, + node: &mut fastn_type::evalexpr::ExprNode, definition_name_with_arguments: Option<(&str, &[String])>, loop_object_name_and_kind: &Option, doc: &mut ftd::interpreter::TDoc, line_number: usize, ) -> ftd::interpreter::Result<()>; fn get_references( - node: &mut fastn_grammar::evalexpr::ExprNode, + node: &mut fastn_type::evalexpr::ExprNode, definition_name_with_arguments: &mut Option<(&str, &mut [fastn_type::Argument])>, loop_object_name_and_kind: &Option<(String, fastn_type::Argument, Option)>, doc: &mut ftd::interpreter::TDoc, @@ -29,7 +29,7 @@ pub(crate) trait ExpressionExt { >; fn eval(&self, doc: &ftd::interpreter::TDoc) -> ftd::interpreter::Result; fn is_static(&self, doc: &ftd::interpreter::TDoc) -> bool; - fn update_node_with_variable_reference(&self) -> fastn_grammar::evalexpr::ExprNode; + fn update_node_with_variable_reference(&self) -> fastn_type::evalexpr::ExprNode; } impl ExpressionExt for fastn_type::Expression { @@ -40,7 +40,7 @@ impl ExpressionExt for fastn_type::Expression { doc: &mut ftd::interpreter::TDoc, ) -> ftd::interpreter::Result<()> { if let Some(expression_mode) = get_expression_mode(condition.expression.as_str()) { - let mut node = fastn_grammar::evalexpr::build_operator_tree(expression_mode.as_str())?; + let mut node = fastn_type::evalexpr::build_operator_tree(expression_mode.as_str())?; fastn_type::Expression::scan_references( &mut node, definition_name_with_arguments, @@ -68,7 +68,7 @@ impl ExpressionExt for fastn_type::Expression { doc: &mut ftd::interpreter::TDoc, ) -> ftd::interpreter::Result> { if let Some(expression_mode) = get_expression_mode(condition.expression.as_str()) { - let mut node = fastn_grammar::evalexpr::build_operator_tree(expression_mode.as_str())?; + let mut node = fastn_type::evalexpr::build_operator_tree(expression_mode.as_str())?; let references = try_ok_state!(fastn_type::Expression::get_references( &mut node, definition_name_with_arguments, @@ -92,7 +92,7 @@ impl ExpressionExt for fastn_type::Expression { } fn scan_references( - node: &mut fastn_grammar::evalexpr::ExprNode, + node: &mut fastn_type::evalexpr::ExprNode, definition_name_with_arguments: Option<(&str, &[String])>, loop_object_name_and_kind: &Option, doc: &mut ftd::interpreter::TDoc, @@ -116,7 +116,7 @@ impl ExpressionExt for fastn_type::Expression { } fn get_references( - node: &mut fastn_grammar::evalexpr::ExprNode, + node: &mut fastn_type::evalexpr::ExprNode, definition_name_with_arguments: &mut Option<(&str, &mut [fastn_type::Argument])>, loop_object_name_and_kind: &Option<(String, fastn_type::Argument, Option)>, doc: &mut ftd::interpreter::TDoc, @@ -206,7 +206,7 @@ impl ExpressionExt for fastn_type::Expression { fn eval(&self, doc: &ftd::interpreter::TDoc) -> ftd::interpreter::Result { use ftd::interpreter::{PropertyValueExt, ValueExt}; - let mut values: ftd::Map = Default::default(); + let mut values: ftd::Map = Default::default(); for (key, property_value) in self.references.iter() { values.insert( key.to_string(), @@ -232,15 +232,15 @@ impl ExpressionExt for fastn_type::Expression { true } - fn update_node_with_variable_reference(&self) -> fastn_grammar::evalexpr::ExprNode { + fn update_node_with_variable_reference(&self) -> fastn_type::evalexpr::ExprNode { return update_node_with_variable_reference_(&self.expression, &self.references); fn update_node_with_variable_reference_( - expr: &fastn_grammar::evalexpr::ExprNode, + expr: &fastn_type::evalexpr::ExprNode, references: &ftd::Map, - ) -> fastn_grammar::evalexpr::ExprNode { + ) -> fastn_type::evalexpr::ExprNode { let mut operator = expr.operator().clone(); - if let fastn_grammar::evalexpr::Operator::VariableIdentifierRead { ref identifier } = + if let fastn_type::evalexpr::Operator::VariableIdentifierRead { ref identifier } = operator { if format!("${}", ftd::interpreter::FTD_LOOP_COUNTER).eq(identifier) { @@ -249,14 +249,14 @@ impl ExpressionExt for fastn_type::Expression { .. }) = references.get(identifier) { - operator = fastn_grammar::evalexpr::Operator::VariableIdentifierRead { + operator = fastn_type::evalexpr::Operator::VariableIdentifierRead { identifier: value.to_string(), } } } else if let Some(fastn_type::PropertyValue::Reference { name, .. }) = references.get(identifier) { - operator = fastn_grammar::evalexpr::Operator::VariableIdentifierRead { + operator = fastn_type::evalexpr::Operator::VariableIdentifierRead { identifier: format!( "resolve_reference(\"{}\", data)", ftd::interpreter::utils::js_reference_name(name) @@ -268,7 +268,7 @@ impl ExpressionExt for fastn_type::Expression { for child in expr.children() { children.push(update_node_with_variable_reference_(child, references)); } - fastn_grammar::evalexpr::ExprNode::new(operator).add_children(children) + fastn_type::evalexpr::ExprNode::new(operator).add_children(children) } } } @@ -286,12 +286,12 @@ pub(crate) struct VariableIdentifierReadNode { } fn get_variable_identifier_read( - node: &mut fastn_grammar::evalexpr::ExprNode, + node: &mut fastn_type::evalexpr::ExprNode, ) -> Vec { return get_variable_identifier_read_(node, &mut vec![], false, None); fn get_variable_identifier_read_( - node: &mut fastn_grammar::evalexpr::ExprNode, + node: &mut fastn_type::evalexpr::ExprNode, write_variable: &mut Vec, add_infer_type: bool, last_variable_identifier_read: Option>, @@ -302,8 +302,8 @@ fn get_variable_identifier_read( // TODO: if operator.eq(ftd_ast::NULL) throw error } else if let Some(operator) = node.operator().get_variable_identifier_read() { if operator.eq(ftd_ast::NULL) { - *node.operator_mut() = fastn_grammar::evalexpr::Operator::Const { - value: fastn_grammar::evalexpr::Value::Empty, + *node.operator_mut() = fastn_type::evalexpr::Operator::Const { + value: fastn_type::evalexpr::Value::Empty, }; } else if !write_variable.contains(&operator) { values.push(VariableIdentifierReadNode { @@ -323,7 +323,7 @@ fn get_variable_identifier_read( write_variable, matches!( operator, - fastn_grammar::evalexpr::Operator::Eq | fastn_grammar::evalexpr::Operator::Neq + fastn_type::evalexpr::Operator::Eq | fastn_type::evalexpr::Operator::Neq ), values.last().map(|last| Box::new(last.clone())), )); @@ -333,13 +333,13 @@ fn get_variable_identifier_read( } pub(crate) fn update_node_with_value( - expr: &fastn_grammar::evalexpr::ExprNode, - values: &ftd::Map, -) -> fastn_grammar::evalexpr::ExprNode { + expr: &fastn_type::evalexpr::ExprNode, + values: &ftd::Map, +) -> fastn_type::evalexpr::ExprNode { let mut operator = expr.operator().clone(); - if let fastn_grammar::evalexpr::Operator::VariableIdentifierRead { ref identifier } = operator { + if let fastn_type::evalexpr::Operator::VariableIdentifierRead { ref identifier } = operator { if let Some(value) = values.get(identifier) { - operator = fastn_grammar::evalexpr::Operator::Const { + operator = fastn_type::evalexpr::Operator::Const { value: value.to_owned(), } } @@ -348,5 +348,5 @@ pub(crate) fn update_node_with_value( for child in expr.children() { children.push(update_node_with_value(child, values)); } - fastn_grammar::evalexpr::ExprNode::new(operator).add_children(children) + fastn_type::evalexpr::ExprNode::new(operator).add_children(children) } diff --git a/ftd/src/interpreter/things/function.rs b/ftd/src/interpreter/things/function.rs index 0c5b18d2f8..76142b4d96 100644 --- a/ftd/src/interpreter/things/function.rs +++ b/ftd/src/interpreter/things/function.rs @@ -103,11 +103,11 @@ impl FunctionExt for fastn_type::Function { doc: &ftd::interpreter::TDoc, line_number: usize, ) -> ftd::interpreter::Result> { - use fastn_grammar::evalexpr::*; + use fastn_type::evalexpr::*; use ftd::interpreter::{PropertyValueExt, ValueExt}; struct VariableContext { - value: fastn_grammar::evalexpr::Value, + value: fastn_type::evalexpr::Value, reference: Option, mutable: bool, kind: fastn_type::Kind, @@ -167,7 +167,7 @@ impl FunctionExt for fastn_type::Function { let expression = self.convert_to_evalexpr_expression(); - let eval = fastn_grammar::evalexpr::eval_with_context_mut( + let eval = fastn_type::evalexpr::eval_with_context_mut( expression.as_str(), &mut evalexpr_context, )?; diff --git a/ftd/src/interpreter/things/value.rs b/ftd/src/interpreter/things/value.rs index cc5a74d040..398c8155c9 100644 --- a/ftd/src/interpreter/things/value.rs +++ b/ftd/src/interpreter/things/value.rs @@ -1461,14 +1461,14 @@ pub trait ValueExt { fn into_evalexpr_value( self, doc: &ftd::interpreter::TDoc, - ) -> ftd::interpreter::Result; + ) -> ftd::interpreter::Result; fn to_evalexpr_value( &self, doc: &ftd::interpreter::TDoc, line_number: usize, - ) -> ftd::interpreter::Result; + ) -> ftd::interpreter::Result; fn from_evalexpr_value( - value: fastn_grammar::evalexpr::Value, + value: fastn_type::evalexpr::Value, expected_kind: &fastn_type::Kind, doc_name: &str, line_number: usize, @@ -1664,21 +1664,17 @@ impl ValueExt for fastn_type::Value { fn into_evalexpr_value( self, doc: &ftd::interpreter::TDoc, - ) -> ftd::interpreter::Result { + ) -> ftd::interpreter::Result { match self { - fastn_type::Value::String { text } => Ok(fastn_grammar::evalexpr::Value::String(text)), - fastn_type::Value::Integer { value } => Ok(fastn_grammar::evalexpr::Value::Int(value)), - fastn_type::Value::Decimal { value } => { - Ok(fastn_grammar::evalexpr::Value::Float(value)) - } - fastn_type::Value::Boolean { value } => { - Ok(fastn_grammar::evalexpr::Value::Boolean(value)) - } + fastn_type::Value::String { text } => Ok(fastn_type::evalexpr::Value::String(text)), + fastn_type::Value::Integer { value } => Ok(fastn_type::evalexpr::Value::Int(value)), + fastn_type::Value::Decimal { value } => Ok(fastn_type::evalexpr::Value::Float(value)), + fastn_type::Value::Boolean { value } => Ok(fastn_type::evalexpr::Value::Boolean(value)), fastn_type::Value::Optional { data, .. } => { if let Some(data) = data.as_ref() { data.clone().into_evalexpr_value(doc) } else { - Ok(fastn_grammar::evalexpr::Value::Empty) + Ok(fastn_type::evalexpr::Value::Empty) } } fastn_type::Value::OrType { value, .. } => { @@ -1687,7 +1683,7 @@ impl ValueExt for fastn_type::Value { } fastn_type::Value::Record { .. } => { if let Ok(Some(value)) = ftd::interpreter::utils::get_value(doc, &self) { - Ok(fastn_grammar::evalexpr::Value::String(value.to_string())) + Ok(fastn_type::evalexpr::Value::String(value.to_string())) } else { unimplemented!("{:?}", self) } @@ -1698,7 +1694,7 @@ impl ValueExt for fastn_type::Value { let line_number = item.line_number(); values.push(item.resolve(doc, line_number)?.into_evalexpr_value(doc)?); } - Ok(fastn_grammar::evalexpr::Value::Tuple(values)) + Ok(fastn_type::evalexpr::Value::Tuple(values)) } t => unimplemented!("{:?}", t), } @@ -1708,14 +1704,14 @@ impl ValueExt for fastn_type::Value { &self, doc: &ftd::interpreter::TDoc, line_number: usize, - ) -> ftd::interpreter::Result { + ) -> ftd::interpreter::Result { Ok(match self { fastn_type::Value::String { text } => { - fastn_grammar::evalexpr::Value::String(text.to_string()) + fastn_type::evalexpr::Value::String(text.to_string()) } - fastn_type::Value::Integer { value } => fastn_grammar::evalexpr::Value::Int(*value), - fastn_type::Value::Decimal { value } => fastn_grammar::evalexpr::Value::Float(*value), - fastn_type::Value::Boolean { value } => fastn_grammar::evalexpr::Value::Boolean(*value), + fastn_type::Value::Integer { value } => fastn_type::evalexpr::Value::Int(*value), + fastn_type::Value::Decimal { value } => fastn_type::evalexpr::Value::Float(*value), + fastn_type::Value::Boolean { value } => fastn_type::evalexpr::Value::Boolean(*value), fastn_type::Value::List { data, .. } => { let mut values = vec![]; for value in data { @@ -1725,13 +1721,13 @@ impl ValueExt for fastn_type::Value { .to_evalexpr_value(doc, value.line_number())?; values.push(v); } - fastn_grammar::evalexpr::Value::Tuple(values) + fastn_type::evalexpr::Value::Tuple(values) } fastn_type::Value::Optional { data, .. } => { if let Some(data) = data.as_ref() { data.to_evalexpr_value(doc, line_number)? } else { - fastn_grammar::evalexpr::Value::Empty + fastn_type::evalexpr::Value::Empty } } t => unimplemented!("{:?}", t), @@ -1739,25 +1735,25 @@ impl ValueExt for fastn_type::Value { } fn from_evalexpr_value( - value: fastn_grammar::evalexpr::Value, + value: fastn_type::evalexpr::Value, expected_kind: &fastn_type::Kind, doc_name: &str, line_number: usize, ) -> ftd::interpreter::Result { Ok(match value { - fastn_grammar::evalexpr::Value::String(text) if expected_kind.is_string() => { + fastn_type::evalexpr::Value::String(text) if expected_kind.is_string() => { fastn_type::Value::String { text } } - fastn_grammar::evalexpr::Value::Float(value) if expected_kind.is_decimal() => { + fastn_type::evalexpr::Value::Float(value) if expected_kind.is_decimal() => { fastn_type::Value::Decimal { value } } - fastn_grammar::evalexpr::Value::Int(value) if expected_kind.is_integer() => { + fastn_type::evalexpr::Value::Int(value) if expected_kind.is_integer() => { fastn_type::Value::Integer { value } } - fastn_grammar::evalexpr::Value::Boolean(value) if expected_kind.is_boolean() => { + fastn_type::evalexpr::Value::Boolean(value) if expected_kind.is_boolean() => { fastn_type::Value::Boolean { value } } - fastn_grammar::evalexpr::Value::Tuple(data) if expected_kind.is_list() => { + fastn_type::evalexpr::Value::Tuple(data) if expected_kind.is_list() => { let mut values = vec![]; let val_kind = expected_kind.list_type(doc_name, line_number)?; for val in data { @@ -1777,7 +1773,7 @@ impl ValueExt for fastn_type::Value { kind: fastn_type::KindData::new(val_kind), } } - fastn_grammar::evalexpr::Value::Empty if expected_kind.is_optional() => { + fastn_type::evalexpr::Value::Empty if expected_kind.is_optional() => { fastn_type::Value::Optional { data: Box::new(None), kind: fastn_type::KindData::new(expected_kind.clone()), diff --git a/ftd/src/js/mod.rs b/ftd/src/js/mod.rs index e74257ac8e..f80f39109b 100644 --- a/ftd/src/js/mod.rs +++ b/ftd/src/js/mod.rs @@ -186,9 +186,7 @@ impl FunctionExt for fastn_type::Function { self.name.as_str(), self.expression .iter() - .map(|e| { - fastn_grammar::evalexpr::build_operator_tree(e.expression.as_str()).unwrap() - }) + .map(|e| fastn_type::evalexpr::build_operator_tree(e.expression.as_str()).unwrap()) .collect_vec(), self.arguments .iter() diff --git a/ftd/src/js/value.rs b/ftd/src/js/value.rs index 0fec98a8b4..88c60623e2 100644 --- a/ftd/src/js/value.rs +++ b/ftd/src/js/value.rs @@ -165,7 +165,7 @@ pub(crate) trait ExpressionExt { fn update_node_with_variable_reference_js( &self, rdata: &ftd::js::ResolverData, - ) -> fastn_grammar::evalexpr::ExprNode; + ) -> fastn_type::evalexpr::ExprNode; } impl ExpressionExt for fastn_type::Expression { @@ -182,25 +182,25 @@ impl ExpressionExt for fastn_type::Expression { fn update_node_with_variable_reference_js( &self, rdata: &ftd::js::ResolverData, - ) -> fastn_grammar::evalexpr::ExprNode { + ) -> fastn_type::evalexpr::ExprNode { return update_node_with_variable_reference_js_(&self.expression, &self.references, rdata); fn update_node_with_variable_reference_js_( - expr: &fastn_grammar::evalexpr::ExprNode, + expr: &fastn_type::evalexpr::ExprNode, references: &ftd::Map, rdata: &ftd::js::ResolverData, - ) -> fastn_grammar::evalexpr::ExprNode { + ) -> fastn_type::evalexpr::ExprNode { let mut operator = expr.operator().clone(); - if let fastn_grammar::evalexpr::Operator::VariableIdentifierRead { ref identifier } = + if let fastn_type::evalexpr::Operator::VariableIdentifierRead { ref identifier } = operator { if format!("${}", ftd::interpreter::FTD_LOOP_COUNTER).eq(identifier) { - operator = fastn_grammar::evalexpr::Operator::VariableIdentifierRead { + operator = fastn_type::evalexpr::Operator::VariableIdentifierRead { identifier: "index".to_string(), } } else if let Some(loop_counter_alias) = rdata.loop_counter_alias { if loop_counter_alias.eq(identifier.trim_start_matches('$')) { - operator = fastn_grammar::evalexpr::Operator::VariableIdentifierRead { + operator = fastn_type::evalexpr::Operator::VariableIdentifierRead { identifier: "index".to_string(), } } @@ -208,7 +208,7 @@ impl ExpressionExt for fastn_type::Expression { references.get(identifier) { let name = ftd::js::utils::update_reference(name, rdata); - operator = fastn_grammar::evalexpr::Operator::VariableIdentifierRead { + operator = fastn_type::evalexpr::Operator::VariableIdentifierRead { identifier: fastn_js::utils::reference_to_js(name.as_str()), } } @@ -219,7 +219,7 @@ impl ExpressionExt for fastn_type::Expression { child, references, rdata, )); } - fastn_grammar::evalexpr::ExprNode::new(operator).add_children(children) + fastn_type::evalexpr::ExprNode::new(operator).add_children(children) } } } diff --git a/v0.5/Cargo.toml b/v0.5/Cargo.toml index 417f681927..84c875e94d 100644 --- a/v0.5/Cargo.toml +++ b/v0.5/Cargo.toml @@ -7,6 +7,8 @@ members = [ "fastn-static", "fastn-unresolved", "fastn-update", + "../fastn-type", + "../fastn-grammar", ] exclude = [] resolver = "2" @@ -37,8 +39,9 @@ homepage = "https://fastn.com" # and create its own [dependencies.] section. Also, document it with why are you not # using the latest dependency, and what is the plan to move to the latest version. - fastn-lang = { path = "fastn-lang" } +fastn-grammar = { path = "../fastn-grammar" } +fastn-type = { path = "../fastn-type" } fastn-section = { path = "fastn-section" } fastn-static = { path = "fastn-static" } fastn-core = { path = "fastn-core" } diff --git a/v0.5/fastn-unresolved/Cargo.toml b/v0.5/fastn-unresolved/Cargo.toml index 320545bc08..56a4426336 100644 --- a/v0.5/fastn-unresolved/Cargo.toml +++ b/v0.5/fastn-unresolved/Cargo.toml @@ -11,6 +11,7 @@ homepage.workspace = true [dependencies] fastn-section.workspace = true serde.workspace = true +fastn-type.workspace = true [dev-dependencies] serde_json.workspace = true \ No newline at end of file diff --git a/v0.5/fastn-unresolved/src/lib.rs b/v0.5/fastn-unresolved/src/lib.rs index 27061f5bae..d5b38c6f55 100644 --- a/v0.5/fastn-unresolved/src/lib.rs +++ b/v0.5/fastn-unresolved/src/lib.rs @@ -92,8 +92,9 @@ pub enum UR { #[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] pub struct ComponentInvocation { pub name: UR, - pub caption: Option, - pub properties: Vec, + /// once a caption is resolved it is set to () here, and moved to properties + pub caption: UR, ()>, + pub properties: Vec>, pub body: Vec, pub children: Vec, }