lib/liquidscript/compiler/base.rb in liquidscript-0.6.1 vs lib/liquidscript/compiler/base.rb in liquidscript-0.6.2

- old
+ new

@@ -15,12 +15,13 @@ # @param scanner [Scanner, #each] the scanner. Used to # manage the tokens. This could be stubbed out, if # the #each function returns an Enumerator, which yields # {Scanner::Token}s. def initialize(scanner) - @scanner = scanner.each - @action = Action.new + @scanner = scanner + @iterator = scanner.each + @action = Action.new reset! end # Returns the top set. If the variable @top isn't set by the # inheriting class, then it defaults to the value of an array. @@ -69,30 +70,30 @@ # raises a {StopIteration} error, it returns the value of # {#scanner_nil} instead. # # @return [#type?, Blank] def pop - @scanner.next + @iterator.next rescue StopIteration scanner_nil end # Peeks at the next argument on the scanner. If the call # raises a {StopIteration} error, it returns the value of # {#scanner_nil} instead. # # @return [#type, Blank] def peek - @scanner.peek + @iterator.peek rescue StopIteration scanner_nil end # Resets the state of the compiler. # # @return [void] def reset! - @scanner.rewind + @iterator.rewind end alias_method :rewind, :reset! end