Skip to content

Commit

Permalink
buckets fix
Browse files Browse the repository at this point in the history
  • Loading branch information
loomstyla committed Oct 2, 2023
1 parent 9004e52 commit 0ed80be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion palabritas/src/palabritas.pest
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
33 changes: 22 additions & 11 deletions runtime/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -1006,7 +1017,7 @@ impl Runtime {
settings: &cuentitos_common::BlockSettings,
) -> Result<Option<BlockId>, RuntimeError> {
let total_frequency = self.get_total_frequency(settings)?;

if total_frequency == 0 {
return Ok(None);
}
Expand Down

0 comments on commit 0ed80be

Please sign in to comment.