Class: Evilution::AST::Pattern::Parser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/ast/pattern/parser.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Parser

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Parser.



6
7
8
9
# File 'lib/evilution/ast/pattern/parser.rb', line 6

def initialize(input)
  @input = input.strip
  @pos = 0
end

Instance Method Details

#parseObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
14
15
16
17
18
19
# File 'lib/evilution/ast/pattern/parser.rb', line 11

def parse
  raise Evilution::ConfigError, "invalid pattern: empty string" if @input.empty?

  result = parse_pattern
  skip_whitespace
  raise Evilution::ConfigError, "unexpected characters at position #{@pos}: #{@input[@pos..]}" unless @pos >= @input.length

  result
end