machine.go (26038B)
1 package urn 2 3 import ( 4 "fmt" 5 ) 6 7 var ( 8 errPrefix = "expecting the prefix to be the \"urn\" string (whatever case) [col %d]" 9 errIdentifier = "expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col %d]" 10 errSpecificString = "expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col %d]" 11 errNoUrnWithinID = "expecting the identifier to not contain the \"urn\" reserved string [col %d]" 12 errHex = "expecting the specific string hex chars to be well-formed (%%alnum{2}) [col %d]" 13 errParse = "parsing error [col %d]" 14 ) 15 16 const start int = 1 17 const firstFinal int = 44 18 19 const enFail int = 46 20 const enMain int = 1 21 22 // Machine is the interface representing the FSM 23 type Machine interface { 24 Error() error 25 Parse(input []byte) (*URN, error) 26 } 27 28 type machine struct { 29 data []byte 30 cs int 31 p, pe, eof, pb int 32 err error 33 tolower []int 34 } 35 36 // NewMachine creates a new FSM able to parse RFC 2141 strings. 37 func NewMachine() Machine { 38 m := &machine{} 39 40 return m 41 } 42 43 // Err returns the error that occurred on the last call to Parse. 44 // 45 // If the result is nil, then the line was parsed successfully. 46 func (m *machine) Error() error { 47 return m.err 48 } 49 50 func (m *machine) text() []byte { 51 return m.data[m.pb:m.p] 52 } 53 54 // Parse parses the input byte array as a RFC 2141 string. 55 func (m *machine) Parse(input []byte) (*URN, error) { 56 m.data = input 57 m.p = 0 58 m.pb = 0 59 m.pe = len(input) 60 m.eof = len(input) 61 m.err = nil 62 m.tolower = []int{} 63 output := &URN{} 64 { 65 m.cs = start 66 } 67 { 68 if (m.p) == (m.pe) { 69 goto _testEof 70 } 71 switch m.cs { 72 case 1: 73 goto stCase1 74 case 0: 75 goto stCase0 76 case 2: 77 goto stCase2 78 case 3: 79 goto stCase3 80 case 4: 81 goto stCase4 82 case 5: 83 goto stCase5 84 case 6: 85 goto stCase6 86 case 7: 87 goto stCase7 88 case 8: 89 goto stCase8 90 case 9: 91 goto stCase9 92 case 10: 93 goto stCase10 94 case 11: 95 goto stCase11 96 case 12: 97 goto stCase12 98 case 13: 99 goto stCase13 100 case 14: 101 goto stCase14 102 case 15: 103 goto stCase15 104 case 16: 105 goto stCase16 106 case 17: 107 goto stCase17 108 case 18: 109 goto stCase18 110 case 19: 111 goto stCase19 112 case 20: 113 goto stCase20 114 case 21: 115 goto stCase21 116 case 22: 117 goto stCase22 118 case 23: 119 goto stCase23 120 case 24: 121 goto stCase24 122 case 25: 123 goto stCase25 124 case 26: 125 goto stCase26 126 case 27: 127 goto stCase27 128 case 28: 129 goto stCase28 130 case 29: 131 goto stCase29 132 case 30: 133 goto stCase30 134 case 31: 135 goto stCase31 136 case 32: 137 goto stCase32 138 case 33: 139 goto stCase33 140 case 34: 141 goto stCase34 142 case 35: 143 goto stCase35 144 case 36: 145 goto stCase36 146 case 37: 147 goto stCase37 148 case 38: 149 goto stCase38 150 case 44: 151 goto stCase44 152 case 39: 153 goto stCase39 154 case 40: 155 goto stCase40 156 case 45: 157 goto stCase45 158 case 41: 159 goto stCase41 160 case 42: 161 goto stCase42 162 case 43: 163 goto stCase43 164 case 46: 165 goto stCase46 166 } 167 goto stOut 168 stCase1: 169 switch (m.data)[(m.p)] { 170 case 85: 171 goto tr1 172 case 117: 173 goto tr1 174 } 175 goto tr0 176 tr0: 177 178 m.err = fmt.Errorf(errParse, m.p) 179 (m.p)-- 180 181 { 182 goto st46 183 } 184 185 goto st0 186 tr3: 187 188 m.err = fmt.Errorf(errPrefix, m.p) 189 (m.p)-- 190 191 { 192 goto st46 193 } 194 195 m.err = fmt.Errorf(errParse, m.p) 196 (m.p)-- 197 198 { 199 goto st46 200 } 201 202 goto st0 203 tr6: 204 205 m.err = fmt.Errorf(errIdentifier, m.p) 206 (m.p)-- 207 208 { 209 goto st46 210 } 211 212 m.err = fmt.Errorf(errParse, m.p) 213 (m.p)-- 214 215 { 216 goto st46 217 } 218 219 goto st0 220 tr41: 221 222 m.err = fmt.Errorf(errSpecificString, m.p) 223 (m.p)-- 224 225 { 226 goto st46 227 } 228 229 m.err = fmt.Errorf(errParse, m.p) 230 (m.p)-- 231 232 { 233 goto st46 234 } 235 236 goto st0 237 tr44: 238 239 m.err = fmt.Errorf(errHex, m.p) 240 (m.p)-- 241 242 { 243 goto st46 244 } 245 246 m.err = fmt.Errorf(errSpecificString, m.p) 247 (m.p)-- 248 249 { 250 goto st46 251 } 252 253 m.err = fmt.Errorf(errParse, m.p) 254 (m.p)-- 255 256 { 257 goto st46 258 } 259 260 goto st0 261 tr50: 262 263 m.err = fmt.Errorf(errPrefix, m.p) 264 (m.p)-- 265 266 { 267 goto st46 268 } 269 270 m.err = fmt.Errorf(errIdentifier, m.p) 271 (m.p)-- 272 273 { 274 goto st46 275 } 276 277 m.err = fmt.Errorf(errParse, m.p) 278 (m.p)-- 279 280 { 281 goto st46 282 } 283 284 goto st0 285 tr52: 286 287 m.err = fmt.Errorf(errNoUrnWithinID, m.p) 288 (m.p)-- 289 290 { 291 goto st46 292 } 293 294 m.err = fmt.Errorf(errIdentifier, m.p) 295 (m.p)-- 296 297 { 298 goto st46 299 } 300 301 m.err = fmt.Errorf(errParse, m.p) 302 (m.p)-- 303 304 { 305 goto st46 306 } 307 308 goto st0 309 stCase0: 310 st0: 311 m.cs = 0 312 goto _out 313 tr1: 314 315 m.pb = m.p 316 317 goto st2 318 st2: 319 if (m.p)++; (m.p) == (m.pe) { 320 goto _testEof2 321 } 322 stCase2: 323 switch (m.data)[(m.p)] { 324 case 82: 325 goto st3 326 case 114: 327 goto st3 328 } 329 goto tr0 330 st3: 331 if (m.p)++; (m.p) == (m.pe) { 332 goto _testEof3 333 } 334 stCase3: 335 switch (m.data)[(m.p)] { 336 case 78: 337 goto st4 338 case 110: 339 goto st4 340 } 341 goto tr3 342 st4: 343 if (m.p)++; (m.p) == (m.pe) { 344 goto _testEof4 345 } 346 stCase4: 347 if (m.data)[(m.p)] == 58 { 348 goto tr5 349 } 350 goto tr0 351 tr5: 352 353 output.prefix = string(m.text()) 354 355 goto st5 356 st5: 357 if (m.p)++; (m.p) == (m.pe) { 358 goto _testEof5 359 } 360 stCase5: 361 switch (m.data)[(m.p)] { 362 case 85: 363 goto tr8 364 case 117: 365 goto tr8 366 } 367 switch { 368 case (m.data)[(m.p)] < 65: 369 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 370 goto tr7 371 } 372 case (m.data)[(m.p)] > 90: 373 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 374 goto tr7 375 } 376 default: 377 goto tr7 378 } 379 goto tr6 380 tr7: 381 382 m.pb = m.p 383 384 goto st6 385 st6: 386 if (m.p)++; (m.p) == (m.pe) { 387 goto _testEof6 388 } 389 stCase6: 390 switch (m.data)[(m.p)] { 391 case 45: 392 goto st7 393 case 58: 394 goto tr10 395 } 396 switch { 397 case (m.data)[(m.p)] < 65: 398 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 399 goto st7 400 } 401 case (m.data)[(m.p)] > 90: 402 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 403 goto st7 404 } 405 default: 406 goto st7 407 } 408 goto tr6 409 st7: 410 if (m.p)++; (m.p) == (m.pe) { 411 goto _testEof7 412 } 413 stCase7: 414 switch (m.data)[(m.p)] { 415 case 45: 416 goto st8 417 case 58: 418 goto tr10 419 } 420 switch { 421 case (m.data)[(m.p)] < 65: 422 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 423 goto st8 424 } 425 case (m.data)[(m.p)] > 90: 426 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 427 goto st8 428 } 429 default: 430 goto st8 431 } 432 goto tr6 433 st8: 434 if (m.p)++; (m.p) == (m.pe) { 435 goto _testEof8 436 } 437 stCase8: 438 switch (m.data)[(m.p)] { 439 case 45: 440 goto st9 441 case 58: 442 goto tr10 443 } 444 switch { 445 case (m.data)[(m.p)] < 65: 446 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 447 goto st9 448 } 449 case (m.data)[(m.p)] > 90: 450 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 451 goto st9 452 } 453 default: 454 goto st9 455 } 456 goto tr6 457 st9: 458 if (m.p)++; (m.p) == (m.pe) { 459 goto _testEof9 460 } 461 stCase9: 462 switch (m.data)[(m.p)] { 463 case 45: 464 goto st10 465 case 58: 466 goto tr10 467 } 468 switch { 469 case (m.data)[(m.p)] < 65: 470 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 471 goto st10 472 } 473 case (m.data)[(m.p)] > 90: 474 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 475 goto st10 476 } 477 default: 478 goto st10 479 } 480 goto tr6 481 st10: 482 if (m.p)++; (m.p) == (m.pe) { 483 goto _testEof10 484 } 485 stCase10: 486 switch (m.data)[(m.p)] { 487 case 45: 488 goto st11 489 case 58: 490 goto tr10 491 } 492 switch { 493 case (m.data)[(m.p)] < 65: 494 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 495 goto st11 496 } 497 case (m.data)[(m.p)] > 90: 498 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 499 goto st11 500 } 501 default: 502 goto st11 503 } 504 goto tr6 505 st11: 506 if (m.p)++; (m.p) == (m.pe) { 507 goto _testEof11 508 } 509 stCase11: 510 switch (m.data)[(m.p)] { 511 case 45: 512 goto st12 513 case 58: 514 goto tr10 515 } 516 switch { 517 case (m.data)[(m.p)] < 65: 518 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 519 goto st12 520 } 521 case (m.data)[(m.p)] > 90: 522 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 523 goto st12 524 } 525 default: 526 goto st12 527 } 528 goto tr6 529 st12: 530 if (m.p)++; (m.p) == (m.pe) { 531 goto _testEof12 532 } 533 stCase12: 534 switch (m.data)[(m.p)] { 535 case 45: 536 goto st13 537 case 58: 538 goto tr10 539 } 540 switch { 541 case (m.data)[(m.p)] < 65: 542 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 543 goto st13 544 } 545 case (m.data)[(m.p)] > 90: 546 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 547 goto st13 548 } 549 default: 550 goto st13 551 } 552 goto tr6 553 st13: 554 if (m.p)++; (m.p) == (m.pe) { 555 goto _testEof13 556 } 557 stCase13: 558 switch (m.data)[(m.p)] { 559 case 45: 560 goto st14 561 case 58: 562 goto tr10 563 } 564 switch { 565 case (m.data)[(m.p)] < 65: 566 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 567 goto st14 568 } 569 case (m.data)[(m.p)] > 90: 570 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 571 goto st14 572 } 573 default: 574 goto st14 575 } 576 goto tr6 577 st14: 578 if (m.p)++; (m.p) == (m.pe) { 579 goto _testEof14 580 } 581 stCase14: 582 switch (m.data)[(m.p)] { 583 case 45: 584 goto st15 585 case 58: 586 goto tr10 587 } 588 switch { 589 case (m.data)[(m.p)] < 65: 590 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 591 goto st15 592 } 593 case (m.data)[(m.p)] > 90: 594 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 595 goto st15 596 } 597 default: 598 goto st15 599 } 600 goto tr6 601 st15: 602 if (m.p)++; (m.p) == (m.pe) { 603 goto _testEof15 604 } 605 stCase15: 606 switch (m.data)[(m.p)] { 607 case 45: 608 goto st16 609 case 58: 610 goto tr10 611 } 612 switch { 613 case (m.data)[(m.p)] < 65: 614 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 615 goto st16 616 } 617 case (m.data)[(m.p)] > 90: 618 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 619 goto st16 620 } 621 default: 622 goto st16 623 } 624 goto tr6 625 st16: 626 if (m.p)++; (m.p) == (m.pe) { 627 goto _testEof16 628 } 629 stCase16: 630 switch (m.data)[(m.p)] { 631 case 45: 632 goto st17 633 case 58: 634 goto tr10 635 } 636 switch { 637 case (m.data)[(m.p)] < 65: 638 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 639 goto st17 640 } 641 case (m.data)[(m.p)] > 90: 642 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 643 goto st17 644 } 645 default: 646 goto st17 647 } 648 goto tr6 649 st17: 650 if (m.p)++; (m.p) == (m.pe) { 651 goto _testEof17 652 } 653 stCase17: 654 switch (m.data)[(m.p)] { 655 case 45: 656 goto st18 657 case 58: 658 goto tr10 659 } 660 switch { 661 case (m.data)[(m.p)] < 65: 662 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 663 goto st18 664 } 665 case (m.data)[(m.p)] > 90: 666 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 667 goto st18 668 } 669 default: 670 goto st18 671 } 672 goto tr6 673 st18: 674 if (m.p)++; (m.p) == (m.pe) { 675 goto _testEof18 676 } 677 stCase18: 678 switch (m.data)[(m.p)] { 679 case 45: 680 goto st19 681 case 58: 682 goto tr10 683 } 684 switch { 685 case (m.data)[(m.p)] < 65: 686 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 687 goto st19 688 } 689 case (m.data)[(m.p)] > 90: 690 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 691 goto st19 692 } 693 default: 694 goto st19 695 } 696 goto tr6 697 st19: 698 if (m.p)++; (m.p) == (m.pe) { 699 goto _testEof19 700 } 701 stCase19: 702 switch (m.data)[(m.p)] { 703 case 45: 704 goto st20 705 case 58: 706 goto tr10 707 } 708 switch { 709 case (m.data)[(m.p)] < 65: 710 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 711 goto st20 712 } 713 case (m.data)[(m.p)] > 90: 714 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 715 goto st20 716 } 717 default: 718 goto st20 719 } 720 goto tr6 721 st20: 722 if (m.p)++; (m.p) == (m.pe) { 723 goto _testEof20 724 } 725 stCase20: 726 switch (m.data)[(m.p)] { 727 case 45: 728 goto st21 729 case 58: 730 goto tr10 731 } 732 switch { 733 case (m.data)[(m.p)] < 65: 734 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 735 goto st21 736 } 737 case (m.data)[(m.p)] > 90: 738 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 739 goto st21 740 } 741 default: 742 goto st21 743 } 744 goto tr6 745 st21: 746 if (m.p)++; (m.p) == (m.pe) { 747 goto _testEof21 748 } 749 stCase21: 750 switch (m.data)[(m.p)] { 751 case 45: 752 goto st22 753 case 58: 754 goto tr10 755 } 756 switch { 757 case (m.data)[(m.p)] < 65: 758 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 759 goto st22 760 } 761 case (m.data)[(m.p)] > 90: 762 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 763 goto st22 764 } 765 default: 766 goto st22 767 } 768 goto tr6 769 st22: 770 if (m.p)++; (m.p) == (m.pe) { 771 goto _testEof22 772 } 773 stCase22: 774 switch (m.data)[(m.p)] { 775 case 45: 776 goto st23 777 case 58: 778 goto tr10 779 } 780 switch { 781 case (m.data)[(m.p)] < 65: 782 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 783 goto st23 784 } 785 case (m.data)[(m.p)] > 90: 786 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 787 goto st23 788 } 789 default: 790 goto st23 791 } 792 goto tr6 793 st23: 794 if (m.p)++; (m.p) == (m.pe) { 795 goto _testEof23 796 } 797 stCase23: 798 switch (m.data)[(m.p)] { 799 case 45: 800 goto st24 801 case 58: 802 goto tr10 803 } 804 switch { 805 case (m.data)[(m.p)] < 65: 806 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 807 goto st24 808 } 809 case (m.data)[(m.p)] > 90: 810 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 811 goto st24 812 } 813 default: 814 goto st24 815 } 816 goto tr6 817 st24: 818 if (m.p)++; (m.p) == (m.pe) { 819 goto _testEof24 820 } 821 stCase24: 822 switch (m.data)[(m.p)] { 823 case 45: 824 goto st25 825 case 58: 826 goto tr10 827 } 828 switch { 829 case (m.data)[(m.p)] < 65: 830 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 831 goto st25 832 } 833 case (m.data)[(m.p)] > 90: 834 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 835 goto st25 836 } 837 default: 838 goto st25 839 } 840 goto tr6 841 st25: 842 if (m.p)++; (m.p) == (m.pe) { 843 goto _testEof25 844 } 845 stCase25: 846 switch (m.data)[(m.p)] { 847 case 45: 848 goto st26 849 case 58: 850 goto tr10 851 } 852 switch { 853 case (m.data)[(m.p)] < 65: 854 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 855 goto st26 856 } 857 case (m.data)[(m.p)] > 90: 858 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 859 goto st26 860 } 861 default: 862 goto st26 863 } 864 goto tr6 865 st26: 866 if (m.p)++; (m.p) == (m.pe) { 867 goto _testEof26 868 } 869 stCase26: 870 switch (m.data)[(m.p)] { 871 case 45: 872 goto st27 873 case 58: 874 goto tr10 875 } 876 switch { 877 case (m.data)[(m.p)] < 65: 878 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 879 goto st27 880 } 881 case (m.data)[(m.p)] > 90: 882 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 883 goto st27 884 } 885 default: 886 goto st27 887 } 888 goto tr6 889 st27: 890 if (m.p)++; (m.p) == (m.pe) { 891 goto _testEof27 892 } 893 stCase27: 894 switch (m.data)[(m.p)] { 895 case 45: 896 goto st28 897 case 58: 898 goto tr10 899 } 900 switch { 901 case (m.data)[(m.p)] < 65: 902 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 903 goto st28 904 } 905 case (m.data)[(m.p)] > 90: 906 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 907 goto st28 908 } 909 default: 910 goto st28 911 } 912 goto tr6 913 st28: 914 if (m.p)++; (m.p) == (m.pe) { 915 goto _testEof28 916 } 917 stCase28: 918 switch (m.data)[(m.p)] { 919 case 45: 920 goto st29 921 case 58: 922 goto tr10 923 } 924 switch { 925 case (m.data)[(m.p)] < 65: 926 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 927 goto st29 928 } 929 case (m.data)[(m.p)] > 90: 930 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 931 goto st29 932 } 933 default: 934 goto st29 935 } 936 goto tr6 937 st29: 938 if (m.p)++; (m.p) == (m.pe) { 939 goto _testEof29 940 } 941 stCase29: 942 switch (m.data)[(m.p)] { 943 case 45: 944 goto st30 945 case 58: 946 goto tr10 947 } 948 switch { 949 case (m.data)[(m.p)] < 65: 950 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 951 goto st30 952 } 953 case (m.data)[(m.p)] > 90: 954 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 955 goto st30 956 } 957 default: 958 goto st30 959 } 960 goto tr6 961 st30: 962 if (m.p)++; (m.p) == (m.pe) { 963 goto _testEof30 964 } 965 stCase30: 966 switch (m.data)[(m.p)] { 967 case 45: 968 goto st31 969 case 58: 970 goto tr10 971 } 972 switch { 973 case (m.data)[(m.p)] < 65: 974 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 975 goto st31 976 } 977 case (m.data)[(m.p)] > 90: 978 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 979 goto st31 980 } 981 default: 982 goto st31 983 } 984 goto tr6 985 st31: 986 if (m.p)++; (m.p) == (m.pe) { 987 goto _testEof31 988 } 989 stCase31: 990 switch (m.data)[(m.p)] { 991 case 45: 992 goto st32 993 case 58: 994 goto tr10 995 } 996 switch { 997 case (m.data)[(m.p)] < 65: 998 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 999 goto st32 1000 } 1001 case (m.data)[(m.p)] > 90: 1002 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1003 goto st32 1004 } 1005 default: 1006 goto st32 1007 } 1008 goto tr6 1009 st32: 1010 if (m.p)++; (m.p) == (m.pe) { 1011 goto _testEof32 1012 } 1013 stCase32: 1014 switch (m.data)[(m.p)] { 1015 case 45: 1016 goto st33 1017 case 58: 1018 goto tr10 1019 } 1020 switch { 1021 case (m.data)[(m.p)] < 65: 1022 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 1023 goto st33 1024 } 1025 case (m.data)[(m.p)] > 90: 1026 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1027 goto st33 1028 } 1029 default: 1030 goto st33 1031 } 1032 goto tr6 1033 st33: 1034 if (m.p)++; (m.p) == (m.pe) { 1035 goto _testEof33 1036 } 1037 stCase33: 1038 switch (m.data)[(m.p)] { 1039 case 45: 1040 goto st34 1041 case 58: 1042 goto tr10 1043 } 1044 switch { 1045 case (m.data)[(m.p)] < 65: 1046 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 1047 goto st34 1048 } 1049 case (m.data)[(m.p)] > 90: 1050 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1051 goto st34 1052 } 1053 default: 1054 goto st34 1055 } 1056 goto tr6 1057 st34: 1058 if (m.p)++; (m.p) == (m.pe) { 1059 goto _testEof34 1060 } 1061 stCase34: 1062 switch (m.data)[(m.p)] { 1063 case 45: 1064 goto st35 1065 case 58: 1066 goto tr10 1067 } 1068 switch { 1069 case (m.data)[(m.p)] < 65: 1070 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 1071 goto st35 1072 } 1073 case (m.data)[(m.p)] > 90: 1074 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1075 goto st35 1076 } 1077 default: 1078 goto st35 1079 } 1080 goto tr6 1081 st35: 1082 if (m.p)++; (m.p) == (m.pe) { 1083 goto _testEof35 1084 } 1085 stCase35: 1086 switch (m.data)[(m.p)] { 1087 case 45: 1088 goto st36 1089 case 58: 1090 goto tr10 1091 } 1092 switch { 1093 case (m.data)[(m.p)] < 65: 1094 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 1095 goto st36 1096 } 1097 case (m.data)[(m.p)] > 90: 1098 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1099 goto st36 1100 } 1101 default: 1102 goto st36 1103 } 1104 goto tr6 1105 st36: 1106 if (m.p)++; (m.p) == (m.pe) { 1107 goto _testEof36 1108 } 1109 stCase36: 1110 switch (m.data)[(m.p)] { 1111 case 45: 1112 goto st37 1113 case 58: 1114 goto tr10 1115 } 1116 switch { 1117 case (m.data)[(m.p)] < 65: 1118 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 1119 goto st37 1120 } 1121 case (m.data)[(m.p)] > 90: 1122 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1123 goto st37 1124 } 1125 default: 1126 goto st37 1127 } 1128 goto tr6 1129 st37: 1130 if (m.p)++; (m.p) == (m.pe) { 1131 goto _testEof37 1132 } 1133 stCase37: 1134 if (m.data)[(m.p)] == 58 { 1135 goto tr10 1136 } 1137 goto tr6 1138 tr10: 1139 1140 output.ID = string(m.text()) 1141 1142 goto st38 1143 st38: 1144 if (m.p)++; (m.p) == (m.pe) { 1145 goto _testEof38 1146 } 1147 stCase38: 1148 switch (m.data)[(m.p)] { 1149 case 33: 1150 goto tr42 1151 case 36: 1152 goto tr42 1153 case 37: 1154 goto tr43 1155 case 61: 1156 goto tr42 1157 case 95: 1158 goto tr42 1159 } 1160 switch { 1161 case (m.data)[(m.p)] < 48: 1162 if 39 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 46 { 1163 goto tr42 1164 } 1165 case (m.data)[(m.p)] > 59: 1166 switch { 1167 case (m.data)[(m.p)] > 90: 1168 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1169 goto tr42 1170 } 1171 case (m.data)[(m.p)] >= 64: 1172 goto tr42 1173 } 1174 default: 1175 goto tr42 1176 } 1177 goto tr41 1178 tr42: 1179 1180 m.pb = m.p 1181 1182 goto st44 1183 st44: 1184 if (m.p)++; (m.p) == (m.pe) { 1185 goto _testEof44 1186 } 1187 stCase44: 1188 switch (m.data)[(m.p)] { 1189 case 33: 1190 goto st44 1191 case 36: 1192 goto st44 1193 case 37: 1194 goto st39 1195 case 61: 1196 goto st44 1197 case 95: 1198 goto st44 1199 } 1200 switch { 1201 case (m.data)[(m.p)] < 48: 1202 if 39 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 46 { 1203 goto st44 1204 } 1205 case (m.data)[(m.p)] > 59: 1206 switch { 1207 case (m.data)[(m.p)] > 90: 1208 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1209 goto st44 1210 } 1211 case (m.data)[(m.p)] >= 64: 1212 goto st44 1213 } 1214 default: 1215 goto st44 1216 } 1217 goto tr41 1218 tr43: 1219 1220 m.pb = m.p 1221 1222 goto st39 1223 st39: 1224 if (m.p)++; (m.p) == (m.pe) { 1225 goto _testEof39 1226 } 1227 stCase39: 1228 switch { 1229 case (m.data)[(m.p)] < 65: 1230 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 1231 goto st40 1232 } 1233 case (m.data)[(m.p)] > 90: 1234 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1235 goto st40 1236 } 1237 default: 1238 goto tr46 1239 } 1240 goto tr44 1241 tr46: 1242 1243 m.tolower = append(m.tolower, m.p-m.pb) 1244 1245 goto st40 1246 st40: 1247 if (m.p)++; (m.p) == (m.pe) { 1248 goto _testEof40 1249 } 1250 stCase40: 1251 switch { 1252 case (m.data)[(m.p)] < 65: 1253 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 1254 goto st45 1255 } 1256 case (m.data)[(m.p)] > 90: 1257 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1258 goto st45 1259 } 1260 default: 1261 goto tr48 1262 } 1263 goto tr44 1264 tr48: 1265 1266 m.tolower = append(m.tolower, m.p-m.pb) 1267 1268 goto st45 1269 st45: 1270 if (m.p)++; (m.p) == (m.pe) { 1271 goto _testEof45 1272 } 1273 stCase45: 1274 switch (m.data)[(m.p)] { 1275 case 33: 1276 goto st44 1277 case 36: 1278 goto st44 1279 case 37: 1280 goto st39 1281 case 61: 1282 goto st44 1283 case 95: 1284 goto st44 1285 } 1286 switch { 1287 case (m.data)[(m.p)] < 48: 1288 if 39 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 46 { 1289 goto st44 1290 } 1291 case (m.data)[(m.p)] > 59: 1292 switch { 1293 case (m.data)[(m.p)] > 90: 1294 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1295 goto st44 1296 } 1297 case (m.data)[(m.p)] >= 64: 1298 goto st44 1299 } 1300 default: 1301 goto st44 1302 } 1303 goto tr44 1304 tr8: 1305 1306 m.pb = m.p 1307 1308 goto st41 1309 st41: 1310 if (m.p)++; (m.p) == (m.pe) { 1311 goto _testEof41 1312 } 1313 stCase41: 1314 switch (m.data)[(m.p)] { 1315 case 45: 1316 goto st7 1317 case 58: 1318 goto tr10 1319 case 82: 1320 goto st42 1321 case 114: 1322 goto st42 1323 } 1324 switch { 1325 case (m.data)[(m.p)] < 65: 1326 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 1327 goto st7 1328 } 1329 case (m.data)[(m.p)] > 90: 1330 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1331 goto st7 1332 } 1333 default: 1334 goto st7 1335 } 1336 goto tr6 1337 st42: 1338 if (m.p)++; (m.p) == (m.pe) { 1339 goto _testEof42 1340 } 1341 stCase42: 1342 switch (m.data)[(m.p)] { 1343 case 45: 1344 goto st8 1345 case 58: 1346 goto tr10 1347 case 78: 1348 goto st43 1349 case 110: 1350 goto st43 1351 } 1352 switch { 1353 case (m.data)[(m.p)] < 65: 1354 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 1355 goto st8 1356 } 1357 case (m.data)[(m.p)] > 90: 1358 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1359 goto st8 1360 } 1361 default: 1362 goto st8 1363 } 1364 goto tr50 1365 st43: 1366 if (m.p)++; (m.p) == (m.pe) { 1367 goto _testEof43 1368 } 1369 stCase43: 1370 if (m.data)[(m.p)] == 45 { 1371 goto st9 1372 } 1373 switch { 1374 case (m.data)[(m.p)] < 65: 1375 if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 { 1376 goto st9 1377 } 1378 case (m.data)[(m.p)] > 90: 1379 if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 { 1380 goto st9 1381 } 1382 default: 1383 goto st9 1384 } 1385 goto tr52 1386 st46: 1387 if (m.p)++; (m.p) == (m.pe) { 1388 goto _testEof46 1389 } 1390 stCase46: 1391 switch (m.data)[(m.p)] { 1392 case 10: 1393 goto st0 1394 case 13: 1395 goto st0 1396 } 1397 goto st46 1398 stOut: 1399 _testEof2: 1400 m.cs = 2 1401 goto _testEof 1402 _testEof3: 1403 m.cs = 3 1404 goto _testEof 1405 _testEof4: 1406 m.cs = 4 1407 goto _testEof 1408 _testEof5: 1409 m.cs = 5 1410 goto _testEof 1411 _testEof6: 1412 m.cs = 6 1413 goto _testEof 1414 _testEof7: 1415 m.cs = 7 1416 goto _testEof 1417 _testEof8: 1418 m.cs = 8 1419 goto _testEof 1420 _testEof9: 1421 m.cs = 9 1422 goto _testEof 1423 _testEof10: 1424 m.cs = 10 1425 goto _testEof 1426 _testEof11: 1427 m.cs = 11 1428 goto _testEof 1429 _testEof12: 1430 m.cs = 12 1431 goto _testEof 1432 _testEof13: 1433 m.cs = 13 1434 goto _testEof 1435 _testEof14: 1436 m.cs = 14 1437 goto _testEof 1438 _testEof15: 1439 m.cs = 15 1440 goto _testEof 1441 _testEof16: 1442 m.cs = 16 1443 goto _testEof 1444 _testEof17: 1445 m.cs = 17 1446 goto _testEof 1447 _testEof18: 1448 m.cs = 18 1449 goto _testEof 1450 _testEof19: 1451 m.cs = 19 1452 goto _testEof 1453 _testEof20: 1454 m.cs = 20 1455 goto _testEof 1456 _testEof21: 1457 m.cs = 21 1458 goto _testEof 1459 _testEof22: 1460 m.cs = 22 1461 goto _testEof 1462 _testEof23: 1463 m.cs = 23 1464 goto _testEof 1465 _testEof24: 1466 m.cs = 24 1467 goto _testEof 1468 _testEof25: 1469 m.cs = 25 1470 goto _testEof 1471 _testEof26: 1472 m.cs = 26 1473 goto _testEof 1474 _testEof27: 1475 m.cs = 27 1476 goto _testEof 1477 _testEof28: 1478 m.cs = 28 1479 goto _testEof 1480 _testEof29: 1481 m.cs = 29 1482 goto _testEof 1483 _testEof30: 1484 m.cs = 30 1485 goto _testEof 1486 _testEof31: 1487 m.cs = 31 1488 goto _testEof 1489 _testEof32: 1490 m.cs = 32 1491 goto _testEof 1492 _testEof33: 1493 m.cs = 33 1494 goto _testEof 1495 _testEof34: 1496 m.cs = 34 1497 goto _testEof 1498 _testEof35: 1499 m.cs = 35 1500 goto _testEof 1501 _testEof36: 1502 m.cs = 36 1503 goto _testEof 1504 _testEof37: 1505 m.cs = 37 1506 goto _testEof 1507 _testEof38: 1508 m.cs = 38 1509 goto _testEof 1510 _testEof44: 1511 m.cs = 44 1512 goto _testEof 1513 _testEof39: 1514 m.cs = 39 1515 goto _testEof 1516 _testEof40: 1517 m.cs = 40 1518 goto _testEof 1519 _testEof45: 1520 m.cs = 45 1521 goto _testEof 1522 _testEof41: 1523 m.cs = 41 1524 goto _testEof 1525 _testEof42: 1526 m.cs = 42 1527 goto _testEof 1528 _testEof43: 1529 m.cs = 43 1530 goto _testEof 1531 _testEof46: 1532 m.cs = 46 1533 goto _testEof 1534 1535 _testEof: 1536 { 1537 } 1538 if (m.p) == (m.eof) { 1539 switch m.cs { 1540 case 44, 45: 1541 1542 raw := m.text() 1543 output.SS = string(raw) 1544 // Iterate upper letters lowering them 1545 for _, i := range m.tolower { 1546 raw[i] = raw[i] + 32 1547 } 1548 output.norm = string(raw) 1549 1550 case 1, 2, 4: 1551 1552 m.err = fmt.Errorf(errParse, m.p) 1553 (m.p)-- 1554 1555 { 1556 goto st46 1557 } 1558 1559 case 3: 1560 1561 m.err = fmt.Errorf(errPrefix, m.p) 1562 (m.p)-- 1563 1564 { 1565 goto st46 1566 } 1567 1568 m.err = fmt.Errorf(errParse, m.p) 1569 (m.p)-- 1570 1571 { 1572 goto st46 1573 } 1574 1575 case 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 41: 1576 1577 m.err = fmt.Errorf(errIdentifier, m.p) 1578 (m.p)-- 1579 1580 { 1581 goto st46 1582 } 1583 1584 m.err = fmt.Errorf(errParse, m.p) 1585 (m.p)-- 1586 1587 { 1588 goto st46 1589 } 1590 1591 case 38: 1592 1593 m.err = fmt.Errorf(errSpecificString, m.p) 1594 (m.p)-- 1595 1596 { 1597 goto st46 1598 } 1599 1600 m.err = fmt.Errorf(errParse, m.p) 1601 (m.p)-- 1602 1603 { 1604 goto st46 1605 } 1606 1607 case 42: 1608 1609 m.err = fmt.Errorf(errPrefix, m.p) 1610 (m.p)-- 1611 1612 { 1613 goto st46 1614 } 1615 1616 m.err = fmt.Errorf(errIdentifier, m.p) 1617 (m.p)-- 1618 1619 { 1620 goto st46 1621 } 1622 1623 m.err = fmt.Errorf(errParse, m.p) 1624 (m.p)-- 1625 1626 { 1627 goto st46 1628 } 1629 1630 case 43: 1631 1632 m.err = fmt.Errorf(errNoUrnWithinID, m.p) 1633 (m.p)-- 1634 1635 { 1636 goto st46 1637 } 1638 1639 m.err = fmt.Errorf(errIdentifier, m.p) 1640 (m.p)-- 1641 1642 { 1643 goto st46 1644 } 1645 1646 m.err = fmt.Errorf(errParse, m.p) 1647 (m.p)-- 1648 1649 { 1650 goto st46 1651 } 1652 1653 case 39, 40: 1654 1655 m.err = fmt.Errorf(errHex, m.p) 1656 (m.p)-- 1657 1658 { 1659 goto st46 1660 } 1661 1662 m.err = fmt.Errorf(errSpecificString, m.p) 1663 (m.p)-- 1664 1665 { 1666 goto st46 1667 } 1668 1669 m.err = fmt.Errorf(errParse, m.p) 1670 (m.p)-- 1671 1672 { 1673 goto st46 1674 } 1675 } 1676 } 1677 1678 _out: 1679 { 1680 } 1681 } 1682 1683 if m.cs < firstFinal || m.cs == enFail { 1684 return nil, m.err 1685 } 1686 1687 return output, nil 1688 }