Fix \R parse

This commit is contained in:
2026-05-29 16:24:06 +08:00
parent 465b0d7f9e
commit 24f73a03f8

View File

@@ -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
})])],
);
}
}