class ABNF::Parser::Compiler::Concatenation

Public Instance Methods

alternation_slash(_) click to toggle source
# File lib/abnf/parser/compiler/concatenation.rb, line 5
def alternation_slash _
  finished
end
c_nl(token) click to toggle source
# File lib/abnf/parser/compiler/concatenation.rb, line 9
def c_nl token
  finished
  compiler.handle token
end
c_wsp(_) click to toggle source
# File lib/abnf/parser/compiler/concatenation.rb, line 14
def c_wsp _
end
finished() click to toggle source
# File lib/abnf/parser/compiler/concatenation.rb, line 22
def finished
  if repetitions.size == 1
    rule = repetitions.first
  else
    abnf = repetitions.map &:abnf
    abnf *= ' '
    rule = Rules::Concatenation.new repetitions, abnf
  end

  compiler.pop rule
end
group_stop(token) click to toggle source
# File lib/abnf/parser/compiler/concatenation.rb, line 17
def group_stop token
  finished
  compiler.handle token
end
option_stop(token) click to toggle source
# File lib/abnf/parser/compiler/concatenation.rb, line 34
def option_stop token
  finished
  compiler.handle token
end
repetition(repetition) click to toggle source
# File lib/abnf/parser/compiler/concatenation.rb, line 39
def repetition repetition
  repetitions << repetition
end
repetitions() click to toggle source
# File lib/abnf/parser/compiler/concatenation.rb, line 43
def repetitions
  @repetitions ||= []
end
start_rule(token) click to toggle source
# File lib/abnf/parser/compiler/concatenation.rb, line 47
def start_rule token
  compiler.push Repetition do |element|
    repetition element
  end
end