refactor(parser): get rid of tailcall in favor of chain

Signed-off-by: Charlotte Meyer <dev@buffet.sh>
This commit is contained in:
buffet 2022-11-06 19:25:16 +00:00
parent 4a9d49fbd8
commit f215335627

View file

@ -114,15 +114,6 @@ impl Iterator for Parser<'_> {
}};
}
macro_rules! tailcall {
($rule:expr) => {{
use NodeKind::*;
self.stack.pop();
self.stack.push($rule);
Some(ParseEvent::StartNode($rule))
}};
}
macro_rules! leaf {
($type:expr $(, $mode:ident)?) => {{
use NodeKind::*;
@ -200,7 +191,7 @@ impl Iterator for Parser<'_> {
Newlines => leaf!(Newlines),
Comment => leaf!(Comment),
PlainText | DoubleQuote | OpeningParenthesis | EscapedChar => {
tailcall!(Command)
chain!(call!(Command), ret!())
}
Semicolon => chain_buf!(chain!(error!(UnexpectedSemicolon), ret!()), ret!()),
Pipe => chain!(error!(UnexpectedPipe), ret!()),