add multiline block comments

This commit is contained in:
Luna 2019-05-31 22:45:23 -03:00
parent bba969922f
commit 756f85d77d

View file

@ -272,6 +272,19 @@ pub const Scanner = struct {
// consume comments // consume comments
if (self.match('/')) { if (self.match('/')) {
while (self.peek() != '\n' and !self.isAtEnd()) { while (self.peek() != '\n' and !self.isAtEnd()) {
_ = self.advance();
}
} else if (self.match('*')) {
// multiline block comments are messier to work with, but
// we can still do it!
while (true) {
if (self.isAtEnd()) break;
// check '*/'
if (self.peek() == '*' and self.peekNext() == '/') {
self.current += 2;
break;
}
_ = self.advance(); _ = self.advance();
} }
} else { } else {