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.
main
anna 2 years ago
parent 68254757a3
commit 50b6da41dd
Signed by: fef
GPG Key ID: EC22E476DC2D3D84

@ -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);

Loading…
Cancel
Save