Class: Riml::Compiler::ForNodeVisitor
- Defined in:
- lib/compiler.rb
Instance Method Summary collapse
Methods inherited from Visitor
Constructor Details
This class inherits a constructor from Riml::Compiler::Visitor
Instance Method Details
#compile(node) ⇒ Object
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
# File 'lib/compiler.rb', line 624 def compile(node) if node.variables node.variables.parent_node = node node.variables.each {|v| v.scope_modifier = ""} node.variables.accept( visitor_for_node( node.variables, :propagate_up_tree => false ) ) node.compiled_output = "for #{node.variables.compiled_output} in " else node.compiled_output = "for #{node.variable} in " end node.in_expression.parent_node = node node.in_expression.force_newline = true node.in_expression.accept(visitor_for_node(node.in_expression)) node.expressions.parent_node = node node.expressions.accept(EstablishScopeVisitor.new(:scope => node.to_scope)) node.expressions.accept(NodesVisitor.new :propagate_up_tree => false) body = node.expressions.compiled_output body.each_line do |line| node.compiled_output << node.indent + line end node.compiled_output << "endfor\n" end |