Work around parsing ambiguity involving struct literals
diff --git a/src/nom.rs b/src/nom.rs
index 8586ff3..e313be2 100644
--- a/src/nom.rs
+++ b/src/nom.rs
@@ -25,8 +25,8 @@
}
macro_rules! call {
- ($i:expr, $fun:expr) => {
- $fun($i)
+ ($i:expr, $fun:expr $(, $args:expr)*) => {
+ $fun($i $(, $args)*)
};
}
@@ -78,6 +78,20 @@
};
}
+macro_rules! cond_reduce {
+ ($i:expr, $cond:expr, $submac:ident!( $($args:tt)* )) => {
+ if $cond {
+ $submac!($i, $($args)*)
+ } else {
+ $crate::nom::IResult::Error
+ }
+ };
+
+ ($i:expr, $cond:expr, $f:expr) => {
+ cond_reduce!($i, $cond, call!($f));
+ };
+}
+
macro_rules! preceded {
($i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => {
match tuple!($i, $submac!($($args)*), $submac2!($($args2)*)) {