Module: EDNGRAMMAR::AppStringH6

Defined in:
lib/parser/edngrammar.rb

Instance Method Summary collapse

Instance Method Details

#astObject



7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
# File 'lib/parser/edngrammar.rb', line 7579

def ast
  e1 = elements[1].elements.map {|e| e.ast}
  out = []
  curr = []
  e1.each { |el|
    if curr.size == 0 || curr[0].class == el.class
      curr << el
    else
      out << curr
      curr = [el]
    end
  }
  if out.size == 0 && (curr.size == 0 || String === curr[0])
    curr.join.b # unpack_thread(curr)
  else
    CBOR::Tagged.new(888, (out << curr).map {|x| unpack_thread(x)})
  end
end

#unpack_thread(s) ⇒ Object



7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
# File 'lib/parser/edngrammar.rb', line 7569

def unpack_thread(s)
  case s[0]
  when CBOR::Tagged
    s[0]
  when String
    s.join
  else
    raise "@@@ unpack_thread #{s.inspect}"
  end
end