From d4c0633fab1f2cacbae35238c2a1bc30121a2335 Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 23 May 2024 18:06:04 -0400 Subject: [PATCH] Continue implementing comments --- dust-lang/src/parser.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dust-lang/src/parser.rs b/dust-lang/src/parser.rs index d014ece..547e297 100644 --- a/dust-lang/src/parser.rs +++ b/dust-lang/src/parser.rs @@ -14,8 +14,6 @@ pub type ParserInput<'src> = pub type ParserExtra<'src> = extra::Err, SimpleSpan>>; -pub type Comment = String; - pub fn parse<'src>(tokens: &'src [(Token<'src>, SimpleSpan)]) -> Result> { let statements = parser(false) .parse(tokens.spanned((tokens.len()..tokens.len()).into())) @@ -621,7 +619,13 @@ pub fn parser<'src>( .then_ignore(just(Token::Control(Control::Semicolon)).or_not()) }); - statement.clone().repeated().collect() + select_ref! { + Token::Comment(_) => {} + } + .or_not() + .ignore_then(statement) + .repeated() + .collect() } #[cfg(test)]