Class: RLTK::Parser::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/rltk/parser.rb

Overview

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).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEnvironment

Instantiate a new Environment object.



1240
1241
1242
# File 'lib/rltk/parser.rb', line 1240

def initialize
	self.reset
end

Instance Attribute Details

#errorsArray<Object> (readonly)

A list of all objects added using the error method.

Returns:

  • (Array<Object>)


1237
1238
1239
# File 'lib/rltk/parser.rb', line 1237

def errors
  @errors
end

#heBoolean

Indicates if an error was encountered and handled.

Returns:

  • (Boolean)


1232
1233
1234
# File 'lib/rltk/parser.rb', line 1232

def he
  @he
end

Instance Method Details

#error(o) ⇒ void

This method returns an undefined value.

Adds an object to the list of errors.



1247
1248
1249
# File 'lib/rltk/parser.rb', line 1247

def error(o)
	@errors << o
end

#pos(n) ⇒ StreamPosition

Returns a StreamPosition object for the symbol at location n, indexed from zero.

Parameters:

  • n (Integer)

    Index for symbol position.

Returns:



1257
1258
1259
# File 'lib/rltk/parser.rb', line 1257

def pos(n)
	@positions[n]
end

#resetvoid

This method returns an undefined value.

Reset any variables that need to be re-initialized between parse calls.



1265
1266
1267
1268
# File 'lib/rltk/parser.rb', line 1265

def reset
	@errors	= Array.new
	@he		= false
end

#set_positions(positions) ⇒ Array<StreamPosition>

Setter for the positions array.

Parameters:

Returns:



1275
1276
1277
# File 'lib/rltk/parser.rb', line 1275

def set_positions(positions)
	@positions = positions
end