Exception: RLTK::NotInLanguage

Inherits:
StandardError
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(seen, current, remaining) ⇒ NotInLanguage

Returns a new instance of NotInLanguage.

Parameters:

  • seen (Array<Token>)

    Tokens that have been successfully parsed

  • current (Token)

    Token that caused the parser to stop

  • remaining (Array<Token>)

    Tokens that have yet to be seen



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

#currentToken (readonly)

Returns Token that caused the parser to stop.

Returns:

  • (Token)

    Token that caused the parser to stop



37
38
39
# File 'lib/rltk/parser.rb', line 37

def current
  @current
end

#remainingArray<Token> (readonly)

Returns List of tokens that have yet to be seen.

Returns:

  • (Array<Token>)

    List of tokens that have yet to be seen



40
41
42
# File 'lib/rltk/parser.rb', line 40

def remaining
  @remaining
end

#seenArray<Token> (readonly)

Returns List of tokens that have been successfully parsed.

Returns:

  • (Array<Token>)

    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_sString

Returns String representation of the error.

Returns:

  • (String)

    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