Exception: SPARQL::Grammar::Lexer::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/sparql/grammar/lexer.rb

Overview

Raised for errors during lexical analysis.

Examples:

Raising a lexer error

raise SPARQL::Grammar::Lexer::Error.new(
  "invalid token '%' on line 10",
  :input => query, :token => '%', :lineno => 9)

See Also:

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Error) initialize(message, options = {})

Initializes a new lexer error instance.

Parameters:

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

Options Hash (options):

  • (String) :input — default: nil
  • (String) :token — default: nil
  • (Integer) :lineno — default: nil


599
600
601
602
603
604
# File 'lib/sparql/grammar/lexer.rb', line 599

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

Instance Attribute Details

- (String) input (readonly)

The input string associated with the error.

Returns:



577
578
579
# File 'lib/sparql/grammar/lexer.rb', line 577

def input
  @input
end

- (Integer) lineno (readonly)

The line number where the error occurred.

Returns:

  • (Integer)


589
590
591
# File 'lib/sparql/grammar/lexer.rb', line 589

def lineno
  @lineno
end

- (String) token (readonly)

The invalid token which triggered the error.

Returns:



583
584
585
# File 'lib/sparql/grammar/lexer.rb', line 583

def token
  @token
end