parser_prefix.go 450 B

1234567891011121314151617181920
  1. package parser
  2. import (
  3. "code.osinet.fr/fgm/waiig15/ast"
  4. )
  5. func (p *Parser) parsePrefixExpression() ast.Expression {
  6. expression := &ast.PrefixExpression{
  7. Token: p.curToken,
  8. Operator: p.curToken.Literal,
  9. }
  10. // Consume the operator token to progress to the prefixed expression.
  11. p.nextToken()
  12. // The precedence is now that of the prefix operator instead of the lowest.
  13. expression.Right = p.parseExpression(PREFIX)
  14. return expression
  15. }