diff --git a/examples/async_download.ds b/examples/async_download.ds index ca6d005..983dbf4 100644 --- a/examples/async_download.ds +++ b/examples/async_download.ds @@ -1,13 +1,9 @@ -raw_data = async { - { - cast = (download "https://api.sampleapis.com/futurama/cast") - characters = (download "https://api.sampleapis.com/futurama/characters") - episodes = (download "https://api.sampleapis.com/futurama/episodes") - } -} +cast = (download "https://api.sampleapis.com/futurama/cast") +characters = (download "https://api.sampleapis.com/futurama/characters") +episodes = (download "https://api.sampleapis.com/futurama/episodes") -cast_len = (length (from_json data:cast)) -characters_len = (length (from_json data:characters)) -episodes_len = (length (from_json data:episodes)) +cast_len = (length (from_json cast)) +characters_len = (length (from_json characters)) +episodes_len = (length (from_json episodes)) (output [cast_len, characters_len, episodes_len]) diff --git a/examples/download.ds b/examples/download.ds new file mode 100644 index 0000000..983dbf4 --- /dev/null +++ b/examples/download.ds @@ -0,0 +1,9 @@ +cast = (download "https://api.sampleapis.com/futurama/cast") +characters = (download "https://api.sampleapis.com/futurama/characters") +episodes = (download "https://api.sampleapis.com/futurama/episodes") + +cast_len = (length (from_json cast)) +characters_len = (length (from_json characters)) +episodes_len = (length (from_json episodes)) + +(output [cast_len, characters_len, episodes_len]) diff --git a/examples/fetch.ds b/examples/fetch.ds index b5ebd57..89e656f 100644 --- a/examples/fetch.ds +++ b/examples/fetch.ds @@ -1,8 +1,10 @@ raw_data = (download "https://api.sampleapis.com/futurama/cast") cast_data = (from_json raw_data) -names = transform cast_member in cast_data { - cast_member.name +names = [] + +for cast_member in cast_data { + names += cast_member:name } -(assert_equal "Billy West", names.0) +(assert_equal "Billy West", names:0) diff --git a/src/abstract_tree/block.rs b/src/abstract_tree/block.rs index f0f7f56..572076a 100644 --- a/src/abstract_tree/block.rs +++ b/src/abstract_tree/block.rs @@ -42,8 +42,6 @@ impl AbstractTree for Block { } fn run(&self, source: &str, context: &mut Map) -> Result { - println!("Running {} statements.", self.statements.len()); - if self.is_async { let statements = &self.statements; let final_result = RwLock::new(Ok(Value::Empty)); diff --git a/src/abstract_tree/mod.rs b/src/abstract_tree/mod.rs index 03c2594..0a08a30 100644 --- a/src/abstract_tree/mod.rs +++ b/src/abstract_tree/mod.rs @@ -32,9 +32,9 @@ pub mod r#yield; pub use { assignment::*, block::*, built_in_function::*, expression::*, filter::*, find::*, - function_call::*, identifier::*, if_else::*, index::*, index_assignment::*, insert::*, - logic::*, math::*, r#for::*, r#match::*, r#while::*, r#yield::*, remove::*, select::*, - statement::*, transform::*, value_node::*, + function_call::*, identifier::*, if_else::*, index::*, index_assignment::IndexAssignment, + insert::*, logic::*, math::*, r#for::*, r#match::*, r#while::*, r#yield::*, remove::*, + select::*, statement::*, transform::*, value_node::*, }; use tree_sitter::Node; @@ -55,6 +55,6 @@ pub trait AbstractTree: Sized { /// node's byte range. fn from_syntax_node(source: &str, node: Node) -> Result; - /// Execute dust code by traversing the tree + /// Execute dust code by traversing the tree. fn run(&self, source: &str, context: &mut Map) -> Result; }