lib/opulent/compiler.rb in opulent-1.7.11 vs lib/opulent/compiler.rb in opulent-1.8.0

- old
+ new

@@ -40,11 +40,11 @@ # Get special node types from the settings @multi_node = Settings::MULTI_NODE @inline_node = Settings::INLINE_NODE # Initialize amble object - @template = [[:preamble]] + @template = [] # Incrmental counters @current_variable_count = 0 @current_attribute = 0 @current_extension = 0 @@ -52,17 +52,19 @@ # The node stack is needed to keep track of all the visited nodes # from the current branch level @node_stack = [] - # The sibling stack keeps track of the sibling count from the current - # branch level being generated - @sibling_stack = [] - # Whenever we enter a definition compilation, add the provided blocks to # the current block stack. When exiting a definition, remove blocks. @block_stack = [] + + # Remember last compiled node, required for pretty printing purposes + @sibling_stack = [[[:root, nil]]] + + # Set parent node, required for pretty printing + @parent_stack = [] end # Compile input nodes, replace them with their definitions and # # @param root_node [Array] Root node containing all document nodes @@ -71,11 +73,10 @@ # Compiler generated code @code = '' @generator = '' @definitions = definitions - # Set initial parent, from which we start generating code - @sibling_stack << root_node[@children].size + @template << [:preamble] # Write all node definitions as method defs @definitions.each do |_, node| define node end