From fa750e3d195c249cc48a7416b487715c2031428d Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 1 Apr 2021 22:17:06 -0600 Subject: and here i thought alt() would do backtracking on its own --- src/makefile/mod.rs | 3 +-- src/makefile/token.rs | 10 +++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index c118eb9..5be18e0 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -714,8 +714,7 @@ mod test { #[test] fn basic_conditionals() -> R { let file = " -ifneq (,$(foo bar, $(baz))) -else ifeq (1,1) +ifeq (1,1) worked = yes else ifeq (2,2) worked = no 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(()) -- cgit v1.2.3