Class: Yadriggy::Lambda
- Inherits:
-
Block
- Object
- ASTnode
- Parameters
- Block
- Yadriggy::Lambda
- Defined in:
- lib/yadriggy/ast.rb
Overview
A lambda expression such as -> (x) {x + 1}
.
lambda {|x|x+1}
is parsed as a call to lambda
with
an argument {|x|x + 1}
. So it is an instance of Call.
Instance Attribute Summary
Attributes inherited from Block
Attributes inherited from Parameters
#block_param, #keywords, #optionals, #params, #params_after_rest, #rest_of_keywords, #rest_of_params
Attributes inherited from ASTnode
Class Method Summary collapse
Instance Method Summary collapse
-
#accept(evaluator) ⇒ void
A method for Visitor pattern.
-
#initialize(sexp) ⇒ Lambda
constructor
A new instance of Lambda.
Methods inherited from Block
Methods inherited from Parameters
Methods included from AstHelper
#has_tag?, #to_node, #to_nodes
Methods inherited from ASTnode
#add_child, #add_children, #const_value, #const_value_in_class, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string, #value, #value_in_class
Constructor Details
#initialize(sexp) ⇒ Lambda
Returns a new instance of Lambda.
1422 1423 1424 1425 1426 1427 1428 1429 |
# File 'lib/yadriggy/ast.rb', line 1422 def initialize(sexp) if sexp[1][0] == :paren params = sexp[1][1] else params = sexp[1] end initialize_vars(params, sexp[2]) end |
Class Method Details
.tag ⇒ Object
1420 |
# File 'lib/yadriggy/ast.rb', line 1420 def self.tag() :lambda end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
1434 1435 1436 |
# File 'lib/yadriggy/ast.rb', line 1434 def accept(evaluator) evaluator.lambda_expr(self) end |