diff options
author | Melody Horn <melody@boringcactus.com> | 2021-04-01 22:17:06 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-04-01 22:17:06 -0600 |
commit | fa750e3d195c249cc48a7416b487715c2031428d (patch) | |
tree | 669b54ca91bce3d3088737c564faf4520b482e3a /src/makefile/token.rs | |
parent | dfe0b3fa77d7a448b4fd3286867bf1b9c4adfc74 (diff) | |
download | makers-fa750e3d195c249cc48a7416b487715c2031428d.tar.gz makers-fa750e3d195c249cc48a7416b487715c2031428d.zip |
and here i thought alt() would do backtracking on its own
Diffstat (limited to 'src/makefile/token.rs')
-rw-r--r-- | src/makefile/token.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/makefile/token.rs b/src/makefile/token.rs index 0ee3e4c..60cffe0 100644 --- a/src/makefile/token.rs +++ b/src/makefile/token.rs @@ -205,7 +205,7 @@ fn function_call_body<'a, E: Err<'a>>( fn parens_macro_expansion<'a, E: Err<'a>>(input: &'a str) -> IResult<&'a str, Token, E> { delimited( tag("$("), - alt((macro_expansion_body(')'), function_call_body(')'))), + alt((function_call_body(')'), macro_expansion_body(')'))), tag(")"), )(input) } @@ -213,7 +213,7 @@ fn parens_macro_expansion<'a, E: Err<'a>>(input: &'a str) -> IResult<&'a str, To fn braces_macro_expansion<'a, E: Err<'a>>(input: &'a str) -> IResult<&'a str, Token, E> { delimited( tag("${"), - alt((macro_expansion_body('}'), function_call_body('}'))), + alt((function_call_body('}'), macro_expansion_body('}'))), tag("}"), )(input) } @@ -432,17 +432,13 @@ mod test { #[test] fn function_hell() -> R { - dbg!(alt::<_, _, VerboseError<_>, _>(( - macro_expansion_body(')'), - function_call_body(')') - ))("$(foo bar,$(baz))")); let text = "$(foo bar, $(baz))"; let tokens = tokenize(text)?; assert_eq!( tokens, TokenString(vec![token_function_call( "foo", - vec![TokenString::text("bar"), TokenString::r#macro("baz")] + vec![TokenString::text("bar"), tokenize(" $(baz)")?] )]) ); Ok(()) |