(tok token, allowQuoted bool, isQuoted *bool)
| 399 | } |
| 400 | |
| 401 | func (p *prattParserWorker) normalizeIdent(tok token, allowQuoted bool, isQuoted *bool) string { |
| 402 | if isQuoted != nil { |
| 403 | *isQuoted = false |
| 404 | } |
| 405 | text := p.tokenText(tok) |
| 406 | if len(text) == 0 { |
| 407 | return "" |
| 408 | } |
| 409 | if text[0] == '`' { |
| 410 | if isQuoted != nil { |
| 411 | *isQuoted = true |
| 412 | } |
| 413 | if !allowQuoted { |
| 414 | p.reportError(tok, "unexpected quoted identifier") |
| 415 | return "" |
| 416 | } |
| 417 | if !p.enableIdentEscapeSyntax { |
| 418 | p.reportError(tok, "unsupported syntax: '`'") |
| 419 | } |
| 420 | if len(text) < 2 || text[len(text)-1] != '`' { |
| 421 | p.reportError(tok, "unterminated quoted identifier") |
| 422 | return "" |
| 423 | } |
| 424 | // Validate the quoted identifier syntax: |
| 425 | // ESC_IDENTIFIER : '`' (LETTER | DIGIT | '_' | '.' | '-' | '/' | ' ')+ '`'; |
| 426 | inner := text[1 : len(text)-1] |
| 427 | if len(inner) == 0 { |
| 428 | p.reportError(tok, "unexpected quoted identifier") |
| 429 | return "" |
| 430 | } |
| 431 | for _, c := range inner { |
| 432 | if !isAlpha(c) && !isDigit(c) && c != '_' && c != '.' && c != '-' && c != '/' && c != ' ' { |
| 433 | if c == '@' && p.enableCallEscapeSyntax { |
| 434 | continue |
| 435 | } |
| 436 | p.reportError(tok, "unexpected quoted identifier") |
| 437 | return "" |
| 438 | } |
| 439 | } |
| 440 | return inner |
| 441 | } |
| 442 | return text |
| 443 | } |
| 444 | |
| 445 | func (p *prattParserWorker) parse() ast.Expr { |
| 446 | expr := p.parseExpr() |
no test coverage detected