string processes the String token at the current position. The lexer *must* know the next token is a String before calling.
()
| 282 | // string processes the String token at the current position. |
| 283 | // The lexer *must* know the next token is a String before calling. |
| 284 | func (l *lexer) string() { |
| 285 | tok := &Token{Type: String, Range: Range{Start: l.pos, End: l.pos}} |
| 286 | if r := l.next(); r != '"' { |
| 287 | log.Fatalf("lexer expected '\"', got '%v'", r) |
| 288 | return |
| 289 | } |
| 290 | escape := false |
| 291 | for l.e == nil { |
| 292 | switch l.next() { |
| 293 | case '"': |
| 294 | if !escape { |
| 295 | tok.Range.End = l.pos |
| 296 | l.toks = append(l.toks, tok) |
| 297 | return |
| 298 | } |
| 299 | case '\\': |
| 300 | escape = !escape |
| 301 | default: |
| 302 | escape = false |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | // operator processes the Operator token at the current position. |
| 308 | // The lexer *must* know the next token is a Operator before calling. |
no test coverage detected