aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-01 22:17:06 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-01 22:17:06 -0600
commitfa750e3d195c249cc48a7416b487715c2031428d (patch)
tree669b54ca91bce3d3088737c564faf4520b482e3a /src
parentdfe0b3fa77d7a448b4fd3286867bf1b9c4adfc74 (diff)
downloadmakers-fa750e3d195c249cc48a7416b487715c2031428d.tar.gz
makers-fa750e3d195c249cc48a7416b487715c2031428d.zip
and here i thought alt() would do backtracking on its own
Diffstat (limited to 'src')
-rw-r--r--src/makefile/mod.rs3
-rw-r--r--src/makefile/token.rs10
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(())