Class: RLTK::Parser::Environment
- Inherits:
-
Object
- Object
- RLTK::Parser::Environment
- 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
-
#errors ⇒ Array<Object>
readonly
A list of all objects added using the error method.
-
#he ⇒ Boolean
Indicates if an error was encountered and handled.
Instance Method Summary collapse
-
#error(o) ⇒ void
Adds an object to the list of errors.
-
#initialize ⇒ Environment
constructor
Instantiate a new Environment object.
-
#pos(n) ⇒ StreamPosition
Returns a StreamPosition object for the symbol at location n, indexed from zero.
-
#reset ⇒ void
Reset any variables that need to be re-initialized between parse calls.
-
#set_positions(positions) ⇒ Array<StreamPosition>
Setter for the positions array.
Constructor Details
#initialize ⇒ Environment
Instantiate a new Environment object.
1283 1284 1285 |
# File 'lib/rltk/parser.rb', line 1283 def initialize self.reset end |
Instance Attribute Details
#errors ⇒ Array<Object> (readonly)
A list of all objects added using the error method.
1280 1281 1282 |
# File 'lib/rltk/parser.rb', line 1280 def errors @errors end |
#he ⇒ Boolean
Indicates if an error was encountered and handled.
1275 1276 1277 |
# File 'lib/rltk/parser.rb', line 1275 def he @he end |
Instance Method Details
#error(o) ⇒ void
This method returns an undefined value.
Adds an object to the list of errors.
1290 1291 1292 |
# File 'lib/rltk/parser.rb', line 1290 def error(o) @errors << o end |
#pos(n) ⇒ StreamPosition
Returns a StreamPosition object for the symbol at location n, indexed from zero.
1300 1301 1302 |
# File 'lib/rltk/parser.rb', line 1300 def pos(n) @positions[n] end |
#reset ⇒ void
This method returns an undefined value.
Reset any variables that need to be re-initialized between parse calls.
1308 1309 1310 1311 |
# File 'lib/rltk/parser.rb', line 1308 def reset @errors = Array.new @he = false end |
#set_positions(positions) ⇒ Array<StreamPosition>
Setter for the positions array.
1318 1319 1320 |
# File 'lib/rltk/parser.rb', line 1318 def set_positions(positions) @positions = positions end |