ClassSetCharacter ::= | SourceCharacter -- ClassSetSyntaxCharacter -- ClassSetReservedDoublePunctuator | '\' (CharacterEscape | ClassSetReservedPunctuator | 'b')
()
| 806 | // | SourceCharacter -- ClassSetSyntaxCharacter -- ClassSetReservedDoublePunctuator |
| 807 | // | '\' (CharacterEscape | ClassSetReservedPunctuator | 'b') |
| 808 | func (p *regExpParser) scanClassSetCharacter() string { |
| 809 | ch := p.char() |
| 810 | if ch == '\\' { |
| 811 | p.incPos(1) |
| 812 | innerCh := p.char() |
| 813 | switch innerCh { |
| 814 | case 'b': |
| 815 | p.incPos(1) |
| 816 | return "\b" |
| 817 | case '&', '-', '!', '#', '%', ',', ':', ';', '<', '=', '>', '@', '`', '~': |
| 818 | p.incPos(1) |
| 819 | return string(innerCh) |
| 820 | default: |
| 821 | return p.scanCharacterEscape(false /*atomEscape*/) |
| 822 | } |
| 823 | } else if p.pos()+1 < p.end && ch == p.charAt(p.pos()+1) { |
| 824 | switch ch { |
| 825 | case '&', '!', '#', '%', '*', '+', ',', '.', ':', ';', '<', '=', '>', '?', '@', '`', '~': |
| 826 | p.error(diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, p.pos(), 2) |
| 827 | p.incPos(2) |
| 828 | return p.text()[p.pos()-2 : p.pos()] |
| 829 | } |
| 830 | } |
| 831 | switch ch { |
| 832 | case '/', '(', ')', '[', ']', '{', '}', '-', '|': |
| 833 | p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos(), 1, string(ch)) |
| 834 | p.incPos(1) |
| 835 | return string(ch) |
| 836 | } |
| 837 | return p.scanSourceCharacter() |
| 838 | } |
| 839 | |
| 840 | // ClassAtom ::= |
| 841 | // |
no test coverage detected