Module: BioVcf::VcfHeaderParser::RagelKeyValues
- Defined in:
- lib/bio-vcf/vcfheader_line.rb
Class Attribute Summary collapse
-
._simple_lexer_actions ⇒ Object
Returns the value of attribute _simple_lexer_actions.
-
._simple_lexer_eof_actions ⇒ Object
Returns the value of attribute _simple_lexer_eof_actions.
-
._simple_lexer_index_offsets ⇒ Object
Returns the value of attribute _simple_lexer_index_offsets.
-
._simple_lexer_key_offsets ⇒ Object
Returns the value of attribute _simple_lexer_key_offsets.
-
._simple_lexer_range_lengths ⇒ Object
Returns the value of attribute _simple_lexer_range_lengths.
-
._simple_lexer_single_lengths ⇒ Object
Returns the value of attribute _simple_lexer_single_lengths.
-
._simple_lexer_trans_actions ⇒ Object
Returns the value of attribute _simple_lexer_trans_actions.
-
._simple_lexer_trans_keys ⇒ Object
Returns the value of attribute _simple_lexer_trans_keys.
-
._simple_lexer_trans_targs ⇒ Object
Returns the value of attribute _simple_lexer_trans_targs.
-
.simple_lexer_en_main ⇒ Object
Returns the value of attribute simple_lexer_en_main.
-
.simple_lexer_error ⇒ Object
Returns the value of attribute simple_lexer_error.
-
.simple_lexer_first_final ⇒ Object
Returns the value of attribute simple_lexer_first_final.
-
.simple_lexer_start ⇒ Object
Returns the value of attribute simple_lexer_start.
Class Method Summary collapse
- .debug(msg) ⇒ Object
-
.run_lexer(buf, options = {}) ⇒ Object
line 79 “gen_vcfheaderline_parser.rl” %% this just fixes syntax highlighting…
Class Attribute Details
._simple_lexer_actions ⇒ Object
Returns the value of attribute _simple_lexer_actions.
39 40 41 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 39 def _simple_lexer_actions @_simple_lexer_actions end |
._simple_lexer_eof_actions ⇒ Object
Returns the value of attribute _simple_lexer_eof_actions.
422 423 424 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 422 def _simple_lexer_eof_actions @_simple_lexer_eof_actions end |
._simple_lexer_index_offsets ⇒ Object
Returns the value of attribute _simple_lexer_index_offsets.
220 221 222 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 220 def _simple_lexer_index_offsets @_simple_lexer_index_offsets end |
._simple_lexer_key_offsets ⇒ Object
Returns the value of attribute _simple_lexer_key_offsets.
53 54 55 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 53 def _simple_lexer_key_offsets @_simple_lexer_key_offsets end |
._simple_lexer_range_lengths ⇒ Object
Returns the value of attribute _simple_lexer_range_lengths.
196 197 198 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 196 def _simple_lexer_range_lengths @_simple_lexer_range_lengths end |
._simple_lexer_single_lengths ⇒ Object
Returns the value of attribute _simple_lexer_single_lengths.
172 173 174 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 172 def _simple_lexer_single_lengths @_simple_lexer_single_lengths end |
._simple_lexer_trans_actions ⇒ Object
Returns the value of attribute _simple_lexer_trans_actions.
333 334 335 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 333 def _simple_lexer_trans_actions @_simple_lexer_trans_actions end |
._simple_lexer_trans_keys ⇒ Object
Returns the value of attribute _simple_lexer_trans_keys.
77 78 79 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 77 def _simple_lexer_trans_keys @_simple_lexer_trans_keys end |
._simple_lexer_trans_targs ⇒ Object
Returns the value of attribute _simple_lexer_trans_targs.
244 245 246 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 244 def _simple_lexer_trans_targs @_simple_lexer_trans_targs end |
.simple_lexer_en_main ⇒ Object
Returns the value of attribute simple_lexer_en_main.
459 460 461 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 459 def simple_lexer_en_main @simple_lexer_en_main end |
.simple_lexer_error ⇒ Object
Returns the value of attribute simple_lexer_error.
454 455 456 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 454 def simple_lexer_error @simple_lexer_error end |
.simple_lexer_first_final ⇒ Object
Returns the value of attribute simple_lexer_first_final.
450 451 452 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 450 def simple_lexer_first_final @simple_lexer_first_final end |
.simple_lexer_start ⇒ Object
Returns the value of attribute simple_lexer_start.
446 447 448 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 446 def simple_lexer_start @simple_lexer_start end |
Class Method Details
.debug(msg) ⇒ Object
25 26 27 28 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 25 def self.debug msg # nothing # $stderr.print "DEBUG: ",msg,"\n" end |
.run_lexer(buf, options = {}) ⇒ Object
line 79 “gen_vcfheaderline_parser.rl” %% this just fixes syntax highlighting…
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 |
# File 'lib/bio-vcf/vcfheader_line.rb', line 467 def self.run_lexer(buf, = {}) do_debug = ([:debug] == true) $stderr.print "---> ",buf,"\n" if do_debug data = buf.unpack("c*") if(buf.is_a?(String)) eof = data.length values = [] stack = [] emit = lambda { |type, data, ts, p| # Print the type and text of the last read token # p ts,p $stderr.print "EMITTED: #{type}: #{data[ts...p].pack('c*')}\n" if do_debug values << [type,data[ts...p].pack('c*')] } error_code = nil # line 486 "gen_vcfheaderline_parser.rb" begin p ||= 0 pe ||= data.length cs = simple_lexer_start end # line 99 "gen_vcfheaderline_parser.rl" # line 495 "gen_vcfheaderline_parser.rb" begin _klen, _trans, _keys, _acts, _nacts = nil _goto_level = 0 _resume = 10 _eof_trans = 15 _again = 20 _test_eof = 30 _out = 40 while true _trigger_goto = false if _goto_level <= 0 if p == pe _goto_level = _test_eof next end if cs == 0 _goto_level = _out next end end if _goto_level <= _resume _keys = _simple_lexer_key_offsets[cs] _trans = _simple_lexer_index_offsets[cs] _klen = _simple_lexer_single_lengths[cs] _break_match = false begin if _klen > 0 _lower = _keys _upper = _keys + _klen - 1 loop do break if _upper < _lower _mid = _lower + ( (_upper - _lower) >> 1 ) if data[p].ord < _simple_lexer_trans_keys[_mid] _upper = _mid - 1 elsif data[p].ord > _simple_lexer_trans_keys[_mid] _lower = _mid + 1 else _trans += (_mid - _keys) _break_match = true break end end # loop break if _break_match _keys += _klen _trans += _klen end _klen = _simple_lexer_range_lengths[cs] if _klen > 0 _lower = _keys _upper = _keys + (_klen << 1) - 2 loop do break if _upper < _lower _mid = _lower + (((_upper-_lower) >> 1) & ~1) if data[p].ord < _simple_lexer_trans_keys[_mid] _upper = _mid - 2 elsif data[p].ord > _simple_lexer_trans_keys[_mid+1] _lower = _mid + 2 else _trans += ((_mid - _keys) >> 1) _break_match = true break end end # loop break if _break_match _trans += _klen end end while false cs = _simple_lexer_trans_targs[_trans] if _simple_lexer_trans_actions[_trans] != 0 _acts = _simple_lexer_trans_actions[_trans] _nacts = _simple_lexer_actions[_acts] _acts += 1 while _nacts > 0 _nacts -= 1 _acts += 1 case _simple_lexer_actions[_acts - 1] when 0 then # line 33 "gen_vcfheaderline_parser.rl" begin ts=p end when 1 then # line 34 "gen_vcfheaderline_parser.rl" begin emit.call(:value,data,ts,p) end when 2 then # line 38 "gen_vcfheaderline_parser.rl" begin emit.call(:kw,data,ts,p) end when 3 then # line 58 "gen_vcfheaderline_parser.rl" begin emit.call(:key_word,data,ts,p) end when 4 then # line 59 "gen_vcfheaderline_parser.rl" begin emit.call(:value,data,ts,p) end when 5 then # line 60 "gen_vcfheaderline_parser.rl" begin emit.call(:value,data,ts,p) end when 6 then # line 62 "gen_vcfheaderline_parser.rl" begin emit.call(:value,data,ts,p) end when 7 then # line 65 "gen_vcfheaderline_parser.rl" begin emit.call(:value,data,ts,p) end when 8 then # line 67 "gen_vcfheaderline_parser.rl" begin debug("ID FOUND") end when 9 then # line 67 "gen_vcfheaderline_parser.rl" begin error_code="Malformed ID" end when 10 then # line 68 "gen_vcfheaderline_parser.rl" begin error_code="Version" end when 11 then # line 69 "gen_vcfheaderline_parser.rl" begin error_code="Number" end when 12 then # line 70 "gen_vcfheaderline_parser.rl" begin debug("DATE FOUND") end when 13 then # line 70 "gen_vcfheaderline_parser.rl" begin error_code="Date" end when 14 then # line 71 "gen_vcfheaderline_parser.rl" begin error_code="GATK" end when 15 then # line 72 "gen_vcfheaderline_parser.rl" begin debug("KEY_VALUE found") end when 16 then # line 72 "gen_vcfheaderline_parser.rl" begin error_code="unknown key-value " end # line 647 "gen_vcfheaderline_parser.rb" end # action switch end end if _trigger_goto next end end if _goto_level <= _again if cs == 0 _goto_level = _out next end p += 1 if p != pe _goto_level = _resume next end end if _goto_level <= _test_eof if p == eof __acts = _simple_lexer_eof_actions[cs] __nacts = _simple_lexer_actions[__acts] __acts += 1 while __nacts > 0 __nacts -= 1 __acts += 1 case _simple_lexer_actions[__acts - 1] when 9 then # line 67 "gen_vcfheaderline_parser.rl" begin error_code="Malformed ID" end when 10 then # line 68 "gen_vcfheaderline_parser.rl" begin error_code="Version" end when 11 then # line 69 "gen_vcfheaderline_parser.rl" begin error_code="Number" end when 13 then # line 70 "gen_vcfheaderline_parser.rl" begin error_code="Date" end when 14 then # line 71 "gen_vcfheaderline_parser.rl" begin error_code="GATK" end when 16 then # line 72 "gen_vcfheaderline_parser.rl" begin error_code="unknown key-value " end # line 699 "gen_vcfheaderline_parser.rb" end # eof action switch end if _trigger_goto next end end end if _goto_level <= _out break end end end # line 100 "gen_vcfheaderline_parser.rl" raise "ERROR: "+error_code+" in "+buf if error_code begin res = {} # p values values.each_slice(2) do | a,b | $stderr.print '*',a,b if do_debug keyword = a[1] value = b[1] value = value.to_i if ['length','Epoch'].index(keyword) res[keyword] = value # p h[:value] if h[:name]==:identifier or h[:name]==:value or h[:name]==:string end rescue print "ERROR: " p values raise end $stderr.print(res,"\n") if do_debug res end |