Initial scaffold for developing a quoted string parser

This commit is contained in:
Tom Alexander 2020-04-06 20:20:53 -04:00
parent 41abcb9b4a
commit b3120d2e52
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -1,5 +1,7 @@
use nom::branch::alt;
use nom::bytes::complete::escaped;
use nom::bytes::complete::is_a;
use nom::bytes::complete::is_not;
use nom::bytes::complete::tag;
use nom::bytes::complete::take_until;
use nom::character::complete::one_of;
@ -326,6 +328,10 @@ pub fn template(i: &str) -> IResult<&str, Template> {
Ok((remaining, Template { contents: contents }))
}
fn temp_string(i: &str) -> IResult<&str, &str> {
escaped(is_not("\""), '\\', one_of(r#""\"#))(i)
}
#[cfg(test)]
mod tests {
use super::*;
@ -601,4 +607,9 @@ mod tests {
))
);
}
#[test]
fn test_temp_string() {
assert_eq!(temp_string(""), Ok(("", "")));
}
}