Module: Siren::Json
Defined Under Namespace
Modules: Array0, Array1, Array2, Array3, False0, KeyValuePair0, Null0, Number0, Number1, Number2, Number3, Number4, Object0, Object1, Object2, Object3, String0, String1, String2, String3, True0, Value0, Value1
Instance Method Summary collapse
- #_nt_array ⇒ Object
- #_nt_digit ⇒ Object
- #_nt_false ⇒ Object
- #_nt_hex ⇒ Object
- #_nt_key_value_pair ⇒ Object
- #_nt_null ⇒ Object
- #_nt_number ⇒ Object
- #_nt_object ⇒ Object
- #_nt_space ⇒ Object
- #_nt_string ⇒ Object
- #_nt_true ⇒ Object
- #_nt_value ⇒ Object
- #root ⇒ Object
Instance Method Details
#_nt_array ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/siren/json.rb', line 332 def _nt_array start_index = index if node_cache[:array].has_key?(index) cached = node_cache[:array][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] if input.index("[", index) == index r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("[") r1 = nil end s0 << r1 if r1 r2 = _nt_space s0 << r2 if r2 i4, s4 = index, [] r5 = _nt_value s4 << r5 if r5 s6, i6 = [], index loop do i7, s7 = index, [] if input.index(",", index) == index r8 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(",") r8 = nil end s7 << r8 if r8 r9 = _nt_value s7 << r9 end if s7.last r7 = instantiate_node(SyntaxNode,input, i7...index, s7) r7.extend(Array0) else self.index = i7 r7 = nil end if r7 s6 << r7 else break end end r6 = instantiate_node(SyntaxNode,input, i6...index, s6) s4 << r6 end if s4.last r4 = instantiate_node(SyntaxNode,input, i4...index, s4) r4.extend(Array1) else self.index = i4 r4 = nil end if r4 r3 = r4 else r3 = instantiate_node(SyntaxNode,input, index...index) end s0 << r3 if r3 if input.index("]", index) == index r10 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("]") r10 = nil end s0 << r10 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Array2) r0.extend(Array3) else self.index = i0 r0 = nil end node_cache[:array][start_index] = r0 return r0 end |
#_nt_digit ⇒ Object
873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 |
# File 'lib/siren/json.rb', line 873 def _nt_digit start_index = index if node_cache[:digit].has_key?(index) cached = node_cache[:digit][index] @index = cached.interval.end if cached return cached end if input.index(Regexp.new('[0-9]'), index) == index r0 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else r0 = nil end node_cache[:digit][start_index] = r0 return r0 end |
#_nt_false ⇒ Object
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 |
# File 'lib/siren/json.rb', line 955 def _nt_false start_index = index if node_cache[:false].has_key?(index) cached = node_cache[:false][index] @index = cached.interval.end if cached return cached end if input.index("false", index) == index r0 = instantiate_node(SyntaxNode,input, index...(index + 5)) r0.extend(False0) @index += 5 else terminal_parse_failure("false") r0 = nil end node_cache[:false][start_index] = r0 return r0 end |
#_nt_hex ⇒ Object
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
# File 'lib/siren/json.rb', line 893 def _nt_hex start_index = index if node_cache[:hex].has_key?(index) cached = node_cache[:hex][index] @index = cached.interval.end if cached return cached end i0 = index if input.index(Regexp.new('[a-f]'), index) == index r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else r1 = nil end if r1 r0 = r1 else r2 = _nt_digit if r2 r0 = r2 else self.index = i0 r0 = nil end end node_cache[:hex][start_index] = r0 return r0 end |
#_nt_key_value_pair ⇒ Object
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/siren/json.rb', line 251 def _nt_key_value_pair start_index = index if node_cache[:key_value_pair].has_key?(index) cached = node_cache[:key_value_pair][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_space s0 << r1 if r1 r2 = _nt_string s0 << r2 if r2 r3 = _nt_space s0 << r3 if r3 if input.index(":", index) == index r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(":") r4 = nil end s0 << r4 if r4 r5 = _nt_value s0 << r5 end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(KeyValuePair0) else self.index = i0 r0 = nil end node_cache[:key_value_pair][start_index] = r0 return r0 end |
#_nt_null ⇒ Object
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 |
# File 'lib/siren/json.rb', line 981 def _nt_null start_index = index if node_cache[:null].has_key?(index) cached = node_cache[:null][index] @index = cached.interval.end if cached return cached end if input.index("null", index) == index r0 = instantiate_node(SyntaxNode,input, index...(index + 4)) r0.extend(Null0) @index += 4 else terminal_parse_failure("null") r0 = nil end node_cache[:null][start_index] = r0 return r0 end |
#_nt_number ⇒ Object
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 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 |
# File 'lib/siren/json.rb', line 691 def _nt_number start_index = index if node_cache[:number].has_key?(index) cached = node_cache[:number][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] if input.index("-", index) == index r2 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("-") r2 = nil end if r2 r1 = r2 else r1 = instantiate_node(SyntaxNode,input, index...index) end s0 << r1 if r1 i3 = index if input.index("0", index) == index r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("0") r4 = nil end if r4 r3 = r4 else i5, s5 = index, [] if input.index(Regexp.new('[1-9]'), index) == index r6 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else r6 = nil end s5 << r6 if r6 s7, i7 = [], index loop do r8 = _nt_digit if r8 s7 << r8 else break end end r7 = instantiate_node(SyntaxNode,input, i7...index, s7) s5 << r7 end if s5.last r5 = instantiate_node(SyntaxNode,input, i5...index, s5) r5.extend(Number0) else self.index = i5 r5 = nil end if r5 r3 = r5 else self.index = i3 r3 = nil end end s0 << r3 if r3 i10, s10 = index, [] if input.index(".", index) == index r11 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(".") r11 = nil end s10 << r11 if r11 s12, i12 = [], index loop do r13 = _nt_digit if r13 s12 << r13 else break end end if s12.empty? self.index = i12 r12 = nil else r12 = instantiate_node(SyntaxNode,input, i12...index, s12) end s10 << r12 end if s10.last r10 = instantiate_node(SyntaxNode,input, i10...index, s10) r10.extend(Number1) else self.index = i10 r10 = nil end if r10 r9 = r10 else r9 = instantiate_node(SyntaxNode,input, index...index) end s0 << r9 if r9 i15, s15 = index, [] if input.index(Regexp.new('[eE]'), index) == index r16 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else r16 = nil end s15 << r16 if r16 if input.index(Regexp.new('[+-]'), index) == index r18 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else r18 = nil end if r18 r17 = r18 else r17 = instantiate_node(SyntaxNode,input, index...index) end s15 << r17 if r17 s19, i19 = [], index loop do r20 = _nt_digit if r20 s19 << r20 else break end end if s19.empty? self.index = i19 r19 = nil else r19 = instantiate_node(SyntaxNode,input, i19...index, s19) end s15 << r19 end end if s15.last r15 = instantiate_node(SyntaxNode,input, i15...index, s15) r15.extend(Number2) else self.index = i15 r15 = nil end if r15 r14 = r15 else r14 = instantiate_node(SyntaxNode,input, index...index) end s0 << r14 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Number3) r0.extend(Number4) else self.index = i0 r0 = nil end node_cache[:number][start_index] = r0 return r0 end |
#_nt_object ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/siren/json.rb', line 138 def _nt_object start_index = index if node_cache[:object].has_key?(index) cached = node_cache[:object][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] if input.index("{", index) == index r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("{") r1 = nil end s0 << r1 if r1 r2 = _nt_space s0 << r2 if r2 i4, s4 = index, [] r5 = _nt_key_value_pair s4 << r5 if r5 s6, i6 = [], index loop do i7, s7 = index, [] if input.index(",", index) == index r8 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(",") r8 = nil end s7 << r8 if r8 r9 = _nt_key_value_pair s7 << r9 end if s7.last r7 = instantiate_node(SyntaxNode,input, i7...index, s7) r7.extend(Object0) else self.index = i7 r7 = nil end if r7 s6 << r7 else break end end r6 = instantiate_node(SyntaxNode,input, i6...index, s6) s4 << r6 end if s4.last r4 = instantiate_node(SyntaxNode,input, i4...index, s4) r4.extend(Object1) else self.index = i4 r4 = nil end if r4 r3 = r4 else r3 = instantiate_node(SyntaxNode,input, index...index) end s0 << r3 if r3 if input.index("}", index) == index r10 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r10 = nil end s0 << r10 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Object2) r0.extend(Object3) else self.index = i0 r0 = nil end node_cache[:object][start_index] = r0 return r0 end |
#_nt_space ⇒ Object
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 |
# File 'lib/siren/json.rb', line 1003 def _nt_space start_index = index if node_cache[:space].has_key?(index) cached = node_cache[:space][index] @index = cached.interval.end if cached return cached end s0, i0 = [], index loop do if input.index(Regexp.new('[\\s\\n\\t]'), index) == index r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) node_cache[:space][start_index] = r0 return r0 end |
#_nt_string ⇒ Object
457 458 459 460 461 462 463 464 465 466 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 |
# File 'lib/siren/json.rb', line 457 def _nt_string start_index = index if node_cache[:string].has_key?(index) cached = node_cache[:string][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] if input.index('"', index) == index r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('"') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do i3 = index i4, s4 = index, [] if input.index('\\', index) == index r5 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('\\') r5 = nil end s4 << r5 if r5 i6 = index if input.index('"', index) == index r7 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('"') r7 = nil end if r7 r6 = r7 else if input.index('\\', index) == index r8 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('\\') r8 = nil end if r8 r6 = r8 else if input.index('/', index) == index r9 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('/') r9 = nil end if r9 r6 = r9 else if input.index('b', index) == index r10 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('b') r10 = nil end if r10 r6 = r10 else if input.index('f', index) == index r11 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('f') r11 = nil end if r11 r6 = r11 else if input.index('n', index) == index r12 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('n') r12 = nil end if r12 r6 = r12 else if input.index('r', index) == index r13 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('r') r13 = nil end if r13 r6 = r13 else if input.index('t', index) == index r14 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('t') r14 = nil end if r14 r6 = r14 else i15, s15 = index, [] if input.index('u', index) == index r16 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('u') r16 = nil end s15 << r16 if r16 r17 = _nt_hex s15 << r17 if r17 r18 = _nt_hex s15 << r18 if r18 r19 = _nt_hex s15 << r19 if r19 r20 = _nt_hex s15 << r20 end end end end if s15.last r15 = instantiate_node(SyntaxNode,input, i15...index, s15) r15.extend(String0) else self.index = i15 r15 = nil end if r15 r6 = r15 else self.index = i6 r6 = nil end end end end end end end end end s4 << r6 end if s4.last r4 = instantiate_node(SyntaxNode,input, i4...index, s4) r4.extend(String1) else self.index = i4 r4 = nil end if r4 r3 = r4 else if input.index(Regexp.new('[^\\"\\\\]'), index) == index r21 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else r21 = nil end if r21 r3 = r21 else self.index = i3 r3 = nil end end if r3 s2 << r3 else break end end r2 = instantiate_node(SyntaxNode,input, i2...index, s2) s0 << r2 if r2 if input.index('"', index) == index r22 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('"') r22 = nil end s0 << r22 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(String2) r0.extend(String3) else self.index = i0 r0 = nil end node_cache[:string][start_index] = r0 return r0 end |
#_nt_true ⇒ Object
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 |
# File 'lib/siren/json.rb', line 929 def _nt_true start_index = index if node_cache[:true].has_key?(index) cached = node_cache[:true][index] @index = cached.interval.end if cached return cached end if input.index("true", index) == index r0 = instantiate_node(SyntaxNode,input, index...(index + 4)) r0.extend(True0) @index += 4 else terminal_parse_failure("true") r0 = nil end node_cache[:true][start_index] = r0 return r0 end |
#_nt_value ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/siren/json.rb', line 29 def _nt_value start_index = index if node_cache[:value].has_key?(index) cached = node_cache[:value][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_space s0 << r1 if r1 i2 = index r3 = _nt_object if r3 r2 = r3 else r4 = _nt_array if r4 r2 = r4 else r5 = _nt_string if r5 r2 = r5 else r6 = _nt_number if r6 r2 = r6 else r7 = _nt_true if r7 r2 = r7 else r8 = _nt_false if r8 r2 = r8 else r9 = _nt_null if r9 r2 = r9 else self.index = i2 r2 = nil end end end end end end end s0 << r2 if r2 r10 = _nt_space s0 << r10 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Value0) r0.extend(Value1) else self.index = i0 r0 = nil end node_cache[:value][start_index] = r0 return r0 end |
#root ⇒ Object
5 6 7 |
# File 'lib/siren/json.rb', line 5 def root @root || :value end |