Module: EDNGRAMMAR::String2
- Defined in:
- lib/parser/edngrammar.rb
Instance Method Summary collapse
Instance Method Details
#ast ⇒ Object
386 387 388 389 390 391 392 393 394 |
# File 'lib/parser/edngrammar.rb', line 386 def ast arr = [elements[0].ast] + elements[1].elements.map {|x| x.elements[1].ast} charr = arr.chunk(&:class).to_a if charr.size == 1 unpack_chunk(*charr.first) else CBOR::Tagged.new(888, charr.map {|x| unpack_chunk(*x)}) end end |
#join1(s) ⇒ Object
373 374 375 |
# File 'lib/parser/edngrammar.rb', line 373 def join1(s) s.join # XXX -- look at encoding and ei end |
#unpack_chunk(c, s) ⇒ Object
376 377 378 379 380 381 382 383 384 385 |
# File 'lib/parser/edngrammar.rb', line 376 def unpack_chunk(c, s) if c == String join1(s) else unless c == CBOR::Tagged && s.first.tag == 888 && s.first.value == nil # XXX check all values? raise "*** unjoinable chunks #{c.inspect} #{s.inspect}" if s.size != 1 end s.first end end |