Method: Packrat::AST.number_multioccurences

Defined in:
lib/packrat/grammar.rb

.number_multioccurences(sig) ⇒ Object



423
424
425
426
427
428
429
# File 'lib/packrat/grammar.rb', line 423

def number_multioccurences(sig)
  num_sigs = sig.inject(Hash.new(0)) {|h, s| h[s] += 1 if Symbol === s; h}
  counters = Hash.new(0)
  sig.map do |s|
    (num_sigs[s] > 1) ? (s.to_s + (counters[s] += 1).to_s).intern : s
  end
end