mirror of
https://github.com/TheM1Stery/izanami.git
synced 2025-04-19 16:31:11 +00:00
feat: add multi-line comments
Challenge 4 of fourth chapter 'Scanner'
This commit is contained in:
parent
3357899307
commit
0b437fe5e1
@ -92,6 +92,19 @@ impl Scanner {
|
||||
self.advance();
|
||||
}
|
||||
}
|
||||
'/' if self.peek_and_match('*') => {
|
||||
while self.peek().is_some_and(|c| c != '*')
|
||||
&& self.peek_double().is_some_and(|c| c != '/')
|
||||
{
|
||||
if self.peek().is_some_and(|c| c == '\n') {
|
||||
self.line += 1;
|
||||
}
|
||||
self.advance();
|
||||
}
|
||||
// advance twice to get rid of */
|
||||
self.advance();
|
||||
self.advance();
|
||||
}
|
||||
'/' => self.add_token(TokenType::Slash),
|
||||
'"' => error = self.string(),
|
||||
' ' | '\r' | '\t' => (),
|
||||
|
Loading…
Reference in New Issue
Block a user