From 3cfed0d0e18c1a74fcc14d70229290c1434ab0d9 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Sun, 13 Jan 2019 14:31:04 -0600 Subject: [PATCH] FEATURE: Better error reporting using must!. Some errors around punctuation were less than helpful. This should improve that situation somewhat. --- src/parse/mod.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 839e6ce..e4b3079 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -214,8 +214,8 @@ make_fn!( do_each!( field => wrap_err!(either!(match_type!(BOOLEAN), match_type!(BAREWORD), match_type!(STR)), "Field names must be a bareword or a string."), - _ => punct!("="), - value => expression, + _ => must!(punct!("=")), + value => must!(expression), (field, value) ) ); @@ -381,14 +381,14 @@ fn module_expression(input: SliceIter) -> Result, Expres let parsed = do_each!(input, pos => pos, _ => word!("module"), - _ => punct!("{"), + _ => must!(punct!("{")), arglist => trace_parse!(optional!(field_list)), _ => optional!(punct!(",")), - _ => punct!("}"), - _ => punct!("=>"), - _ => punct!("{"), + _ => must!(punct!("}")), + _ => must!(punct!("=>")), + _ => must!(punct!("{")), stmt_list => trace_parse!(repeat!(statement)), - _ => punct!("}"), + _ => must!(punct!("}")), (pos, arglist, stmt_list) ); match parsed { @@ -412,10 +412,10 @@ fn macro_expression(input: SliceIter) -> Result, Express let parsed = do_each!(input, pos => pos, _ => word!("macro"), - _ => punct!("("), + _ => must!(punct!("(")), arglist => trace_parse!(optional!(arglist)), - _ => punct!(")"), - _ => punct!("=>"), + _ => must!(punct!(")")), + _ => must!(punct!("=>")), map => trace_parse!(tuple), (pos, arglist, map) ); @@ -502,9 +502,9 @@ make_fn!( do_each!( tmpl => match_type!(STR), _ => punct!("%"), - _ => punct!("("), + _ => must!(punct!("(")), args => separated!(punct!(","), trace_parse!(expression)), - _ => punct!(")"), + _ => must!(punct!(")")), (tuple_to_format(tmpl, args)) ) ); @@ -514,8 +514,8 @@ make_fn!( do_each!( pos => pos, _ => word!("include"), - typ => match_type!(BAREWORD), - path => match_type!(STR), + typ => must!(match_type!(BAREWORD)), + path => must!(match_type!(STR)), (Expression::Include(IncludeDef{ pos: pos, typ: typ,