Class: Idl::IfSyntaxNode
- Inherits:
-
SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- SyntaxNode
- Idl::IfSyntaxNode
- Defined in:
- lib/idlc/ast.rb
Instance Method Summary collapse
Methods inherited from Treetop::Runtime::SyntaxNode
#set_input_file, #set_input_file_unless_already_set, #space?
Instance Method Details
#to_ast ⇒ Object
9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 |
# File 'lib/idlc/ast.rb', line 9015 def to_ast if_body_stmts = T.let([], T::Array[StatementAst]) send(:if_body).elements.each do |e| if_body_stmts << e.e.to_ast end eifs = T.let([], T::Array[ElseIfAst]) unless send(:elseifs).empty? send(:elseifs).elements.each do |eif| stmts = [] eif.body.elements.each do |e| stmts << e.e.to_ast end elseif_body = IfBodyAst.new(input, eif.body.interval, stmts) eifs << ElseIfAst.new(input, eif.interval, elseif_body.interval, eif.expression.to_ast, elseif_body.stmts) end end final_else_stmts = T.let([], T::Array[StatementAst]) unless send(:final_else).empty? send(:final_else).body.elements.each do |e| final_else_stmts << e.e.to_ast end end if_body_ast = IfBodyAst.new(input, send(:if_body).interval, if_body_stmts) final_else_ast = if send(:final_else).empty? IfBodyAst.new(input, 0..0, final_else_stmts) else IfBodyAst.new(input, send(:final_else).body.interval, final_else_stmts) end ast = IfAst.new(input, interval, send(:if_cond).to_ast, if_body_ast, eifs, final_else_ast) ast end |