()
| 392 | } |
| 393 | |
| 394 | func (p *Parser) parsePrimary() Node { |
| 395 | token := p.current |
| 396 | |
| 397 | if token.Is(Operator) { |
| 398 | if op, ok := operator.Unary[token.Value]; ok { |
| 399 | p.next() |
| 400 | expr := p.parseExpression(op.Precedence) |
| 401 | node := p.createNode(&UnaryNode{ |
| 402 | Operator: token.Value, |
| 403 | Node: expr, |
| 404 | }, token.Location) |
| 405 | if node == nil { |
| 406 | return nil |
| 407 | } |
| 408 | return p.parsePostfixExpression(node) |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | if token.Is(Bracket, "(") { |
| 413 | p.next() |
| 414 | expr := p.parseSequenceExpression() |
| 415 | p.expect(Bracket, ")") // "an opened parenthesis is not properly closed" |
| 416 | return p.parsePostfixExpression(expr) |
| 417 | } |
| 418 | |
| 419 | if p.depth > 0 { |
| 420 | if token.Is(Operator, "#") || token.Is(Operator, ".") { |
| 421 | name := "" |
| 422 | if token.Is(Operator, "#") { |
| 423 | p.next() |
| 424 | if p.current.Is(Identifier) { |
| 425 | name = p.current.Value |
| 426 | p.next() |
| 427 | } |
| 428 | } |
| 429 | node := p.createNode(&PointerNode{Name: name}, token.Location) |
| 430 | if node == nil { |
| 431 | return nil |
| 432 | } |
| 433 | return p.parsePostfixExpression(node) |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | if token.Is(Operator, "::") { |
| 438 | p.next() |
| 439 | token = p.current |
| 440 | p.expect(Identifier) |
| 441 | return p.parsePostfixExpression(p.parseCall(token, []Node{}, false)) |
| 442 | } |
| 443 | |
| 444 | return p.parseSecondary() |
| 445 | } |
| 446 | |
| 447 | func (p *Parser) parseSecondary() Node { |
| 448 | var node Node |
no test coverage detected