forked from luna/jorts
add multiline block comments
This commit is contained in:
parent
bba969922f
commit
756f85d77d
1 changed files with 13 additions and 0 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue