mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-25 18:49:50 -04:00
FEATURE: Better error reporting using must!.
Some errors around punctuation were less than helpful. This should improve that situation somewhat.
This commit is contained in:
parent
c4505ac2ab
commit
3cfed0d0e1
@ -214,8 +214,8 @@ make_fn!(
|
|||||||
do_each!(
|
do_each!(
|
||||||
field => wrap_err!(either!(match_type!(BOOLEAN), match_type!(BAREWORD), match_type!(STR)),
|
field => wrap_err!(either!(match_type!(BOOLEAN), match_type!(BAREWORD), match_type!(STR)),
|
||||||
"Field names must be a bareword or a string."),
|
"Field names must be a bareword or a string."),
|
||||||
_ => punct!("="),
|
_ => must!(punct!("=")),
|
||||||
value => expression,
|
value => must!(expression),
|
||||||
(field, value)
|
(field, value)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -381,14 +381,14 @@ fn module_expression(input: SliceIter<Token>) -> Result<SliceIter<Token>, Expres
|
|||||||
let parsed = do_each!(input,
|
let parsed = do_each!(input,
|
||||||
pos => pos,
|
pos => pos,
|
||||||
_ => word!("module"),
|
_ => word!("module"),
|
||||||
_ => punct!("{"),
|
_ => must!(punct!("{")),
|
||||||
arglist => trace_parse!(optional!(field_list)),
|
arglist => trace_parse!(optional!(field_list)),
|
||||||
_ => optional!(punct!(",")),
|
_ => optional!(punct!(",")),
|
||||||
_ => punct!("}"),
|
_ => must!(punct!("}")),
|
||||||
_ => punct!("=>"),
|
_ => must!(punct!("=>")),
|
||||||
_ => punct!("{"),
|
_ => must!(punct!("{")),
|
||||||
stmt_list => trace_parse!(repeat!(statement)),
|
stmt_list => trace_parse!(repeat!(statement)),
|
||||||
_ => punct!("}"),
|
_ => must!(punct!("}")),
|
||||||
(pos, arglist, stmt_list)
|
(pos, arglist, stmt_list)
|
||||||
);
|
);
|
||||||
match parsed {
|
match parsed {
|
||||||
@ -412,10 +412,10 @@ fn macro_expression(input: SliceIter<Token>) -> Result<SliceIter<Token>, Express
|
|||||||
let parsed = do_each!(input,
|
let parsed = do_each!(input,
|
||||||
pos => pos,
|
pos => pos,
|
||||||
_ => word!("macro"),
|
_ => word!("macro"),
|
||||||
_ => punct!("("),
|
_ => must!(punct!("(")),
|
||||||
arglist => trace_parse!(optional!(arglist)),
|
arglist => trace_parse!(optional!(arglist)),
|
||||||
_ => punct!(")"),
|
_ => must!(punct!(")")),
|
||||||
_ => punct!("=>"),
|
_ => must!(punct!("=>")),
|
||||||
map => trace_parse!(tuple),
|
map => trace_parse!(tuple),
|
||||||
(pos, arglist, map)
|
(pos, arglist, map)
|
||||||
);
|
);
|
||||||
@ -502,9 +502,9 @@ make_fn!(
|
|||||||
do_each!(
|
do_each!(
|
||||||
tmpl => match_type!(STR),
|
tmpl => match_type!(STR),
|
||||||
_ => punct!("%"),
|
_ => punct!("%"),
|
||||||
_ => punct!("("),
|
_ => must!(punct!("(")),
|
||||||
args => separated!(punct!(","), trace_parse!(expression)),
|
args => separated!(punct!(","), trace_parse!(expression)),
|
||||||
_ => punct!(")"),
|
_ => must!(punct!(")")),
|
||||||
(tuple_to_format(tmpl, args))
|
(tuple_to_format(tmpl, args))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -514,8 +514,8 @@ make_fn!(
|
|||||||
do_each!(
|
do_each!(
|
||||||
pos => pos,
|
pos => pos,
|
||||||
_ => word!("include"),
|
_ => word!("include"),
|
||||||
typ => match_type!(BAREWORD),
|
typ => must!(match_type!(BAREWORD)),
|
||||||
path => match_type!(STR),
|
path => must!(match_type!(STR)),
|
||||||
(Expression::Include(IncludeDef{
|
(Expression::Include(IncludeDef{
|
||||||
pos: pos,
|
pos: pos,
|
||||||
typ: typ,
|
typ: typ,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user