MCPcopy Create free account
hub / github.com/andybalholm/cascadia / parseIdentifier

Method parseIdentifier

parser.go:77–97  ·  view source on GitHub ↗

parseIdentifier parses an identifier.

()

Source from the content-addressed store, hash-verified

75
76// parseIdentifier parses an identifier.
77func (p *parser) parseIdentifier() (result string, err error) {
78 startingDash := false
79 if len(p.s) > p.i && p.s[p.i] == '-' {
80 startingDash = true
81 p.i++
82 }
83
84 if len(p.s) <= p.i {
85 return "", errors.New("expected identifier, found EOF instead")
86 }
87
88 if c := p.s[p.i]; !(nameStart(c) || c == '\\') {
89 return "", fmt.Errorf("expected identifier, found %c instead", c)
90 }
91
92 result, err = p.parseName()
93 if startingDash && err == nil {
94 result = "-" + result
95 }
96 return
97}
98
99// parseName parses a name (which is like an identifier, but doesn't have
100// extra restrictions on the first character).

Callers 5

TestParseIdentifierFunction · 0.95
parseTypeSelectorMethod · 0.95
parseClassSelectorMethod · 0.95

Calls 2

parseNameMethod · 0.95
nameStartFunction · 0.85

Tested by 1

TestParseIdentifierFunction · 0.76