github.com/maruel/nin@v0.0.0-20220112143044-f35891e3ce7e/lexer.go (about) 1 // Code generated by re2c, DO NOT EDIT. 2 // Copyright 2011 Google Inc. All Rights Reserved. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 package nin 17 18 import ( 19 "errors" 20 "fmt" 21 "strings" 22 ) 23 24 type Token int32 25 26 const ( 27 ERROR Token = iota 28 BUILD 29 COLON 30 DEFAULT 31 EQUALS 32 IDENT 33 INCLUDE 34 INDENT 35 NEWLINE 36 PIPE 37 PIPE2 38 PIPEAT 39 POOL 40 RULE 41 SUBNINJA 42 TEOF 43 ) 44 45 // String() returns a human-readable form of a token, used in error messages. 46 func (t Token) String() string { 47 switch t { 48 case ERROR: 49 return "lexing error" 50 case BUILD: 51 return "'build'" 52 case COLON: 53 return "':'" 54 case DEFAULT: 55 return "'default'" 56 case EQUALS: 57 return "'='" 58 case IDENT: 59 return "identifier" 60 case INCLUDE: 61 return "'include'" 62 case INDENT: 63 return "indent" 64 case NEWLINE: 65 return "newline" 66 case PIPE2: 67 return "'||'" 68 case PIPE: 69 return "'|'" 70 case PIPEAT: 71 return "'|@'" 72 case POOL: 73 return "'pool'" 74 case RULE: 75 return "'rule'" 76 case SUBNINJA: 77 return "'subninja'" 78 case TEOF: 79 return "eof" 80 } 81 return "" // not reached 82 } 83 84 // errorHint returns a human-readable token hint, used in error messages. 85 func (t Token) errorHint() string { 86 if t == COLON { 87 return " ($ also escapes ':')" 88 } 89 return "" 90 } 91 92 // lexerOffset permits quickly toggling between int64 and int32 to measure 93 // performance impact. 94 type lexerOffset = int 95 96 // lexerState is the offset of processing a token. 97 // 98 // It is meant to be saved when an error message may be printed after the 99 // parsing continued. 100 type lexerState struct { 101 // In the original C++ code, these two are char pointers and are used to do 102 // pointer arithmetics. Go doesn't allow pointer arithmetics so they are 103 // indexes. ofs starts at 0. lastToken is initially -1 to mark that it is 104 // not yet set. 105 ofs lexerOffset 106 lastToken lexerOffset 107 } 108 109 // error constructs an error message with context. 110 func (l *lexerState) error(message, filename string, input []byte) error { 111 // Compute line/column. 112 line := lexerOffset(1) 113 lineStart := lexerOffset(0) 114 for p := lexerOffset(0); p < l.lastToken; p++ { 115 if input[p] == '\n' { 116 line++ 117 lineStart = p + 1 118 } 119 } 120 col := lexerOffset(0) 121 if l.lastToken != -1 { 122 col = l.lastToken - lineStart 123 } 124 125 // Add some context to the message. 126 c := "" 127 const truncateColumn = 72 128 if col > 0 && col < truncateColumn { 129 truncated := true 130 length := lexerOffset(0) 131 for ; length < truncateColumn; length++ { 132 if input[lineStart+length] == 0 || input[lineStart+length] == '\n' { 133 truncated = false 134 break 135 } 136 } 137 c = unsafeString(input[lineStart : lineStart+length]) 138 if truncated { 139 c += "..." 140 } 141 c += "\n" 142 c += strings.Repeat(" ", int(col)) 143 c += "^ near here" 144 } 145 // TODO(maruel): There's a problem where the error is wrapped, thus the alignment doesn't work. 146 return fmt.Errorf("%s:%d: %s\n%s", filename, line, message, c) 147 } 148 149 type lexer struct { 150 // Immutable. 151 filename string 152 input []byte 153 154 // Mutable. 155 lexerState 156 } 157 158 // Error constructs an error message with context. 159 func (l *lexer) Error(message string) error { 160 return l.lexerState.error(message, l.filename, l.input) 161 } 162 163 // Start parsing some input. 164 func (l *lexer) Start(filename string, input []byte) error { 165 l.filename = filename 166 if input[len(input)-1] != 0 { 167 panic("Requires hack with a trailing 0 byte") 168 } 169 if len(input) > 0x7fffffff { 170 return errors.New("input larger than 2gb is not supported") 171 } 172 l.input = input 173 l.ofs = 0 174 l.lastToken = -1 175 return nil 176 } 177 178 // If the last token read was an ERROR token, provide more info 179 // or the empty string. 180 func (l *lexer) DescribeLastError() string { 181 if l.lastToken != -1 { 182 switch l.input[l.lastToken] { 183 case '\t': 184 return "tabs are not allowed, use spaces" 185 } 186 } 187 return "lexing error" 188 } 189 190 // Rewind to the last read Token. 191 func (l *lexer) UnreadToken() { 192 l.ofs = l.lastToken 193 } 194 195 func (l *lexer) ReadToken() Token { 196 p := l.ofs 197 q := lexerOffset(0) 198 start := lexerOffset(0) 199 var token Token 200 for { 201 start = p 202 203 { 204 var yych byte 205 yyaccept := 0 206 yych = l.input[p] 207 switch yych { 208 case 0x00: 209 goto yy2 210 case '\n': 211 goto yy6 212 case '\r': 213 goto yy8 214 case ' ': 215 goto yy9 216 case '#': 217 goto yy12 218 case '-': 219 fallthrough 220 case '.': 221 fallthrough 222 case '0': 223 fallthrough 224 case '1': 225 fallthrough 226 case '2': 227 fallthrough 228 case '3': 229 fallthrough 230 case '4': 231 fallthrough 232 case '5': 233 fallthrough 234 case '6': 235 fallthrough 236 case '7': 237 fallthrough 238 case '8': 239 fallthrough 240 case '9': 241 fallthrough 242 case 'A': 243 fallthrough 244 case 'B': 245 fallthrough 246 case 'C': 247 fallthrough 248 case 'D': 249 fallthrough 250 case 'E': 251 fallthrough 252 case 'F': 253 fallthrough 254 case 'G': 255 fallthrough 256 case 'H': 257 fallthrough 258 case 'I': 259 fallthrough 260 case 'J': 261 fallthrough 262 case 'K': 263 fallthrough 264 case 'L': 265 fallthrough 266 case 'M': 267 fallthrough 268 case 'N': 269 fallthrough 270 case 'O': 271 fallthrough 272 case 'P': 273 fallthrough 274 case 'Q': 275 fallthrough 276 case 'R': 277 fallthrough 278 case 'S': 279 fallthrough 280 case 'T': 281 fallthrough 282 case 'U': 283 fallthrough 284 case 'V': 285 fallthrough 286 case 'W': 287 fallthrough 288 case 'X': 289 fallthrough 290 case 'Y': 291 fallthrough 292 case 'Z': 293 fallthrough 294 case '_': 295 fallthrough 296 case 'a': 297 fallthrough 298 case 'c': 299 fallthrough 300 case 'e': 301 fallthrough 302 case 'f': 303 fallthrough 304 case 'g': 305 fallthrough 306 case 'h': 307 fallthrough 308 case 'j': 309 fallthrough 310 case 'k': 311 fallthrough 312 case 'l': 313 fallthrough 314 case 'm': 315 fallthrough 316 case 'n': 317 fallthrough 318 case 'o': 319 fallthrough 320 case 'q': 321 fallthrough 322 case 't': 323 fallthrough 324 case 'u': 325 fallthrough 326 case 'v': 327 fallthrough 328 case 'w': 329 fallthrough 330 case 'x': 331 fallthrough 332 case 'y': 333 fallthrough 334 case 'z': 335 goto yy13 336 case ':': 337 goto yy16 338 case '=': 339 goto yy18 340 case 'b': 341 goto yy20 342 case 'd': 343 goto yy21 344 case 'i': 345 goto yy22 346 case 'p': 347 goto yy23 348 case 'r': 349 goto yy24 350 case 's': 351 goto yy25 352 case '|': 353 goto yy26 354 default: 355 goto yy4 356 } 357 yy2: 358 p++ 359 { 360 token = TEOF 361 break 362 } 363 yy4: 364 p++ 365 yy5: 366 { 367 token = ERROR 368 break 369 } 370 yy6: 371 p++ 372 { 373 token = NEWLINE 374 break 375 } 376 yy8: 377 p++ 378 yych = l.input[p] 379 switch yych { 380 case '\n': 381 goto yy28 382 default: 383 goto yy5 384 } 385 yy9: 386 yyaccept = 0 387 p++ 388 q = p 389 yych = l.input[p] 390 switch yych { 391 case '\n': 392 goto yy6 393 case '\r': 394 goto yy30 395 case ' ': 396 goto yy9 397 case '#': 398 goto yy32 399 default: 400 goto yy11 401 } 402 yy11: 403 { 404 token = INDENT 405 break 406 } 407 yy12: 408 yyaccept = 1 409 p++ 410 q = p 411 yych = l.input[p] 412 if yych <= 0x00 { 413 goto yy5 414 } 415 goto yy33 416 yy13: 417 p++ 418 yych = l.input[p] 419 yy14: 420 switch yych { 421 case '-': 422 fallthrough 423 case '.': 424 fallthrough 425 case '0': 426 fallthrough 427 case '1': 428 fallthrough 429 case '2': 430 fallthrough 431 case '3': 432 fallthrough 433 case '4': 434 fallthrough 435 case '5': 436 fallthrough 437 case '6': 438 fallthrough 439 case '7': 440 fallthrough 441 case '8': 442 fallthrough 443 case '9': 444 fallthrough 445 case 'A': 446 fallthrough 447 case 'B': 448 fallthrough 449 case 'C': 450 fallthrough 451 case 'D': 452 fallthrough 453 case 'E': 454 fallthrough 455 case 'F': 456 fallthrough 457 case 'G': 458 fallthrough 459 case 'H': 460 fallthrough 461 case 'I': 462 fallthrough 463 case 'J': 464 fallthrough 465 case 'K': 466 fallthrough 467 case 'L': 468 fallthrough 469 case 'M': 470 fallthrough 471 case 'N': 472 fallthrough 473 case 'O': 474 fallthrough 475 case 'P': 476 fallthrough 477 case 'Q': 478 fallthrough 479 case 'R': 480 fallthrough 481 case 'S': 482 fallthrough 483 case 'T': 484 fallthrough 485 case 'U': 486 fallthrough 487 case 'V': 488 fallthrough 489 case 'W': 490 fallthrough 491 case 'X': 492 fallthrough 493 case 'Y': 494 fallthrough 495 case 'Z': 496 fallthrough 497 case '_': 498 fallthrough 499 case 'a': 500 fallthrough 501 case 'b': 502 fallthrough 503 case 'c': 504 fallthrough 505 case 'd': 506 fallthrough 507 case 'e': 508 fallthrough 509 case 'f': 510 fallthrough 511 case 'g': 512 fallthrough 513 case 'h': 514 fallthrough 515 case 'i': 516 fallthrough 517 case 'j': 518 fallthrough 519 case 'k': 520 fallthrough 521 case 'l': 522 fallthrough 523 case 'm': 524 fallthrough 525 case 'n': 526 fallthrough 527 case 'o': 528 fallthrough 529 case 'p': 530 fallthrough 531 case 'q': 532 fallthrough 533 case 'r': 534 fallthrough 535 case 's': 536 fallthrough 537 case 't': 538 fallthrough 539 case 'u': 540 fallthrough 541 case 'v': 542 fallthrough 543 case 'w': 544 fallthrough 545 case 'x': 546 fallthrough 547 case 'y': 548 fallthrough 549 case 'z': 550 goto yy13 551 default: 552 goto yy15 553 } 554 yy15: 555 { 556 token = IDENT 557 break 558 } 559 yy16: 560 p++ 561 { 562 token = COLON 563 break 564 } 565 yy18: 566 p++ 567 { 568 token = EQUALS 569 break 570 } 571 yy20: 572 p++ 573 yych = l.input[p] 574 switch yych { 575 case 'u': 576 goto yy36 577 default: 578 goto yy14 579 } 580 yy21: 581 p++ 582 yych = l.input[p] 583 switch yych { 584 case 'e': 585 goto yy37 586 default: 587 goto yy14 588 } 589 yy22: 590 p++ 591 yych = l.input[p] 592 switch yych { 593 case 'n': 594 goto yy38 595 default: 596 goto yy14 597 } 598 yy23: 599 p++ 600 yych = l.input[p] 601 switch yych { 602 case 'o': 603 goto yy39 604 default: 605 goto yy14 606 } 607 yy24: 608 p++ 609 yych = l.input[p] 610 switch yych { 611 case 'u': 612 goto yy40 613 default: 614 goto yy14 615 } 616 yy25: 617 p++ 618 yych = l.input[p] 619 switch yych { 620 case 'u': 621 goto yy41 622 default: 623 goto yy14 624 } 625 yy26: 626 p++ 627 yych = l.input[p] 628 switch yych { 629 case '@': 630 goto yy42 631 case '|': 632 goto yy44 633 default: 634 goto yy27 635 } 636 yy27: 637 { 638 token = PIPE 639 break 640 } 641 yy28: 642 p++ 643 { 644 token = NEWLINE 645 break 646 } 647 yy30: 648 p++ 649 yych = l.input[p] 650 switch yych { 651 case '\n': 652 goto yy28 653 default: 654 goto yy31 655 } 656 yy31: 657 p = q 658 if yyaccept == 0 { 659 goto yy11 660 } else { 661 goto yy5 662 } 663 yy32: 664 p++ 665 yych = l.input[p] 666 yy33: 667 switch yych { 668 case 0x00: 669 goto yy31 670 case '\n': 671 goto yy34 672 default: 673 goto yy32 674 } 675 yy34: 676 p++ 677 { 678 continue 679 } 680 yy36: 681 p++ 682 yych = l.input[p] 683 switch yych { 684 case 'i': 685 goto yy46 686 default: 687 goto yy14 688 } 689 yy37: 690 p++ 691 yych = l.input[p] 692 switch yych { 693 case 'f': 694 goto yy47 695 default: 696 goto yy14 697 } 698 yy38: 699 p++ 700 yych = l.input[p] 701 switch yych { 702 case 'c': 703 goto yy48 704 default: 705 goto yy14 706 } 707 yy39: 708 p++ 709 yych = l.input[p] 710 switch yych { 711 case 'o': 712 goto yy49 713 default: 714 goto yy14 715 } 716 yy40: 717 p++ 718 yych = l.input[p] 719 switch yych { 720 case 'l': 721 goto yy50 722 default: 723 goto yy14 724 } 725 yy41: 726 p++ 727 yych = l.input[p] 728 switch yych { 729 case 'b': 730 goto yy51 731 default: 732 goto yy14 733 } 734 yy42: 735 p++ 736 { 737 token = PIPEAT 738 break 739 } 740 yy44: 741 p++ 742 { 743 token = PIPE2 744 break 745 } 746 yy46: 747 p++ 748 yych = l.input[p] 749 switch yych { 750 case 'l': 751 goto yy52 752 default: 753 goto yy14 754 } 755 yy47: 756 p++ 757 yych = l.input[p] 758 switch yych { 759 case 'a': 760 goto yy53 761 default: 762 goto yy14 763 } 764 yy48: 765 p++ 766 yych = l.input[p] 767 switch yych { 768 case 'l': 769 goto yy54 770 default: 771 goto yy14 772 } 773 yy49: 774 p++ 775 yych = l.input[p] 776 switch yych { 777 case 'l': 778 goto yy55 779 default: 780 goto yy14 781 } 782 yy50: 783 p++ 784 yych = l.input[p] 785 switch yych { 786 case 'e': 787 goto yy57 788 default: 789 goto yy14 790 } 791 yy51: 792 p++ 793 yych = l.input[p] 794 switch yych { 795 case 'n': 796 goto yy59 797 default: 798 goto yy14 799 } 800 yy52: 801 p++ 802 yych = l.input[p] 803 switch yych { 804 case 'd': 805 goto yy60 806 default: 807 goto yy14 808 } 809 yy53: 810 p++ 811 yych = l.input[p] 812 switch yych { 813 case 'u': 814 goto yy62 815 default: 816 goto yy14 817 } 818 yy54: 819 p++ 820 yych = l.input[p] 821 switch yych { 822 case 'u': 823 goto yy63 824 default: 825 goto yy14 826 } 827 yy55: 828 p++ 829 yych = l.input[p] 830 switch yych { 831 case '-': 832 fallthrough 833 case '.': 834 fallthrough 835 case '0': 836 fallthrough 837 case '1': 838 fallthrough 839 case '2': 840 fallthrough 841 case '3': 842 fallthrough 843 case '4': 844 fallthrough 845 case '5': 846 fallthrough 847 case '6': 848 fallthrough 849 case '7': 850 fallthrough 851 case '8': 852 fallthrough 853 case '9': 854 fallthrough 855 case 'A': 856 fallthrough 857 case 'B': 858 fallthrough 859 case 'C': 860 fallthrough 861 case 'D': 862 fallthrough 863 case 'E': 864 fallthrough 865 case 'F': 866 fallthrough 867 case 'G': 868 fallthrough 869 case 'H': 870 fallthrough 871 case 'I': 872 fallthrough 873 case 'J': 874 fallthrough 875 case 'K': 876 fallthrough 877 case 'L': 878 fallthrough 879 case 'M': 880 fallthrough 881 case 'N': 882 fallthrough 883 case 'O': 884 fallthrough 885 case 'P': 886 fallthrough 887 case 'Q': 888 fallthrough 889 case 'R': 890 fallthrough 891 case 'S': 892 fallthrough 893 case 'T': 894 fallthrough 895 case 'U': 896 fallthrough 897 case 'V': 898 fallthrough 899 case 'W': 900 fallthrough 901 case 'X': 902 fallthrough 903 case 'Y': 904 fallthrough 905 case 'Z': 906 fallthrough 907 case '_': 908 fallthrough 909 case 'a': 910 fallthrough 911 case 'b': 912 fallthrough 913 case 'c': 914 fallthrough 915 case 'd': 916 fallthrough 917 case 'e': 918 fallthrough 919 case 'f': 920 fallthrough 921 case 'g': 922 fallthrough 923 case 'h': 924 fallthrough 925 case 'i': 926 fallthrough 927 case 'j': 928 fallthrough 929 case 'k': 930 fallthrough 931 case 'l': 932 fallthrough 933 case 'm': 934 fallthrough 935 case 'n': 936 fallthrough 937 case 'o': 938 fallthrough 939 case 'p': 940 fallthrough 941 case 'q': 942 fallthrough 943 case 'r': 944 fallthrough 945 case 's': 946 fallthrough 947 case 't': 948 fallthrough 949 case 'u': 950 fallthrough 951 case 'v': 952 fallthrough 953 case 'w': 954 fallthrough 955 case 'x': 956 fallthrough 957 case 'y': 958 fallthrough 959 case 'z': 960 goto yy13 961 default: 962 goto yy56 963 } 964 yy56: 965 { 966 token = POOL 967 break 968 } 969 yy57: 970 p++ 971 yych = l.input[p] 972 switch yych { 973 case '-': 974 fallthrough 975 case '.': 976 fallthrough 977 case '0': 978 fallthrough 979 case '1': 980 fallthrough 981 case '2': 982 fallthrough 983 case '3': 984 fallthrough 985 case '4': 986 fallthrough 987 case '5': 988 fallthrough 989 case '6': 990 fallthrough 991 case '7': 992 fallthrough 993 case '8': 994 fallthrough 995 case '9': 996 fallthrough 997 case 'A': 998 fallthrough 999 case 'B': 1000 fallthrough 1001 case 'C': 1002 fallthrough 1003 case 'D': 1004 fallthrough 1005 case 'E': 1006 fallthrough 1007 case 'F': 1008 fallthrough 1009 case 'G': 1010 fallthrough 1011 case 'H': 1012 fallthrough 1013 case 'I': 1014 fallthrough 1015 case 'J': 1016 fallthrough 1017 case 'K': 1018 fallthrough 1019 case 'L': 1020 fallthrough 1021 case 'M': 1022 fallthrough 1023 case 'N': 1024 fallthrough 1025 case 'O': 1026 fallthrough 1027 case 'P': 1028 fallthrough 1029 case 'Q': 1030 fallthrough 1031 case 'R': 1032 fallthrough 1033 case 'S': 1034 fallthrough 1035 case 'T': 1036 fallthrough 1037 case 'U': 1038 fallthrough 1039 case 'V': 1040 fallthrough 1041 case 'W': 1042 fallthrough 1043 case 'X': 1044 fallthrough 1045 case 'Y': 1046 fallthrough 1047 case 'Z': 1048 fallthrough 1049 case '_': 1050 fallthrough 1051 case 'a': 1052 fallthrough 1053 case 'b': 1054 fallthrough 1055 case 'c': 1056 fallthrough 1057 case 'd': 1058 fallthrough 1059 case 'e': 1060 fallthrough 1061 case 'f': 1062 fallthrough 1063 case 'g': 1064 fallthrough 1065 case 'h': 1066 fallthrough 1067 case 'i': 1068 fallthrough 1069 case 'j': 1070 fallthrough 1071 case 'k': 1072 fallthrough 1073 case 'l': 1074 fallthrough 1075 case 'm': 1076 fallthrough 1077 case 'n': 1078 fallthrough 1079 case 'o': 1080 fallthrough 1081 case 'p': 1082 fallthrough 1083 case 'q': 1084 fallthrough 1085 case 'r': 1086 fallthrough 1087 case 's': 1088 fallthrough 1089 case 't': 1090 fallthrough 1091 case 'u': 1092 fallthrough 1093 case 'v': 1094 fallthrough 1095 case 'w': 1096 fallthrough 1097 case 'x': 1098 fallthrough 1099 case 'y': 1100 fallthrough 1101 case 'z': 1102 goto yy13 1103 default: 1104 goto yy58 1105 } 1106 yy58: 1107 { 1108 token = RULE 1109 break 1110 } 1111 yy59: 1112 p++ 1113 yych = l.input[p] 1114 switch yych { 1115 case 'i': 1116 goto yy64 1117 default: 1118 goto yy14 1119 } 1120 yy60: 1121 p++ 1122 yych = l.input[p] 1123 switch yych { 1124 case '-': 1125 fallthrough 1126 case '.': 1127 fallthrough 1128 case '0': 1129 fallthrough 1130 case '1': 1131 fallthrough 1132 case '2': 1133 fallthrough 1134 case '3': 1135 fallthrough 1136 case '4': 1137 fallthrough 1138 case '5': 1139 fallthrough 1140 case '6': 1141 fallthrough 1142 case '7': 1143 fallthrough 1144 case '8': 1145 fallthrough 1146 case '9': 1147 fallthrough 1148 case 'A': 1149 fallthrough 1150 case 'B': 1151 fallthrough 1152 case 'C': 1153 fallthrough 1154 case 'D': 1155 fallthrough 1156 case 'E': 1157 fallthrough 1158 case 'F': 1159 fallthrough 1160 case 'G': 1161 fallthrough 1162 case 'H': 1163 fallthrough 1164 case 'I': 1165 fallthrough 1166 case 'J': 1167 fallthrough 1168 case 'K': 1169 fallthrough 1170 case 'L': 1171 fallthrough 1172 case 'M': 1173 fallthrough 1174 case 'N': 1175 fallthrough 1176 case 'O': 1177 fallthrough 1178 case 'P': 1179 fallthrough 1180 case 'Q': 1181 fallthrough 1182 case 'R': 1183 fallthrough 1184 case 'S': 1185 fallthrough 1186 case 'T': 1187 fallthrough 1188 case 'U': 1189 fallthrough 1190 case 'V': 1191 fallthrough 1192 case 'W': 1193 fallthrough 1194 case 'X': 1195 fallthrough 1196 case 'Y': 1197 fallthrough 1198 case 'Z': 1199 fallthrough 1200 case '_': 1201 fallthrough 1202 case 'a': 1203 fallthrough 1204 case 'b': 1205 fallthrough 1206 case 'c': 1207 fallthrough 1208 case 'd': 1209 fallthrough 1210 case 'e': 1211 fallthrough 1212 case 'f': 1213 fallthrough 1214 case 'g': 1215 fallthrough 1216 case 'h': 1217 fallthrough 1218 case 'i': 1219 fallthrough 1220 case 'j': 1221 fallthrough 1222 case 'k': 1223 fallthrough 1224 case 'l': 1225 fallthrough 1226 case 'm': 1227 fallthrough 1228 case 'n': 1229 fallthrough 1230 case 'o': 1231 fallthrough 1232 case 'p': 1233 fallthrough 1234 case 'q': 1235 fallthrough 1236 case 'r': 1237 fallthrough 1238 case 's': 1239 fallthrough 1240 case 't': 1241 fallthrough 1242 case 'u': 1243 fallthrough 1244 case 'v': 1245 fallthrough 1246 case 'w': 1247 fallthrough 1248 case 'x': 1249 fallthrough 1250 case 'y': 1251 fallthrough 1252 case 'z': 1253 goto yy13 1254 default: 1255 goto yy61 1256 } 1257 yy61: 1258 { 1259 token = BUILD 1260 break 1261 } 1262 yy62: 1263 p++ 1264 yych = l.input[p] 1265 switch yych { 1266 case 'l': 1267 goto yy65 1268 default: 1269 goto yy14 1270 } 1271 yy63: 1272 p++ 1273 yych = l.input[p] 1274 switch yych { 1275 case 'd': 1276 goto yy66 1277 default: 1278 goto yy14 1279 } 1280 yy64: 1281 p++ 1282 yych = l.input[p] 1283 switch yych { 1284 case 'n': 1285 goto yy67 1286 default: 1287 goto yy14 1288 } 1289 yy65: 1290 p++ 1291 yych = l.input[p] 1292 switch yych { 1293 case 't': 1294 goto yy68 1295 default: 1296 goto yy14 1297 } 1298 yy66: 1299 p++ 1300 yych = l.input[p] 1301 switch yych { 1302 case 'e': 1303 goto yy70 1304 default: 1305 goto yy14 1306 } 1307 yy67: 1308 p++ 1309 yych = l.input[p] 1310 switch yych { 1311 case 'j': 1312 goto yy72 1313 default: 1314 goto yy14 1315 } 1316 yy68: 1317 p++ 1318 yych = l.input[p] 1319 switch yych { 1320 case '-': 1321 fallthrough 1322 case '.': 1323 fallthrough 1324 case '0': 1325 fallthrough 1326 case '1': 1327 fallthrough 1328 case '2': 1329 fallthrough 1330 case '3': 1331 fallthrough 1332 case '4': 1333 fallthrough 1334 case '5': 1335 fallthrough 1336 case '6': 1337 fallthrough 1338 case '7': 1339 fallthrough 1340 case '8': 1341 fallthrough 1342 case '9': 1343 fallthrough 1344 case 'A': 1345 fallthrough 1346 case 'B': 1347 fallthrough 1348 case 'C': 1349 fallthrough 1350 case 'D': 1351 fallthrough 1352 case 'E': 1353 fallthrough 1354 case 'F': 1355 fallthrough 1356 case 'G': 1357 fallthrough 1358 case 'H': 1359 fallthrough 1360 case 'I': 1361 fallthrough 1362 case 'J': 1363 fallthrough 1364 case 'K': 1365 fallthrough 1366 case 'L': 1367 fallthrough 1368 case 'M': 1369 fallthrough 1370 case 'N': 1371 fallthrough 1372 case 'O': 1373 fallthrough 1374 case 'P': 1375 fallthrough 1376 case 'Q': 1377 fallthrough 1378 case 'R': 1379 fallthrough 1380 case 'S': 1381 fallthrough 1382 case 'T': 1383 fallthrough 1384 case 'U': 1385 fallthrough 1386 case 'V': 1387 fallthrough 1388 case 'W': 1389 fallthrough 1390 case 'X': 1391 fallthrough 1392 case 'Y': 1393 fallthrough 1394 case 'Z': 1395 fallthrough 1396 case '_': 1397 fallthrough 1398 case 'a': 1399 fallthrough 1400 case 'b': 1401 fallthrough 1402 case 'c': 1403 fallthrough 1404 case 'd': 1405 fallthrough 1406 case 'e': 1407 fallthrough 1408 case 'f': 1409 fallthrough 1410 case 'g': 1411 fallthrough 1412 case 'h': 1413 fallthrough 1414 case 'i': 1415 fallthrough 1416 case 'j': 1417 fallthrough 1418 case 'k': 1419 fallthrough 1420 case 'l': 1421 fallthrough 1422 case 'm': 1423 fallthrough 1424 case 'n': 1425 fallthrough 1426 case 'o': 1427 fallthrough 1428 case 'p': 1429 fallthrough 1430 case 'q': 1431 fallthrough 1432 case 'r': 1433 fallthrough 1434 case 's': 1435 fallthrough 1436 case 't': 1437 fallthrough 1438 case 'u': 1439 fallthrough 1440 case 'v': 1441 fallthrough 1442 case 'w': 1443 fallthrough 1444 case 'x': 1445 fallthrough 1446 case 'y': 1447 fallthrough 1448 case 'z': 1449 goto yy13 1450 default: 1451 goto yy69 1452 } 1453 yy69: 1454 { 1455 token = DEFAULT 1456 break 1457 } 1458 yy70: 1459 p++ 1460 yych = l.input[p] 1461 switch yych { 1462 case '-': 1463 fallthrough 1464 case '.': 1465 fallthrough 1466 case '0': 1467 fallthrough 1468 case '1': 1469 fallthrough 1470 case '2': 1471 fallthrough 1472 case '3': 1473 fallthrough 1474 case '4': 1475 fallthrough 1476 case '5': 1477 fallthrough 1478 case '6': 1479 fallthrough 1480 case '7': 1481 fallthrough 1482 case '8': 1483 fallthrough 1484 case '9': 1485 fallthrough 1486 case 'A': 1487 fallthrough 1488 case 'B': 1489 fallthrough 1490 case 'C': 1491 fallthrough 1492 case 'D': 1493 fallthrough 1494 case 'E': 1495 fallthrough 1496 case 'F': 1497 fallthrough 1498 case 'G': 1499 fallthrough 1500 case 'H': 1501 fallthrough 1502 case 'I': 1503 fallthrough 1504 case 'J': 1505 fallthrough 1506 case 'K': 1507 fallthrough 1508 case 'L': 1509 fallthrough 1510 case 'M': 1511 fallthrough 1512 case 'N': 1513 fallthrough 1514 case 'O': 1515 fallthrough 1516 case 'P': 1517 fallthrough 1518 case 'Q': 1519 fallthrough 1520 case 'R': 1521 fallthrough 1522 case 'S': 1523 fallthrough 1524 case 'T': 1525 fallthrough 1526 case 'U': 1527 fallthrough 1528 case 'V': 1529 fallthrough 1530 case 'W': 1531 fallthrough 1532 case 'X': 1533 fallthrough 1534 case 'Y': 1535 fallthrough 1536 case 'Z': 1537 fallthrough 1538 case '_': 1539 fallthrough 1540 case 'a': 1541 fallthrough 1542 case 'b': 1543 fallthrough 1544 case 'c': 1545 fallthrough 1546 case 'd': 1547 fallthrough 1548 case 'e': 1549 fallthrough 1550 case 'f': 1551 fallthrough 1552 case 'g': 1553 fallthrough 1554 case 'h': 1555 fallthrough 1556 case 'i': 1557 fallthrough 1558 case 'j': 1559 fallthrough 1560 case 'k': 1561 fallthrough 1562 case 'l': 1563 fallthrough 1564 case 'm': 1565 fallthrough 1566 case 'n': 1567 fallthrough 1568 case 'o': 1569 fallthrough 1570 case 'p': 1571 fallthrough 1572 case 'q': 1573 fallthrough 1574 case 'r': 1575 fallthrough 1576 case 's': 1577 fallthrough 1578 case 't': 1579 fallthrough 1580 case 'u': 1581 fallthrough 1582 case 'v': 1583 fallthrough 1584 case 'w': 1585 fallthrough 1586 case 'x': 1587 fallthrough 1588 case 'y': 1589 fallthrough 1590 case 'z': 1591 goto yy13 1592 default: 1593 goto yy71 1594 } 1595 yy71: 1596 { 1597 token = INCLUDE 1598 break 1599 } 1600 yy72: 1601 p++ 1602 yych = l.input[p] 1603 switch yych { 1604 case 'a': 1605 goto yy73 1606 default: 1607 goto yy14 1608 } 1609 yy73: 1610 p++ 1611 yych = l.input[p] 1612 switch yych { 1613 case '-': 1614 fallthrough 1615 case '.': 1616 fallthrough 1617 case '0': 1618 fallthrough 1619 case '1': 1620 fallthrough 1621 case '2': 1622 fallthrough 1623 case '3': 1624 fallthrough 1625 case '4': 1626 fallthrough 1627 case '5': 1628 fallthrough 1629 case '6': 1630 fallthrough 1631 case '7': 1632 fallthrough 1633 case '8': 1634 fallthrough 1635 case '9': 1636 fallthrough 1637 case 'A': 1638 fallthrough 1639 case 'B': 1640 fallthrough 1641 case 'C': 1642 fallthrough 1643 case 'D': 1644 fallthrough 1645 case 'E': 1646 fallthrough 1647 case 'F': 1648 fallthrough 1649 case 'G': 1650 fallthrough 1651 case 'H': 1652 fallthrough 1653 case 'I': 1654 fallthrough 1655 case 'J': 1656 fallthrough 1657 case 'K': 1658 fallthrough 1659 case 'L': 1660 fallthrough 1661 case 'M': 1662 fallthrough 1663 case 'N': 1664 fallthrough 1665 case 'O': 1666 fallthrough 1667 case 'P': 1668 fallthrough 1669 case 'Q': 1670 fallthrough 1671 case 'R': 1672 fallthrough 1673 case 'S': 1674 fallthrough 1675 case 'T': 1676 fallthrough 1677 case 'U': 1678 fallthrough 1679 case 'V': 1680 fallthrough 1681 case 'W': 1682 fallthrough 1683 case 'X': 1684 fallthrough 1685 case 'Y': 1686 fallthrough 1687 case 'Z': 1688 fallthrough 1689 case '_': 1690 fallthrough 1691 case 'a': 1692 fallthrough 1693 case 'b': 1694 fallthrough 1695 case 'c': 1696 fallthrough 1697 case 'd': 1698 fallthrough 1699 case 'e': 1700 fallthrough 1701 case 'f': 1702 fallthrough 1703 case 'g': 1704 fallthrough 1705 case 'h': 1706 fallthrough 1707 case 'i': 1708 fallthrough 1709 case 'j': 1710 fallthrough 1711 case 'k': 1712 fallthrough 1713 case 'l': 1714 fallthrough 1715 case 'm': 1716 fallthrough 1717 case 'n': 1718 fallthrough 1719 case 'o': 1720 fallthrough 1721 case 'p': 1722 fallthrough 1723 case 'q': 1724 fallthrough 1725 case 'r': 1726 fallthrough 1727 case 's': 1728 fallthrough 1729 case 't': 1730 fallthrough 1731 case 'u': 1732 fallthrough 1733 case 'v': 1734 fallthrough 1735 case 'w': 1736 fallthrough 1737 case 'x': 1738 fallthrough 1739 case 'y': 1740 fallthrough 1741 case 'z': 1742 goto yy13 1743 default: 1744 goto yy74 1745 } 1746 yy74: 1747 { 1748 token = SUBNINJA 1749 break 1750 } 1751 } 1752 1753 } 1754 1755 l.lastToken = start 1756 l.ofs = p 1757 if token != NEWLINE && token != TEOF { 1758 l.eatWhitespace() 1759 } 1760 return token 1761 } 1762 1763 // If the next token is \a token, read it and return true. 1764 func (l *lexer) PeekToken(token Token) bool { 1765 t := l.ReadToken() 1766 if t == token { 1767 return true 1768 } 1769 l.UnreadToken() 1770 return false 1771 } 1772 1773 // Skip past whitespace (called after each read token/ident/etc.). 1774 func (l *lexer) eatWhitespace() { 1775 p := l.ofs 1776 q := lexerOffset(0) 1777 for { 1778 l.ofs = p 1779 1780 { 1781 var yych byte 1782 yych = l.input[p] 1783 switch yych { 1784 case 0x00: 1785 goto yy77 1786 case ' ': 1787 goto yy81 1788 case '$': 1789 goto yy84 1790 default: 1791 goto yy79 1792 } 1793 yy77: 1794 p++ 1795 { 1796 break 1797 } 1798 yy79: 1799 p++ 1800 yy80: 1801 { 1802 break 1803 } 1804 yy81: 1805 p++ 1806 yych = l.input[p] 1807 switch yych { 1808 case ' ': 1809 goto yy81 1810 default: 1811 goto yy83 1812 } 1813 yy83: 1814 { 1815 continue 1816 } 1817 yy84: 1818 p++ 1819 q = p 1820 yych = l.input[p] 1821 switch yych { 1822 case '\n': 1823 goto yy85 1824 case '\r': 1825 goto yy87 1826 default: 1827 goto yy80 1828 } 1829 yy85: 1830 p++ 1831 { 1832 continue 1833 } 1834 yy87: 1835 p++ 1836 yych = l.input[p] 1837 switch yych { 1838 case '\n': 1839 goto yy89 1840 default: 1841 goto yy88 1842 } 1843 yy88: 1844 p = q 1845 goto yy80 1846 yy89: 1847 p++ 1848 { 1849 continue 1850 } 1851 } 1852 1853 } 1854 } 1855 1856 // Read a simple identifier (a rule or variable name). 1857 // Returns false if a name can't be read. 1858 func (l *lexer) readIdent() string { 1859 out := "" 1860 p := l.ofs 1861 start := lexerOffset(0) 1862 for { 1863 start = p 1864 1865 { 1866 var yych byte 1867 yych = l.input[p] 1868 switch yych { 1869 case '-': 1870 fallthrough 1871 case '.': 1872 fallthrough 1873 case '0': 1874 fallthrough 1875 case '1': 1876 fallthrough 1877 case '2': 1878 fallthrough 1879 case '3': 1880 fallthrough 1881 case '4': 1882 fallthrough 1883 case '5': 1884 fallthrough 1885 case '6': 1886 fallthrough 1887 case '7': 1888 fallthrough 1889 case '8': 1890 fallthrough 1891 case '9': 1892 fallthrough 1893 case 'A': 1894 fallthrough 1895 case 'B': 1896 fallthrough 1897 case 'C': 1898 fallthrough 1899 case 'D': 1900 fallthrough 1901 case 'E': 1902 fallthrough 1903 case 'F': 1904 fallthrough 1905 case 'G': 1906 fallthrough 1907 case 'H': 1908 fallthrough 1909 case 'I': 1910 fallthrough 1911 case 'J': 1912 fallthrough 1913 case 'K': 1914 fallthrough 1915 case 'L': 1916 fallthrough 1917 case 'M': 1918 fallthrough 1919 case 'N': 1920 fallthrough 1921 case 'O': 1922 fallthrough 1923 case 'P': 1924 fallthrough 1925 case 'Q': 1926 fallthrough 1927 case 'R': 1928 fallthrough 1929 case 'S': 1930 fallthrough 1931 case 'T': 1932 fallthrough 1933 case 'U': 1934 fallthrough 1935 case 'V': 1936 fallthrough 1937 case 'W': 1938 fallthrough 1939 case 'X': 1940 fallthrough 1941 case 'Y': 1942 fallthrough 1943 case 'Z': 1944 fallthrough 1945 case '_': 1946 fallthrough 1947 case 'a': 1948 fallthrough 1949 case 'b': 1950 fallthrough 1951 case 'c': 1952 fallthrough 1953 case 'd': 1954 fallthrough 1955 case 'e': 1956 fallthrough 1957 case 'f': 1958 fallthrough 1959 case 'g': 1960 fallthrough 1961 case 'h': 1962 fallthrough 1963 case 'i': 1964 fallthrough 1965 case 'j': 1966 fallthrough 1967 case 'k': 1968 fallthrough 1969 case 'l': 1970 fallthrough 1971 case 'm': 1972 fallthrough 1973 case 'n': 1974 fallthrough 1975 case 'o': 1976 fallthrough 1977 case 'p': 1978 fallthrough 1979 case 'q': 1980 fallthrough 1981 case 'r': 1982 fallthrough 1983 case 's': 1984 fallthrough 1985 case 't': 1986 fallthrough 1987 case 'u': 1988 fallthrough 1989 case 'v': 1990 fallthrough 1991 case 'w': 1992 fallthrough 1993 case 'x': 1994 fallthrough 1995 case 'y': 1996 fallthrough 1997 case 'z': 1998 goto yy95 1999 default: 2000 goto yy93 2001 } 2002 yy93: 2003 p++ 2004 { 2005 l.lastToken = start 2006 return "" 2007 } 2008 yy95: 2009 p++ 2010 yych = l.input[p] 2011 switch yych { 2012 case '-': 2013 fallthrough 2014 case '.': 2015 fallthrough 2016 case '0': 2017 fallthrough 2018 case '1': 2019 fallthrough 2020 case '2': 2021 fallthrough 2022 case '3': 2023 fallthrough 2024 case '4': 2025 fallthrough 2026 case '5': 2027 fallthrough 2028 case '6': 2029 fallthrough 2030 case '7': 2031 fallthrough 2032 case '8': 2033 fallthrough 2034 case '9': 2035 fallthrough 2036 case 'A': 2037 fallthrough 2038 case 'B': 2039 fallthrough 2040 case 'C': 2041 fallthrough 2042 case 'D': 2043 fallthrough 2044 case 'E': 2045 fallthrough 2046 case 'F': 2047 fallthrough 2048 case 'G': 2049 fallthrough 2050 case 'H': 2051 fallthrough 2052 case 'I': 2053 fallthrough 2054 case 'J': 2055 fallthrough 2056 case 'K': 2057 fallthrough 2058 case 'L': 2059 fallthrough 2060 case 'M': 2061 fallthrough 2062 case 'N': 2063 fallthrough 2064 case 'O': 2065 fallthrough 2066 case 'P': 2067 fallthrough 2068 case 'Q': 2069 fallthrough 2070 case 'R': 2071 fallthrough 2072 case 'S': 2073 fallthrough 2074 case 'T': 2075 fallthrough 2076 case 'U': 2077 fallthrough 2078 case 'V': 2079 fallthrough 2080 case 'W': 2081 fallthrough 2082 case 'X': 2083 fallthrough 2084 case 'Y': 2085 fallthrough 2086 case 'Z': 2087 fallthrough 2088 case '_': 2089 fallthrough 2090 case 'a': 2091 fallthrough 2092 case 'b': 2093 fallthrough 2094 case 'c': 2095 fallthrough 2096 case 'd': 2097 fallthrough 2098 case 'e': 2099 fallthrough 2100 case 'f': 2101 fallthrough 2102 case 'g': 2103 fallthrough 2104 case 'h': 2105 fallthrough 2106 case 'i': 2107 fallthrough 2108 case 'j': 2109 fallthrough 2110 case 'k': 2111 fallthrough 2112 case 'l': 2113 fallthrough 2114 case 'm': 2115 fallthrough 2116 case 'n': 2117 fallthrough 2118 case 'o': 2119 fallthrough 2120 case 'p': 2121 fallthrough 2122 case 'q': 2123 fallthrough 2124 case 'r': 2125 fallthrough 2126 case 's': 2127 fallthrough 2128 case 't': 2129 fallthrough 2130 case 'u': 2131 fallthrough 2132 case 'v': 2133 fallthrough 2134 case 'w': 2135 fallthrough 2136 case 'x': 2137 fallthrough 2138 case 'y': 2139 fallthrough 2140 case 'z': 2141 goto yy95 2142 default: 2143 goto yy97 2144 } 2145 yy97: 2146 { 2147 out = unsafeString(l.input[start:p]) 2148 break 2149 } 2150 } 2151 2152 } 2153 l.lastToken = start 2154 l.ofs = p 2155 l.eatWhitespace() 2156 return out 2157 } 2158 2159 // readEvalString reads a $-escaped string. 2160 // 2161 // If path is true, read a path (complete with $escapes). 2162 // 2163 // If path is false, read the value side of a var = value line (complete with 2164 // $escapes). 2165 // 2166 // Returned path may be empty if a delimiter (space, newline) is hit. 2167 func (l *lexer) readEvalString(path bool) (EvalString, error) { 2168 eval := EvalString{} 2169 p := l.ofs 2170 q := lexerOffset(0) 2171 start := lexerOffset(0) 2172 for { 2173 start = p 2174 2175 { 2176 var yych byte 2177 yych = l.input[p] 2178 switch yych { 2179 case 0x00: 2180 goto yy100 2181 case '\n': 2182 fallthrough 2183 case ' ': 2184 fallthrough 2185 case ':': 2186 fallthrough 2187 case '|': 2188 goto yy105 2189 case '\r': 2190 goto yy107 2191 case '$': 2192 goto yy109 2193 default: 2194 goto yy102 2195 } 2196 yy100: 2197 p++ 2198 { 2199 l.lastToken = start 2200 return eval, l.Error("unexpected EOF") 2201 } 2202 yy102: 2203 p++ 2204 yych = l.input[p] 2205 switch yych { 2206 case 0x00: 2207 fallthrough 2208 case '\n': 2209 fallthrough 2210 case '\r': 2211 fallthrough 2212 case ' ': 2213 fallthrough 2214 case '$': 2215 fallthrough 2216 case ':': 2217 fallthrough 2218 case '|': 2219 goto yy104 2220 default: 2221 goto yy102 2222 } 2223 yy104: 2224 { 2225 eval.Parsed = append(eval.Parsed, EvalStringToken{unsafeString(l.input[start:p]), false}) 2226 continue 2227 } 2228 yy105: 2229 p++ 2230 { 2231 if path { 2232 p = start 2233 break 2234 } else { 2235 if l.input[start] == '\n' { 2236 break 2237 } 2238 eval.Parsed = append(eval.Parsed, EvalStringToken{unsafeString(l.input[start : start+1]), false}) 2239 continue 2240 } 2241 } 2242 yy107: 2243 p++ 2244 yych = l.input[p] 2245 switch yych { 2246 case '\n': 2247 goto yy110 2248 default: 2249 goto yy108 2250 } 2251 yy108: 2252 { 2253 l.lastToken = start 2254 return eval, l.Error(l.DescribeLastError()) 2255 } 2256 yy109: 2257 p++ 2258 yych = l.input[p] 2259 switch yych { 2260 case '\n': 2261 goto yy114 2262 case '\r': 2263 goto yy117 2264 case ' ': 2265 goto yy118 2266 case '$': 2267 goto yy120 2268 case '-': 2269 fallthrough 2270 case '0': 2271 fallthrough 2272 case '1': 2273 fallthrough 2274 case '2': 2275 fallthrough 2276 case '3': 2277 fallthrough 2278 case '4': 2279 fallthrough 2280 case '5': 2281 fallthrough 2282 case '6': 2283 fallthrough 2284 case '7': 2285 fallthrough 2286 case '8': 2287 fallthrough 2288 case '9': 2289 fallthrough 2290 case 'A': 2291 fallthrough 2292 case 'B': 2293 fallthrough 2294 case 'C': 2295 fallthrough 2296 case 'D': 2297 fallthrough 2298 case 'E': 2299 fallthrough 2300 case 'F': 2301 fallthrough 2302 case 'G': 2303 fallthrough 2304 case 'H': 2305 fallthrough 2306 case 'I': 2307 fallthrough 2308 case 'J': 2309 fallthrough 2310 case 'K': 2311 fallthrough 2312 case 'L': 2313 fallthrough 2314 case 'M': 2315 fallthrough 2316 case 'N': 2317 fallthrough 2318 case 'O': 2319 fallthrough 2320 case 'P': 2321 fallthrough 2322 case 'Q': 2323 fallthrough 2324 case 'R': 2325 fallthrough 2326 case 'S': 2327 fallthrough 2328 case 'T': 2329 fallthrough 2330 case 'U': 2331 fallthrough 2332 case 'V': 2333 fallthrough 2334 case 'W': 2335 fallthrough 2336 case 'X': 2337 fallthrough 2338 case 'Y': 2339 fallthrough 2340 case 'Z': 2341 fallthrough 2342 case '_': 2343 fallthrough 2344 case 'a': 2345 fallthrough 2346 case 'b': 2347 fallthrough 2348 case 'c': 2349 fallthrough 2350 case 'd': 2351 fallthrough 2352 case 'e': 2353 fallthrough 2354 case 'f': 2355 fallthrough 2356 case 'g': 2357 fallthrough 2358 case 'h': 2359 fallthrough 2360 case 'i': 2361 fallthrough 2362 case 'j': 2363 fallthrough 2364 case 'k': 2365 fallthrough 2366 case 'l': 2367 fallthrough 2368 case 'm': 2369 fallthrough 2370 case 'n': 2371 fallthrough 2372 case 'o': 2373 fallthrough 2374 case 'p': 2375 fallthrough 2376 case 'q': 2377 fallthrough 2378 case 'r': 2379 fallthrough 2380 case 's': 2381 fallthrough 2382 case 't': 2383 fallthrough 2384 case 'u': 2385 fallthrough 2386 case 'v': 2387 fallthrough 2388 case 'w': 2389 fallthrough 2390 case 'x': 2391 fallthrough 2392 case 'y': 2393 fallthrough 2394 case 'z': 2395 goto yy122 2396 case ':': 2397 goto yy125 2398 case '{': 2399 goto yy127 2400 default: 2401 goto yy112 2402 } 2403 yy110: 2404 p++ 2405 { 2406 if path { 2407 p = start 2408 } 2409 break 2410 } 2411 yy112: 2412 p++ 2413 yy113: 2414 { 2415 l.lastToken = start 2416 return eval, l.Error("bad $-escape (literal $ must be written as $$)") 2417 } 2418 yy114: 2419 p++ 2420 yych = l.input[p] 2421 switch yych { 2422 case ' ': 2423 goto yy114 2424 default: 2425 goto yy116 2426 } 2427 yy116: 2428 { 2429 continue 2430 } 2431 yy117: 2432 p++ 2433 yych = l.input[p] 2434 switch yych { 2435 case '\n': 2436 goto yy128 2437 default: 2438 goto yy113 2439 } 2440 yy118: 2441 p++ 2442 { 2443 eval.Parsed = append(eval.Parsed, EvalStringToken{" ", false}) 2444 continue 2445 } 2446 yy120: 2447 p++ 2448 { 2449 eval.Parsed = append(eval.Parsed, EvalStringToken{"$", false}) 2450 continue 2451 } 2452 yy122: 2453 p++ 2454 yych = l.input[p] 2455 switch yych { 2456 case '-': 2457 fallthrough 2458 case '0': 2459 fallthrough 2460 case '1': 2461 fallthrough 2462 case '2': 2463 fallthrough 2464 case '3': 2465 fallthrough 2466 case '4': 2467 fallthrough 2468 case '5': 2469 fallthrough 2470 case '6': 2471 fallthrough 2472 case '7': 2473 fallthrough 2474 case '8': 2475 fallthrough 2476 case '9': 2477 fallthrough 2478 case 'A': 2479 fallthrough 2480 case 'B': 2481 fallthrough 2482 case 'C': 2483 fallthrough 2484 case 'D': 2485 fallthrough 2486 case 'E': 2487 fallthrough 2488 case 'F': 2489 fallthrough 2490 case 'G': 2491 fallthrough 2492 case 'H': 2493 fallthrough 2494 case 'I': 2495 fallthrough 2496 case 'J': 2497 fallthrough 2498 case 'K': 2499 fallthrough 2500 case 'L': 2501 fallthrough 2502 case 'M': 2503 fallthrough 2504 case 'N': 2505 fallthrough 2506 case 'O': 2507 fallthrough 2508 case 'P': 2509 fallthrough 2510 case 'Q': 2511 fallthrough 2512 case 'R': 2513 fallthrough 2514 case 'S': 2515 fallthrough 2516 case 'T': 2517 fallthrough 2518 case 'U': 2519 fallthrough 2520 case 'V': 2521 fallthrough 2522 case 'W': 2523 fallthrough 2524 case 'X': 2525 fallthrough 2526 case 'Y': 2527 fallthrough 2528 case 'Z': 2529 fallthrough 2530 case '_': 2531 fallthrough 2532 case 'a': 2533 fallthrough 2534 case 'b': 2535 fallthrough 2536 case 'c': 2537 fallthrough 2538 case 'd': 2539 fallthrough 2540 case 'e': 2541 fallthrough 2542 case 'f': 2543 fallthrough 2544 case 'g': 2545 fallthrough 2546 case 'h': 2547 fallthrough 2548 case 'i': 2549 fallthrough 2550 case 'j': 2551 fallthrough 2552 case 'k': 2553 fallthrough 2554 case 'l': 2555 fallthrough 2556 case 'm': 2557 fallthrough 2558 case 'n': 2559 fallthrough 2560 case 'o': 2561 fallthrough 2562 case 'p': 2563 fallthrough 2564 case 'q': 2565 fallthrough 2566 case 'r': 2567 fallthrough 2568 case 's': 2569 fallthrough 2570 case 't': 2571 fallthrough 2572 case 'u': 2573 fallthrough 2574 case 'v': 2575 fallthrough 2576 case 'w': 2577 fallthrough 2578 case 'x': 2579 fallthrough 2580 case 'y': 2581 fallthrough 2582 case 'z': 2583 goto yy122 2584 default: 2585 goto yy124 2586 } 2587 yy124: 2588 { 2589 eval.Parsed = append(eval.Parsed, EvalStringToken{unsafeString(l.input[start+1 : p]), true}) 2590 continue 2591 } 2592 yy125: 2593 p++ 2594 { 2595 eval.Parsed = append(eval.Parsed, EvalStringToken{":", false}) 2596 continue 2597 } 2598 yy127: 2599 p++ 2600 q = p 2601 yych = l.input[p] 2602 switch yych { 2603 case '-': 2604 fallthrough 2605 case '.': 2606 fallthrough 2607 case '0': 2608 fallthrough 2609 case '1': 2610 fallthrough 2611 case '2': 2612 fallthrough 2613 case '3': 2614 fallthrough 2615 case '4': 2616 fallthrough 2617 case '5': 2618 fallthrough 2619 case '6': 2620 fallthrough 2621 case '7': 2622 fallthrough 2623 case '8': 2624 fallthrough 2625 case '9': 2626 fallthrough 2627 case 'A': 2628 fallthrough 2629 case 'B': 2630 fallthrough 2631 case 'C': 2632 fallthrough 2633 case 'D': 2634 fallthrough 2635 case 'E': 2636 fallthrough 2637 case 'F': 2638 fallthrough 2639 case 'G': 2640 fallthrough 2641 case 'H': 2642 fallthrough 2643 case 'I': 2644 fallthrough 2645 case 'J': 2646 fallthrough 2647 case 'K': 2648 fallthrough 2649 case 'L': 2650 fallthrough 2651 case 'M': 2652 fallthrough 2653 case 'N': 2654 fallthrough 2655 case 'O': 2656 fallthrough 2657 case 'P': 2658 fallthrough 2659 case 'Q': 2660 fallthrough 2661 case 'R': 2662 fallthrough 2663 case 'S': 2664 fallthrough 2665 case 'T': 2666 fallthrough 2667 case 'U': 2668 fallthrough 2669 case 'V': 2670 fallthrough 2671 case 'W': 2672 fallthrough 2673 case 'X': 2674 fallthrough 2675 case 'Y': 2676 fallthrough 2677 case 'Z': 2678 fallthrough 2679 case '_': 2680 fallthrough 2681 case 'a': 2682 fallthrough 2683 case 'b': 2684 fallthrough 2685 case 'c': 2686 fallthrough 2687 case 'd': 2688 fallthrough 2689 case 'e': 2690 fallthrough 2691 case 'f': 2692 fallthrough 2693 case 'g': 2694 fallthrough 2695 case 'h': 2696 fallthrough 2697 case 'i': 2698 fallthrough 2699 case 'j': 2700 fallthrough 2701 case 'k': 2702 fallthrough 2703 case 'l': 2704 fallthrough 2705 case 'm': 2706 fallthrough 2707 case 'n': 2708 fallthrough 2709 case 'o': 2710 fallthrough 2711 case 'p': 2712 fallthrough 2713 case 'q': 2714 fallthrough 2715 case 'r': 2716 fallthrough 2717 case 's': 2718 fallthrough 2719 case 't': 2720 fallthrough 2721 case 'u': 2722 fallthrough 2723 case 'v': 2724 fallthrough 2725 case 'w': 2726 fallthrough 2727 case 'x': 2728 fallthrough 2729 case 'y': 2730 fallthrough 2731 case 'z': 2732 goto yy131 2733 default: 2734 goto yy113 2735 } 2736 yy128: 2737 p++ 2738 yych = l.input[p] 2739 switch yych { 2740 case ' ': 2741 goto yy128 2742 default: 2743 goto yy130 2744 } 2745 yy130: 2746 { 2747 continue 2748 } 2749 yy131: 2750 p++ 2751 yych = l.input[p] 2752 switch yych { 2753 case '-': 2754 fallthrough 2755 case '.': 2756 fallthrough 2757 case '0': 2758 fallthrough 2759 case '1': 2760 fallthrough 2761 case '2': 2762 fallthrough 2763 case '3': 2764 fallthrough 2765 case '4': 2766 fallthrough 2767 case '5': 2768 fallthrough 2769 case '6': 2770 fallthrough 2771 case '7': 2772 fallthrough 2773 case '8': 2774 fallthrough 2775 case '9': 2776 fallthrough 2777 case 'A': 2778 fallthrough 2779 case 'B': 2780 fallthrough 2781 case 'C': 2782 fallthrough 2783 case 'D': 2784 fallthrough 2785 case 'E': 2786 fallthrough 2787 case 'F': 2788 fallthrough 2789 case 'G': 2790 fallthrough 2791 case 'H': 2792 fallthrough 2793 case 'I': 2794 fallthrough 2795 case 'J': 2796 fallthrough 2797 case 'K': 2798 fallthrough 2799 case 'L': 2800 fallthrough 2801 case 'M': 2802 fallthrough 2803 case 'N': 2804 fallthrough 2805 case 'O': 2806 fallthrough 2807 case 'P': 2808 fallthrough 2809 case 'Q': 2810 fallthrough 2811 case 'R': 2812 fallthrough 2813 case 'S': 2814 fallthrough 2815 case 'T': 2816 fallthrough 2817 case 'U': 2818 fallthrough 2819 case 'V': 2820 fallthrough 2821 case 'W': 2822 fallthrough 2823 case 'X': 2824 fallthrough 2825 case 'Y': 2826 fallthrough 2827 case 'Z': 2828 fallthrough 2829 case '_': 2830 fallthrough 2831 case 'a': 2832 fallthrough 2833 case 'b': 2834 fallthrough 2835 case 'c': 2836 fallthrough 2837 case 'd': 2838 fallthrough 2839 case 'e': 2840 fallthrough 2841 case 'f': 2842 fallthrough 2843 case 'g': 2844 fallthrough 2845 case 'h': 2846 fallthrough 2847 case 'i': 2848 fallthrough 2849 case 'j': 2850 fallthrough 2851 case 'k': 2852 fallthrough 2853 case 'l': 2854 fallthrough 2855 case 'm': 2856 fallthrough 2857 case 'n': 2858 fallthrough 2859 case 'o': 2860 fallthrough 2861 case 'p': 2862 fallthrough 2863 case 'q': 2864 fallthrough 2865 case 'r': 2866 fallthrough 2867 case 's': 2868 fallthrough 2869 case 't': 2870 fallthrough 2871 case 'u': 2872 fallthrough 2873 case 'v': 2874 fallthrough 2875 case 'w': 2876 fallthrough 2877 case 'x': 2878 fallthrough 2879 case 'y': 2880 fallthrough 2881 case 'z': 2882 goto yy131 2883 case '}': 2884 goto yy134 2885 default: 2886 goto yy133 2887 } 2888 yy133: 2889 p = q 2890 goto yy113 2891 yy134: 2892 p++ 2893 { 2894 eval.Parsed = append(eval.Parsed, EvalStringToken{unsafeString(l.input[start+2 : p-1]), true}) 2895 continue 2896 } 2897 } 2898 2899 } 2900 l.lastToken = start 2901 l.ofs = p 2902 if path { 2903 l.eatWhitespace() 2904 } 2905 // Non-path strings end in newlines, so there's no whitespace to eat. 2906 return eval, nil 2907 }