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

Inherits:
StandardError
  • Object
show all
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-cb49ee954bab/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


568
569
570
571
572
573
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-cb49ee954bab/lib/ebnf/peg/parser.rb', line 568

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:



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

def lineno
  @lineno
end

#productionSymbol (readonly)

The current production.

Returns:



546
547
548
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-cb49ee954bab/lib/ebnf/peg/parser.rb', line 546

def production
  @production
end

#restString (readonly)

The read head when scanning failed

Returns:



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

def rest
  @rest
end