Exception: EBNF::LL1::Parser::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/ebnf/ll1/parser.rb

Overview

Raised for errors during parsing.

Examples:

Raising a parser error

raise Error.new(
  "invalid token '%' on line 10",
  :token => '%', :lineno => 9, :production => :turtleDoc)

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, options = {}) ⇒ Error

Initializes a new lexer error instance.

Parameters:

  • message (String, #to_s)
  • options (Hash{Symbol => Object}) (defaults to: {})

Options Hash (options):

  • :production (Symbol) — default: nil
  • :token (String) — default: nil
  • :lineno (Integer) — default: nil


619
620
621
622
623
624
# File 'lib/ebnf/ll1/parser.rb', line 619

def initialize(message, options = {})
  @production = options[:production]
  @token      = options[:token]
  @lineno     = options[:lineno]
  super(message.to_s)
end

Instance Attribute Details

#linenoInteger (readonly)

The line number where the error occurred.

Returns:

  • (Integer)


609
610
611
# File 'lib/ebnf/ll1/parser.rb', line 609

def lineno
  @lineno
end

#productionSymbol (readonly)

The current production.

Returns:

  • (Symbol)


597
598
599
# File 'lib/ebnf/ll1/parser.rb', line 597

def production
  @production
end

#tokenString (readonly)

The invalid token which triggered the error.

Returns:

  • (String)


603
604
605
# File 'lib/ebnf/ll1/parser.rb', line 603

def token
  @token
end