From f2153356278c34de3a5893618c51803d382cc213 Mon Sep 17 00:00:00 2001 From: Charlotte Meyer Date: Sun, 6 Nov 2022 19:25:16 +0000 Subject: [PATCH] refactor(parser): get rid of tailcall in favor of chain Signed-off-by: Charlotte Meyer --- crates/oyster_parser/src/parser.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/crates/oyster_parser/src/parser.rs b/crates/oyster_parser/src/parser.rs index fc371dc..bbf06bc 100644 --- a/crates/oyster_parser/src/parser.rs +++ b/crates/oyster_parser/src/parser.rs @@ -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!()),