add multiline comment support
This commit is contained in:
parent
1e47b29685
commit
8a9522d954
1 changed files with 21 additions and 8 deletions
|
@ -153,7 +153,7 @@ pub const Scanner = struct {
|
|||
}
|
||||
|
||||
fn peekNext(self: *Scanner) u8 {
|
||||
if (self.current + 1 >= self.source.len) return 0;
|
||||
if (self.current > self.source.len) return 0;
|
||||
return self.source[self.current];
|
||||
}
|
||||
|
||||
|
@ -246,14 +246,27 @@ pub const Scanner = struct {
|
|||
'>' => self.makeMatchToken('=', .GreaterEqual, .Greater),
|
||||
|
||||
'/' => blk: {
|
||||
if (self.peekNext() == '/') {
|
||||
while (self.peek() != '\n' and !self.isAtEnd()) {
|
||||
_ = self.advance();
|
||||
}
|
||||
var next = self.peekNext();
|
||||
switch (next) {
|
||||
'/' => blk2: {
|
||||
while (self.peek() != '\n' and !self.isAtEnd()) {
|
||||
_ = self.advance();
|
||||
}
|
||||
|
||||
break :blk null;
|
||||
} else {
|
||||
break :blk self.makeToken(.Slash);
|
||||
return null;
|
||||
},
|
||||
|
||||
'*' => blk2: {
|
||||
while (self.peek() != '*' or self.peekNext() != '/') {
|
||||
_ = self.advance();
|
||||
}
|
||||
|
||||
// consume the ending slash
|
||||
_ = self.advance();
|
||||
return null;
|
||||
},
|
||||
|
||||
else => break :blk self.makeToken(.Slash),
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue