Module: ABNFGrammar::RepeatC1

Defined in:
lib/abnfgrammar.rb

Instance Method Summary collapse

Instance Method Details

#ast_wrap(a) ⇒ Object



805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
# File 'lib/abnfgrammar.rb', line 805

def ast_wrap(a)
    s = 1
    e = 1
    el = elements.map {|e| e.text_value}
    if el != []
      el[2] = el[0] = el.join if el[1] != "*"
      s = if el[0] != ""
            el[0].to_i
          else
            0
          end
      e = if el[2] != ""
            el[2].to_i
          else
            true
          end
    end
    occ = [s, e]
    if occ == [1, 1]
      a
    else
      ["rep", s, e, a]
    end
end