class RLTK::Parser::Environment
All actions passed to Parser.producation and Parser.clause
are evaluated inside an instance of the Environment
class or its subclass (which must have the same name).
Attributes
A list of all objects added using the error method.
@return [Array<Object>]
Indicates if an error was encountered and handled.
@return [Boolean]
Public Class Methods
Instantiate a new Environment
object.
# File lib/rltk/parser.rb, line 1283 def initialize self.reset end
Public Instance Methods
Adds an object to the list of errors.
@return [void]
# File lib/rltk/parser.rb, line 1290 def error(o) @errors << o end
Returns a StreamPosition
object for the symbol at location n, indexed from zero.
@param [Integer] n Index for symbol position.
@return [StreamPosition] Position of symbol at index n.
# File lib/rltk/parser.rb, line 1300 def pos(n) @positions[n] end
Reset any variables that need to be re-initialized between parse calls.
@return [void]
# File lib/rltk/parser.rb, line 1308 def reset @errors = Array.new @he = false end
Setter for the positions array.
@param [Array<StreamPosition>] positions
@return [Array<StreamPosition>] The same array of positions.
# File lib/rltk/parser.rb, line 1318 def set_positions(positions) @positions = positions end