Skip to content

Commit b3a40f8

Browse files
committed
Rewrite quoted_string parser without macros
1 parent 300bac8 commit b3a40f8

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/fallback.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -990,13 +990,16 @@ named!(string -> (), alt!(
990990
)
991991
));
992992

993-
named!(quoted_string -> (), do_parse!(
994-
punct!("\"") >>
995-
cooked_string >>
996-
tag!("\"") >>
997-
option!(symbol_not_raw) >>
998-
(())
999-
));
993+
fn quoted_string(input: Cursor) -> PResult<()> {
994+
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, ())),
1001+
}
1002+
}
10001003

10011004
fn cooked_string(input: Cursor) -> PResult<()> {
10021005
let mut chars = input.char_indices().peekable();

src/strnom.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,6 @@ macro_rules! call {
251251
};
252252
}
253253

254-
macro_rules! option {
255-
($i:expr, $f:expr) => {
256-
match $f($i) {
257-
Ok((i, o)) => Ok((i, Some(o))),
258-
Err(LexError) => Ok(($i, None)),
259-
}
260-
};
261-
}
262-
263254
macro_rules! tag {
264255
($i:expr, $tag:expr) => {
265256
if $i.starts_with($tag) {

0 commit comments

Comments
 (0)