From 24f73a03f8c815b15cdf0d62def420dba98aaa6e Mon Sep 17 00:00:00 2001 From: lifegpc Date: Fri, 29 May 2026 16:24:06 +0800 Subject: [PATCH] Fix \R parse --- src/scripts/yuris/txt.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/scripts/yuris/txt.rs b/src/scripts/yuris/txt.rs index 0d102da..f694ca7 100644 --- a/src/scripts/yuris/txt.rs +++ b/src/scripts/yuris/txt.rs @@ -356,9 +356,8 @@ impl<'a> Parser<'a> { } // command if c == "\\" { - // check \R - if self.peek_char_offset(1).is_some_and(|c| c == "R") { - self.cur_pos += 2; + let cmd = self.parse_command()?; + if !cmd.has_args && cmd.name == "R" { text.push_str("\\R"); continue; } @@ -367,7 +366,7 @@ impl<'a> Parser<'a> { line.push(LineNode::Text(TextNode(ctext.to_owned()))); text.clear(); } - line.push(LineNode::Command(self.parse_command()?)); + line.push(LineNode::Command(cmd)); continue; } // name @@ -824,4 +823,16 @@ mod tests { ], ); } + #[test] + fn test_parse8() { + let data = r"\RP.END(SCENE_ETC_H04)"; + assert_eq!( + Parser::new(data).parse().unwrap(), + vec![Line::Line(vec![LineNode::Command(CommandNode { + name: "RP.END".into(), + args: vec!["SCENE_ETC_H04".into()], + has_args: true + })])], + ); + } }