()
| 143 | } |
| 144 | |
| 145 | func (p *Parser) parseIdentOrString() (*Ident, error) { |
| 146 | switch { |
| 147 | case p.matchTokenKind(TokenKindIdent): |
| 148 | return p.parseIdent() |
| 149 | case p.matchTokenKind(TokenKindString): |
| 150 | lastToken := p.last() |
| 151 | _ = p.lexer.consumeToken() |
| 152 | return &Ident{ |
| 153 | NamePos: lastToken.Pos, |
| 154 | NameEnd: lastToken.End, |
| 155 | Name: lastToken.String, |
| 156 | QuoteType: SingleQuote, // Treat string literals as single-quoted identifiers |
| 157 | }, nil |
| 158 | default: |
| 159 | return nil, fmt.Errorf("expected <ident> or <string>, but got %q", p.lastTokenKind()) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | func (p *Parser) tryParseDotIdent(_ Pos) (*Ident, error) { |
| 164 | if p.tryConsumeTokenKind(TokenKindDot) == nil { |
no test coverage detected