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

errors[R]

A list of all objects added using the error method.

@return [Array<Object>]

he[RW]

Indicates if an error was encountered and handled.

@return [Boolean]

Public Class Methods

new() click to toggle source

Instantiate a new Environment object.

# File lib/rltk/parser.rb, line 1283
def initialize
        self.reset
end

Public Instance Methods

error(o) click to toggle source

Adds an object to the list of errors.

@return [void]

# File lib/rltk/parser.rb, line 1290
def error(o)
        @errors << o
end
pos(n) click to toggle source

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() click to toggle source

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
set_positions(positions) click to toggle source

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