()
| 566 | // https://tc39.github.io/ecma262/#sec-punctuators |
| 567 | |
| 568 | private scanPunctuator(): RawToken { |
| 569 | const start = this.index; |
| 570 | |
| 571 | // Check for most common single-character punctuators. |
| 572 | let str = this.source[this.index]; |
| 573 | switch (str) { |
| 574 | |
| 575 | case '(': |
| 576 | case '{': |
| 577 | if (str === '{') { |
| 578 | this.curlyStack.push('{'); |
| 579 | } |
| 580 | ++this.index; |
| 581 | break; |
| 582 | |
| 583 | case '.': |
| 584 | ++this.index; |
| 585 | if (this.source[this.index] === '.' && this.source[this.index + 1] === '.') { |
| 586 | // Spread operator: ... |
| 587 | this.index += 2; |
| 588 | str = '...'; |
| 589 | } |
| 590 | break; |
| 591 | |
| 592 | case '}': |
| 593 | ++this.index; |
| 594 | this.curlyStack.pop(); |
| 595 | break; |
| 596 | case ')': |
| 597 | case ';': |
| 598 | case ',': |
| 599 | case '[': |
| 600 | case ']': |
| 601 | case ':': |
| 602 | case '?': |
| 603 | case '~': |
| 604 | ++this.index; |
| 605 | break; |
| 606 | |
| 607 | default: |
| 608 | // 4-character punctuator. |
| 609 | str = this.source.substr(this.index, 4); |
| 610 | if (str === '>>>=') { |
| 611 | this.index += 4; |
| 612 | } else { |
| 613 | |
| 614 | // 3-character punctuators. |
| 615 | str = str.substr(0, 3); |
| 616 | if (str === '===' || str === '!==' || str === '>>>' || |
| 617 | str === '<<=' || str === '>>=' || str === '**=') { |
| 618 | this.index += 3; |
| 619 | } else { |
| 620 | |
| 621 | // 2-character punctuators. |
| 622 | str = str.substr(0, 2); |
| 623 | if (str === '&&' || str === '||' || str === '==' || str === '!=' || |
| 624 | str === '+=' || str === '-=' || str === '*=' || str === '/=' || |
| 625 | str === '++' || str === '--' || str === '<<' || str === '>>' || |
no test coverage detected