From 0ed80bef0ec85f8841006ce6171c43784b085351 Mon Sep 17 00:00:00 2001 From: loomstyla Date: Mon, 2 Oct 2023 12:13:18 -0300 Subject: [PATCH] buckets fix --- palabritas/src/palabritas.pest | 2 +- runtime/src/runtime.rs | 33 ++++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/palabritas/src/palabritas.pest b/palabritas/src/palabritas.pest index 44fc0ec..0d81909 100644 --- a/palabritas/src/palabritas.pest +++ b/palabritas/src/palabritas.pest @@ -51,6 +51,6 @@ Block = { Database = { SOI ~ (NewLine | Block | Section )* ~ EOI } -COMMENT = _{ "//" ~ (!(NewLine | EOI) ~ ANY)* ~ (NewLine | EOI) } +COMMENT = _{ " "* ~"//" ~ (!(NewLine | EOI) ~ ANY)* ~ (NewLine | EOI) } NewLine = _{ EmptyLine | NEWLINE } EmptyLine = _{" "* ~ NEWLINE } \ No newline at end of file diff --git a/runtime/src/runtime.rs b/runtime/src/runtime.rs index f1fd8a4..4633964 100644 --- a/runtime/src/runtime.rs +++ b/runtime/src/runtime.rs @@ -959,17 +959,28 @@ impl Runtime { let parent_settings = parent.get_settings(); let mut previous_block_found = false; - for sibling in &parent_settings.children { - if previous_block_found { - if let cuentitos_common::Block::Choice { id: _, settings: _ } = - self.get_cuentitos_block(*sibling)? - { - continue; - } - return self.push_stack_until_text(*sibling); + + let skip_siblings = matches!( + parent, + cuentitos_common::Block::Bucket { + name: _, + settings: _, } - if *sibling == previous_id { - previous_block_found = true; + ); + + if !skip_siblings { + for sibling in &parent_settings.children { + if previous_block_found { + if let cuentitos_common::Block::Choice { id: _, settings: _ } = + self.get_cuentitos_block(*sibling)? + { + continue; + } + return self.push_stack_until_text(*sibling); + } + if *sibling == previous_id { + previous_block_found = true; + } } } @@ -1006,7 +1017,7 @@ impl Runtime { settings: &cuentitos_common::BlockSettings, ) -> Result, RuntimeError> { let total_frequency = self.get_total_frequency(settings)?; - + if total_frequency == 0 { return Ok(None); }