Exception: EBNF::LL1::Lexer::Error

Inherits:
StandardError
  • Object
show all
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-cb49ee954bab/lib/ebnf/ll1/lexer.rb

Overview

Raised for errors during lexical analysis.

Examples:

Raising a lexer error

raise EBNF::LL1::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

#initialize(message, **options) ⇒ Error

Initializes a new lexer error instance.

Parameters:

Options Hash (**options):

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


498
499
500
501
502
503
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-cb49ee954bab/lib/ebnf/ll1/lexer.rb', line 498

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

Instance Attribute Details

#inputString (readonly)

The input string associated with the error.

Returns:



476
477
478
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-cb49ee954bab/lib/ebnf/ll1/lexer.rb', line 476

def input
  @input
end

#linenoInteger (readonly)

The line number where the error occurred.

Returns:



488
489
490
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-cb49ee954bab/lib/ebnf/ll1/lexer.rb', line 488

def lineno
  @lineno
end

#tokenString (readonly)

The invalid token which triggered the error.

Returns:



482
483
484
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/ebnf-cb49ee954bab/lib/ebnf/ll1/lexer.rb', line 482

def token
  @token
end