Class: Pione::Util::SyntaxErrorAtom

Inherits:
Parslet::Atoms::Base
  • Object
show all
Defined in:
lib/pione/util/parslet-extension.rb

Overview

SyntaxErrorAtom is a special parslet atom for +on_error+ helper method.

Instance Method Summary collapse

Constructor Details

#initialize(msg, expected_elements = [], ignore_error) ⇒ SyntaxErrorAtom

Returns a new instance of SyntaxErrorAtom.



5
6
7
8
9
# File 'lib/pione/util/parslet-extension.rb', line 5

def initialize(msg, expected_elements=[], ignore_error)
  @msg = msg
  @expected_elements = expected_elements
  @ignore_error = ignore_error
end

Instance Method Details

#to_s_inner(prec) ⇒ Object



16
17
18
# File 'lib/pione/util/parslet-extension.rb', line 16

def to_s_inner(prec)
  "SYNTAX_ERROR"
end

#try(source, context, _) ⇒ Object

Raise a +ParserError+ when this atom is touched.

Raises:



12
13
14
# File 'lib/pione/util/parslet-extension.rb', line 12

def try(source, context, _)
  raise Lang::ParserError.new(@msg, @expected_elements, source)
end