Class: IV::Phonic::AST::Declaration
Instance Method Summary collapse
-
#initialize(parent, stmt) ⇒ Declaration
constructor
A new instance of Declaration.
- #to_source(lv) ⇒ Object
Methods inherited from Node
#begin_position, #end_position, #program, #source
Constructor Details
#initialize(parent, stmt) ⇒ Declaration
Returns a new instance of Declaration.
109 110 111 112 113 114 115 116 117 |
# File 'lib/iv/phonic/ast.rb', line 109 def initialize parent, stmt super parent, stmt @name = Identifier.new self, stmt[:name] if stmt[:expr] @expr = Expression.as self, stmt[:expr] else @expr = nil end end |
Instance Method Details
#to_source(lv) ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/iv/phonic/ast.rb', line 118 def to_source lv if @expr "#{@name.to_source lv} = #{@expr.to_source lv}" else "#{@name.to_source lv}" end end |