Exception: EBNF::PEG::Parser::Error

Inherits:
StandardError
  • Object
show all
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-c8f40958c6c3/lib/ebnf/peg/parser.rb

Overview

Raised for errors during parsing.

Examples:

Raising a parser error

raise Error.new(
  "invalid token '%' on line 10",
  rest: '%', 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:

Options Hash (**options):

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


575
576
577
578
579
580
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-c8f40958c6c3/lib/ebnf/peg/parser.rb', line 575

def initialize(message, **options)
  @production = options[:production]
  @rest       = options[:rest]
  @lineno     = options[:lineno]
  super(message.to_s)
end

Instance Attribute Details

#linenoInteger (readonly)

The line number where the error occurred.

Returns:



565
566
567
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-c8f40958c6c3/lib/ebnf/peg/parser.rb', line 565

def lineno
  @lineno
end

#productionSymbol (readonly)

The current production.

Returns:



553
554
555
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-c8f40958c6c3/lib/ebnf/peg/parser.rb', line 553

def production
  @production
end

#restString (readonly)

The read head when scanning failed

Returns:



559
560
561
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-c8f40958c6c3/lib/ebnf/peg/parser.rb', line 559

def rest
  @rest
end