mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-25 13:17:06 +08:00
Fix \R parse
This commit is contained in:
@@ -356,9 +356,8 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
// command
|
// command
|
||||||
if c == "\\" {
|
if c == "\\" {
|
||||||
// check \R
|
let cmd = self.parse_command()?;
|
||||||
if self.peek_char_offset(1).is_some_and(|c| c == "R") {
|
if !cmd.has_args && cmd.name == "R" {
|
||||||
self.cur_pos += 2;
|
|
||||||
text.push_str("\\R");
|
text.push_str("\\R");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -367,7 +366,7 @@ impl<'a> Parser<'a> {
|
|||||||
line.push(LineNode::Text(TextNode(ctext.to_owned())));
|
line.push(LineNode::Text(TextNode(ctext.to_owned())));
|
||||||
text.clear();
|
text.clear();
|
||||||
}
|
}
|
||||||
line.push(LineNode::Command(self.parse_command()?));
|
line.push(LineNode::Command(cmd));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// name
|
// 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
|
||||||
|
})])],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user