()
| 1115 | } |
| 1116 | |
| 1117 | func (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 | } |
no test coverage detected