From 50b6da41dd9cb0e04f4194f5e447c67e5b4a5e87 Mon Sep 17 00:00:00 2001 From: fef Date: Mon, 11 Jul 2022 16:08:11 +0200 Subject: [PATCH] lex: ignore comments This is a cheap hack to just omit comments from the token stream for now. I doubt they will ever be used at all, so their existence would just mean extra work for the parser. --- src/lex/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lex/mod.rs b/src/lex/mod.rs index b8274d8..ca2fdb8 100644 --- a/src/lex/mod.rs +++ b/src/lex/mod.rs @@ -67,7 +67,12 @@ impl Iterator for Lexer<'_> { '/' => self.token_ok(token::Kind::Slash), '%' => self.token_ok(token::Kind::Percent), - '#' => self.read_comment(), + '#' => { + self.read_comment(); + // we don't need comments for now and they would + // only confuse the parser so let's just Not + self.next()? + } '"' => self.read_string_literal(), '0' => self.read_prefix_int_literal(), _c @ '1'..='9' => self.read_int_literal(10), @@ -158,6 +163,7 @@ impl<'a> Lexer<'a> { self.cursor.chop(); let mut raw = String::new(); for c in &mut self.cursor { + // TODO: string escape sequences are a thing if c == '"' { self.cursor.chop(); return self.token_raw_ok(token::Kind::StringLiteral, raw);