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

Method scanPatternModifiers

internal/scanner/regexp.go:354–374  ·  view source on GitHub ↗
(currFlags regularExpressionFlags)

Source from the content-addressed store, hash-verified

352}
353
354func (p *regExpParser) scanPatternModifiers(currFlags regularExpressionFlags) regularExpressionFlags {
355 for p.pos() < p.end {
356 ch, size := utf8.DecodeRuneInString(p.text()[p.pos():])
357 if ch == utf8.RuneError || !IsIdentifierPart(ch) {
358 break
359 }
360 flag, ok := charCodeToRegExpFlag[ch]
361 if !ok {
362 p.error(diagnostics.Unknown_regular_expression_flag, p.pos(), size)
363 } else if currFlags&flag != 0 {
364 p.error(diagnostics.Duplicate_regular_expression_flag, p.pos(), size)
365 } else if flag&regularExpressionFlagsModifiers == 0 {
366 p.error(diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, p.pos(), size)
367 } else {
368 currFlags |= flag
369 p.scanner.checkRegularExpressionFlagAvailability(flag, p.pos(), size)
370 }
371 p.incPos(size)
372 }
373 return currFlags
374}
375
376// AtomEscape ::=
377//

Callers 1

scanAlternativeMethod · 0.95

Calls 6

posMethod · 0.95
textMethod · 0.95
errorMethod · 0.95
incPosMethod · 0.95
IsIdentifierPartFunction · 0.85

Tested by

no test coverage detected