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

- (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) :production — default: nil
  • (Integer) :lineno — default: nil
  • (Integer) :position — default: nil


1334
1335
1336
1337
1338
1339
1340
# File 'lib/sparql/grammar/parser.rb', line 1334

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

Instance Attribute Details

- (String) input (readonly)

The input string associated with the error.

Returns:

  • (String)


1305
1306
1307
# File 'lib/sparql/grammar/parser.rb', line 1305

def input
  @input
end

- (Integer) lineno (readonly)

The line number where the error occurred.

Returns:

  • (Integer)


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

def lineno
  @lineno
end

- (Integer) position (readonly)

Position within line of error.

Returns:

  • (Integer)


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

def position
  @position
end

- (String) production (readonly)

The grammar production where the error was found.

Returns:

  • (String)


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

def production
  @production
end