MCPcopy Create free account
hub / github.com/microsoft/typescript-go / scanClassSetOperand

Method scanClassSetOperand

internal/scanner/regexp.go:748–777  ·  view source on GitHub ↗

ClassSetOperand ::= | '[' ClassSetExpression ']' | '\' CharacterClassEscape | '\q{' ClassStringDisjunctionContents '}' | ClassSetCharacter

()

Source from the content-addressed store, hash-verified

746// | '\q{' ClassStringDisjunctionContents '}'
747// | ClassSetCharacter
748func (p *regExpParser) scanClassSetOperand() string {
749 p.mayContainStrings = false
750 switch p.char() {
751 case '[':
752 p.incPos(1)
753 p.scanClassSetExpression()
754 p.scanExpectedChar(']')
755 return ""
756 case '\\':
757 p.incPos(1)
758 if p.scanCharacterClassEscape() {
759 return ""
760 } else if p.char() == 'q' {
761 p.incPos(1)
762 if p.char() == '{' {
763 p.incPos(1)
764 p.scanClassStringDisjunctionContents()
765 p.scanExpectedChar('}')
766 return ""
767 } else {
768 p.error(diagnostics.X_q_must_be_followed_by_string_alternatives_enclosed_in_braces, p.pos()-2, 2)
769 return "q"
770 }
771 }
772 p.incPos(-1)
773 fallthrough
774 default:
775 return p.scanClassSetCharacter()
776 }
777}
778
779// ClassStringDisjunctionContents ::= ClassSetCharacter* ('|' ClassSetCharacter*)*
780func (p *regExpParser) scanClassStringDisjunctionContents() {

Callers 2

Calls 9

charMethod · 0.95
incPosMethod · 0.95
scanExpectedCharMethod · 0.95
errorMethod · 0.95
posMethod · 0.95
scanClassSetCharacterMethod · 0.95

Tested by

no test coverage detected