Module: EDNGRAMMAR::RAppStringH6

Defined in:
lib/parser/edngrammar.rb

Instance Method Summary collapse

Instance Method Details

#astObject



9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
# File 'lib/parser/edngrammar.rb', line 9078

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



9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
# File 'lib/parser/edngrammar.rb', line 9068

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