Module: EDNGRAMMAR::AppStringH6

Defined in:
lib/parser/edngrammar.rb

Instance Method Summary collapse

Instance Method Details

#astObject



7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
# File 'lib/parser/edngrammar.rb', line 7298

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



7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
# File 'lib/parser/edngrammar.rb', line 7288

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