diff options
Diffstat (limited to 'dhall/src')
-rw-r--r-- | dhall/src/lib.rs | 1 | ||||
-rw-r--r-- | dhall/src/parser.rs | 10 |
2 files changed, 8 insertions, 3 deletions
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index 9dbd3a6..7cc96e1 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -1,4 +1,5 @@ #![feature(box_patterns)] +#![feature(trace_macros)] pub mod context; mod core; diff --git a/dhall/src/parser.rs b/dhall/src/parser.rs index 6c7c0c5..ba96a09 100644 --- a/dhall/src/parser.rs +++ b/dhall/src/parser.rs @@ -135,7 +135,7 @@ macro_rules! match_iter { }; // Check no elements remain - (@match 0, $iter:expr) => { + (@match 0, $iter:expr $(,)*) => { match $iter.next() { Some(_) => break Err(IterMatchError::TooManyItems), None => {}, @@ -190,7 +190,11 @@ macro_rules! match_children { (@collect, $pairs:expr, ($($args:tt)*), $body:expr, ($($acc:tt)*), ($x:ident* : $ty:ident, $($rest:tt)*)) => { match_children!(@collect, $pairs, ($($args)*), $body, ($($acc)*, $x??), ($($rest)*)) }; - (@collect, $pairs:expr, ($($args:tt)*), $body:expr, (,$($acc:tt)*), ()) => { + // Catch extra comma if exists + (@collect, $pairs:expr, ($($args:tt)*), $body:expr, (,$($acc:tt)*), ($(,)*)) => { + match_children!(@collect, $pairs, ($($args)*), $body, ($($acc)*), ()) + }; + (@collect, $pairs:expr, ($($args:tt)*), $body:expr, ($($acc:tt)*), ($(,)*)) => { let matched: Result<_, IterMatchError<ParseError>> = match_iter!(@get_err, $pairs; ($($acc)*) => { match_children!(@parse, $pairs, $($args)*); @@ -228,7 +232,7 @@ macro_rules! match_children { }; match_children!(@parse, $pairs $($rest)*); }; - (@parse, $pairs:expr) => {}; + (@parse, $pairs:expr $(,)*) => {}; // Entrypoint ($pair:expr; $( ($($args:tt)*) => $body:expr ),* $(,)*) => { |