diff --git a/src/parser/parser.rs b/src/parser/parser.rs index 69109f2..839d3f3 100644 --- a/src/parser/parser.rs +++ b/src/parser/parser.rs @@ -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(("", ""))); + } }