module Pione::Util::ParsletParserExtension
ParsletParserExtension
provides parser helper methods.
Public Instance Methods
except(exception)
click to toggle source
# File lib/pione/util/parslet-extension.rb, line 83 def except(exception) ExceptionAtom.new(self, exception) end
ignore()
click to toggle source
# File lib/pione/util/parslet-extension.rb, line 79 def ignore IgnoreAtom.new(self) end
ignore_error() { || ... }
click to toggle source
# File lib/pione/util/parslet-extension.rb, line 108 def ignore_error(&b) res = yield return IgnoreErrorAtom.new(res) end
or_error(msg, *expected_elements)
click to toggle source
Create a special atom that raises ParserError
when it is tried.
# File lib/pione/util/parslet-extension.rb, line 88 def or_error(msg, *expected_elements) self | SyntaxErrorAtom.new(msg, expected_elements, $ignore_error) end
should(atom, msg, *expected_elements)
click to toggle source
# File lib/pione/util/parslet-extension.rb, line 104 def should(atom, msg, *expected_elements) atom | syntax_error(msg, *expected_elements) end
syntax_error(msg, *expected_elements)
click to toggle source
Raises syntax error. This method returns a dummy atom and the parser evaluates it as error. @param [String] msg
error message
@param [Array<String>] expected_elements
expected name list
@return [SyntaxErrorAtom]
dummy atom for parser
# File lib/pione/util/parslet-extension.rb, line 100 def syntax_error(msg, *expected_elements) SyntaxErrorAtom.new(msg, expected_elements, $ignore_error) end