MCPcopy Create free account
hub / github.com/cel-expr/cel-go / parseBytesLiteral

Method parseBytesLiteral

parser/pratt_parser.go:1117–1133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1115}
1116
1117func (p *prattParserWorker) parseBytesLiteral() ast.Expr {
1118 tok := p.nextToken()
1119 id := p.nextID(tok)
1120 text := p.tokenText(tok)
1121 if strings.HasPrefix(text, "b") || strings.HasPrefix(text, "B") {
1122 text = text[1:]
1123 } else if strings.HasPrefix(text, "rb") || strings.HasPrefix(text, "RB") || strings.HasPrefix(text, "rB") || strings.HasPrefix(text, "Rb") {
1124 text = "r" + text[2:]
1125 } else if strings.HasPrefix(text, "br") || strings.HasPrefix(text, "BR") || strings.HasPrefix(text, "bR") || strings.HasPrefix(text, "Br") {
1126 text = text[1:]
1127 }
1128 unescaped, err := unescape(text, true)
1129 if err != nil {
1130 return p.reportError(tok, "%s", err.Error())
1131 }
1132 return p.helper.newLiteralBytes(id, []byte(unescaped))
1133}

Callers 1

parsePrimaryMethod · 0.95

Calls 7

nextTokenMethod · 0.95
nextIDMethod · 0.95
tokenTextMethod · 0.95
reportErrorMethod · 0.95
unescapeFunction · 0.85
newLiteralBytesMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected