diff options
author | Rory Dudley | 2024-05-13 00:06:23 -0600 |
---|---|---|
committer | Rory Dudley | 2024-05-13 00:06:23 -0600 |
commit | ce313753f555061ed8140a0664e73a3e60857d9b (patch) | |
tree | 9be71aabc3e8529272aef4daf06b65d611917796 | |
parent | 908cd899695ba07bfc47645c532337958ee208d7 (diff) | |
download | dwarvish-ce313753f555061ed8140a0664e73a3e60857d9b.tar.gz |
Fix another regression with aliases
The last commit (1415c8f9b89699000ef8d864ff8f0e1bebca4a5f) fixed the
issue with pipes, however, it did not fix it for IO. This patch adds
some logic for the aliased verse to inherit the properties of the
original verse, so that recite works properly for all verse types
(regardless of IO, couplet, or meter).
-rw-r--r-- | src/poem/read.rs | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/poem/read.rs b/src/poem/read.rs index 875bf76..e5cd25d 100644 --- a/src/poem/read.rs +++ b/src/poem/read.rs @@ -68,6 +68,12 @@ impl Appendable for Poem { return Ok(()); } + // Check the meter + verse.meter = meter; + if last == Rune::Couplet || meter == Rune::Couplet { + verse.couplet = true; + } + // Check for aliases match env.aliases.get(&verse.verb()) { Some(alias) => { @@ -80,32 +86,23 @@ impl Appendable for Poem { None => unreachable!(), // Should be caught by a Mishap above }; - // If the verse has a clause, add it to the last verse in - // the poem from the alias + // The last verse inherits the traits from the original + lv.couplet = verse.couplet; + lv.io = verse.io; + lv.poems = verse.poems.clone(); + lv.meter = verse.meter; if verse.clause().is_some() { for word in verse.clause().unwrap().iter() { lv.stanza.push(word.to_string()); } } - // Check the meter - lv.meter = meter; - if last == Rune::Couplet || meter == Rune::Couplet { - verse.couplet = true; - } - // Push verse(s) for v in poem.iter() { self.push(v.clone()); } } None => { - // Check the meter - verse.meter = meter; - if last == Rune::Couplet || meter == Rune::Couplet { - verse.couplet = true; - } - // Push verse(s) self.push(verse.clone()); } @@ -162,8 +159,6 @@ impl Readable for Poem { None => { // Check for IO parse errors if last == Rune::Read || last == Rune::Write || last == Rune::Addendum { - println!("err 0"); - println!("{:?}", verse); return Err(Mishap::IOMishap(j, i, ' ')); } @@ -173,7 +168,6 @@ impl Readable for Poem { // Throw an error if the verse is empty if verse.is_empty() && (last == Rune::Couplet || last == Rune::And) { - println!("err 1"); return Err(Mishap::ParseMishap(j, i, ' ')); } |