Exception: SPARQL::Grammar::Parser::Error

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

Overview

Raised for errors during parsing.

Examples:

Raising a parser error

raise SPARQL::Grammar::Parser::Error.new(
  "FIXME on line 10",
  :input => query, :production => '%', :lineno => 9)

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):

  • :input (String) — default: nil
  • :production (String) — default: nil
  • :lineno (Integer) — default: nil
  • :position (Integer) — default: nil


1341
1342
1343
1344
1345
1346
1347
# File 'lib/sparql/grammar/parser.rb', line 1341

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

Instance Attribute Details

#inputString (readonly)

The input string associated with the error.

Returns:

  • (String)


1312
1313
1314
# File 'lib/sparql/grammar/parser.rb', line 1312

def input
  @input
end

#linenoInteger (readonly)

The line number where the error occurred.

Returns:

  • (Integer)


1324
1325
1326
# File 'lib/sparql/grammar/parser.rb', line 1324

def lineno
  @lineno
end

#positionInteger (readonly)

Position within line of error.

Returns:

  • (Integer)


1330
1331
1332
# File 'lib/sparql/grammar/parser.rb', line 1330

def position
  @position
end

#productionString (readonly)

The grammar production where the error was found.

Returns:

  • (String)


1318
1319
1320
# File 'lib/sparql/grammar/parser.rb', line 1318

def production
  @production
end