lineComment processes the Comment token at the current position. The lexer *must* know the next token is a Comment before calling.
()
| 321 | // lineComment processes the Comment token at the current position. |
| 322 | // The lexer *must* know the next token is a Comment before calling. |
| 323 | func (l *lexer) lineComment() { |
| 324 | tok := &Token{Type: Comment, Range: Range{Start: l.pos, End: l.pos}} |
| 325 | if r := l.next(); r != ';' { |
| 326 | log.Fatalf("lexer expected ';', got '%v'", r) |
| 327 | return |
| 328 | } |
| 329 | for l.e == nil { |
| 330 | s := l.save() |
| 331 | switch l.next() { |
| 332 | case '\n': |
| 333 | l.restore(s) |
| 334 | tok.Range.End = l.pos |
| 335 | l.toks = append(l.toks, tok) |
| 336 | return |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | // newline processes the Newline token at the current position. |
| 342 | // The lexer *must* know the next token is a Newline before calling. |