Skip to content

Commit a95ecbc

Browse files
committed
Rewrite string parser without macros
1 parent b3a40f8 commit a95ecbc

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

src/fallback.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -980,24 +980,19 @@ named!(literal_nocapture -> (), alt!(
980980
int
981981
));
982982

983-
named!(string -> (), alt!(
984-
quoted_string
985-
|
986-
do_parse!(
987-
punct!("r") >>
988-
raw_string >>
989-
(())
990-
)
991-
));
992-
993-
fn quoted_string(input: Cursor) -> PResult<()> {
983+
fn string(input: Cursor) -> PResult<()> {
994984
let input = skip_whitespace(input);
995-
let input = input.expect("\"")?;
996-
let (input, ()) = cooked_string(input)?;
997-
let input = input.expect("\"")?;
998-
match symbol_not_raw(input) {
999-
Ok((input, _)) => Ok((input, ())),
1000-
Err(LexError) => Ok((input, ())),
985+
if let Ok(input) = input.expect("\"") {
986+
let (input, ()) = cooked_string(input)?;
987+
let input = input.expect("\"")?;
988+
match symbol_not_raw(input) {
989+
Ok((input, _)) => Ok((input, ())),
990+
Err(LexError) => Ok((input, ())),
991+
}
992+
} else if let Ok(input) = input.expect("r") {
993+
raw_string(input)
994+
} else {
995+
Err(LexError)
1001996
}
1002997
}
1003998

0 commit comments

Comments
 (0)