Skip to content

Commit 39649dd

Browse files
committed
refactor: Call parser
Apply the same code structure as for <parse::Function as PestParse>. The block around the code that produces the value for `args` is useful to bundle up the code for parsing multiple expressions.
1 parent fb57f0c commit 39649dd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/parse.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -782,14 +782,15 @@ impl PestParse for Call {
782782
let span = Span::from(&pair);
783783
let mut it = pair.into_inner();
784784
let name = CallName::parse(it.next().unwrap())?;
785-
let args_pair = it.next().unwrap();
786-
assert!(matches!(args_pair.as_rule(), Rule::call_args));
787-
let args = args_pair
788-
.into_inner()
789-
.map(Expression::parse)
790-
.collect::<Result<Arc<[Expression]>, _>>()?;
785+
let args = {
786+
let pair = it.next().unwrap();
787+
debug_assert!(matches!(pair.as_rule(), Rule::call_args));
788+
pair.into_inner()
789+
.map(Expression::parse)
790+
.collect::<Result<Arc<[Expression]>, RichError>>()?
791+
};
791792

792-
Ok(Call { name, args, span })
793+
Ok(Self { name, args, span })
793794
}
794795
}
795796

0 commit comments

Comments
 (0)