Module: EDNGRAMMAR::AppStringH6

Defined in:
lib/parser/edngrammar.rb

Instance Method Summary collapse

Instance Method Details

#astObject



8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
# File 'lib/parser/edngrammar.rb', line 8077

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



8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
# File 'lib/parser/edngrammar.rb', line 8067

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