Class: CldrPlurals::Compiler::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/cldr-plurals/compiler/parser.rb

Defined Under Namespace

Classes: UnexpectedTokenError

Constant Summary collapse

OPERATORS =
[
  :modulo, :equals, :not_equals
]
SAMPLES =
[
  :int_sample, :dec_sample
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_list) ⇒ Parser

Returns a new instance of Parser.



21
22
23
24
25
# File 'lib/cldr-plurals/compiler/parser.rb', line 21

def initialize(token_list)
  @token_list = token_list
  @stack = []
  @counter = 0
end

Instance Attribute Details

#counterObject (readonly)

Returns the value of attribute counter.



19
20
21
# File 'lib/cldr-plurals/compiler/parser.rb', line 19

def counter
  @counter
end

#stackObject (readonly)

Returns the value of attribute stack.



19
20
21
# File 'lib/cldr-plurals/compiler/parser.rb', line 19

def stack
  @stack
end

#token_listObject (readonly)

Returns the value of attribute token_list.



19
20
21
# File 'lib/cldr-plurals/compiler/parser.rb', line 19

def token_list
  @token_list
end

Instance Method Details

#parseObject



27
28
29
30
31
32
33
# File 'lib/cldr-plurals/compiler/parser.rb', line 27

def parse
  until eol? || SAMPLES.include?(current_token.type) do
    condition
  end

  Rule.new(stack.pop)
end