1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use crate::error::parse_fail::ParseFail;
use super::munyo_parser::{Pairs, Rule};
pub(crate) fn parse_content(pairs: Pairs, starting_text: &str) -> Result<String, ParseFail> {
let mut s = String::with_capacity(8);
s.push_str(starting_text);
for pair in pairs {
match pair.as_rule() {
Rule::char_seq => {
s.push_str(pair.as_str());
}
Rule::escaped => match pair.as_str() {
r"\\" => {
s.push('\\');
}
r"\|" => {
s.push('|');
}
r"\n" => {
s.push('\n');
}
r"\r" => {
s.push('\r');
}
r"\t" => {
s.push('\t');
}
_ => {
unreachable!()
}
},
_ => {
unreachable!();
}
}
}
Ok(s)
}