Exception: RLTK::NotInLanguage
- Inherits:
-
StandardError
- Object
- StandardError
- RLTK::NotInLanguage
- Defined in:
- lib/rltk/parser.rb
Overview
A NotInLanguage error is raised whenever there is no valid parse tree for a given token stream. In other words, the input string is not in the defined language.
Instance Attribute Summary collapse
-
#current ⇒ Token
readonly
Token that caused the parser to stop.
-
#remaining ⇒ Array<Token>
readonly
List of tokens that have yet to be seen.
-
#seen ⇒ Array<Token>
readonly
List of tokens that have been successfully parsed.
Instance Method Summary collapse
-
#initialize(seen, current, remaining) ⇒ NotInLanguage
constructor
A new instance of NotInLanguage.
-
#to_s ⇒ String
String representation of the error.
Constructor Details
#initialize(seen, current, remaining) ⇒ NotInLanguage
Returns a new instance of NotInLanguage.
45 46 47 48 49 |
# File 'lib/rltk/parser.rb', line 45 def initialize(seen, current, remaining) @seen = seen @current = current @remaining = remaining end |
Instance Attribute Details
#current ⇒ Token (readonly)
Returns Token that caused the parser to stop.
37 38 39 |
# File 'lib/rltk/parser.rb', line 37 def current @current end |
#remaining ⇒ Array<Token> (readonly)
Returns List of tokens that have yet to be seen.
40 41 42 |
# File 'lib/rltk/parser.rb', line 40 def remaining @remaining end |
#seen ⇒ Array<Token> (readonly)
Returns List of tokens that have been successfully parsed.
34 35 36 |
# File 'lib/rltk/parser.rb', line 34 def seen @seen end |
Instance Method Details
#to_s ⇒ String
Returns String representation of the error.
52 53 54 |
# File 'lib/rltk/parser.rb', line 52 def to_s "String not in language. Token info:\n\tSeen: #{@seen}\n\tCurrent: #{@current}\n\tRemaining: #{@remaining}" end |