Class: Twig::ExpressionParser::Infix::Arrow

Inherits:
Twig::ExpressionParser::InfixExpressionParser show all
Defined in:
lib/twig/expression_parser/infix/arrow.rb

Constant Summary

Constants inherited from Twig::ExpressionParser::InfixExpressionParser

Twig::ExpressionParser::InfixExpressionParser::LEFT, Twig::ExpressionParser::InfixExpressionParser::RIGHT

Instance Method Summary collapse

Methods inherited from Twig::ExpressionParser::InfixExpressionParser

#left?, #right?, #type

Methods inherited from Base

#aliases, #to_s, #type

Instance Method Details

#associativityObject



25
26
27
# File 'lib/twig/expression_parser/infix/arrow.rb', line 25

def associativity
  LEFT
end

#descriptionObject



17
18
19
# File 'lib/twig/expression_parser/infix/arrow.rb', line 17

def description
  'Arrow function (x => expr)'
end

#nameObject



13
14
15
# File 'lib/twig/expression_parser/infix/arrow.rb', line 13

def name
  '=>'
end

#parse(parser, left, token) ⇒ Object



7
8
9
10
11
# File 'lib/twig/expression_parser/infix/arrow.rb', line 7

def parse(parser, left, token)
  # As the expression of the arrow function is independent from the current precedence,
  # we want a precedence of 0
  Node::Expression::ArrowFunction.new(parser.parse_expression, left, token.lineno)
end

#precedenceObject



21
22
23
# File 'lib/twig/expression_parser/infix/arrow.rb', line 21

def precedence
  250
end