Changeset 609 for branches/GNU/src/binutils/gas/app.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/gas/app.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* This is the Assembler Pre-Processor 2 2 Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 3 1999, 2000 3 1999, 2000, 2002, 2003 4 4 Free Software Foundation, Inc. 5 5 … … 21 21 02111-1307, USA. */ 22 22 23 /* Modified by Allen Wirfs-Brock, Instantiations Inc 2/90 */23 /* Modified by Allen Wirfs-Brock, Instantiations Inc 2/90. */ 24 24 /* App, the assembler pre-processor. This pre-processor strips out excess 25 25 spaces, turns single-quoted characters into a decimal constant, and turns … … 28 28 29 29 #include <stdio.h> 30 #include "as.h" /* For BAD_CASE() only */30 #include "as.h" /* For BAD_CASE() only. */ 31 31 32 32 #if (__STDC__ != 1) … … 41 41 pseudo-op at different times. */ 42 42 static int scrub_m68k_mri; 43 #else44 #define scrub_m68k_mri 045 #endif46 43 47 44 /* The pseudo-op which switches in and out of MRI mode. See the 48 45 comment in do_scrub_chars. */ 49 46 static const char mri_pseudo[] = ".mri 0"; 47 #else 48 #define scrub_m68k_mri 0 49 #endif 50 50 51 51 #if defined TC_ARM && defined OBJ_ELF … … 79 79 #define LEX_IS_DOUBLEBAR_1ST 13 80 80 #endif 81 #define LEX_IS_PARALLEL_SEPARATOR 14 81 82 #define IS_SYMBOL_COMPONENT(c) (lex[c] == LEX_IS_SYMBOL_COMPONENT) 82 83 #define IS_WHITESPACE(c) (lex[c] == LEX_IS_WHITESPACE) 83 84 #define IS_LINE_SEPARATOR(c) (lex[c] == LEX_IS_LINE_SEPARATOR) 85 #define IS_PARALLEL_SEPARATOR(c) (lex[c] == LEX_IS_PARALLEL_SEPARATOR) 84 86 #define IS_COMMENT(c) (lex[c] == LEX_IS_COMMENT_START) 85 87 #define IS_LINE_COMMENT(c) (lex[c] == LEX_IS_LINE_COMMENT_START) … … 114 116 115 117 #if ! defined (TC_HPPA) && ! defined (TC_I370) 116 /* I370 uses single-quotes to delimit integer, float constants */118 /* I370 uses single-quotes to delimit integer, float constants. */ 117 119 lex['\''] = LEX_IS_ONECHAR_QUOTE; 118 120 #endif … … 129 131 comment char, then it isn't a line separator. */ 130 132 for (p = symbol_chars; *p; ++p) 131 { 132 lex[(unsigned char) *p] = LEX_IS_SYMBOL_COMPONENT; 133 } /* declare symbol characters */ 133 lex[(unsigned char) *p] = LEX_IS_SYMBOL_COMPONENT; 134 134 135 135 for (c = 128; c < 256; ++c) … … 151 151 #endif 152 152 for (p = tc_comment_chars; *p; p++) 153 { 154 lex[(unsigned char) *p] = LEX_IS_COMMENT_START; 155 } /* declare comment chars */ 153 lex[(unsigned char) *p] = LEX_IS_COMMENT_START; 156 154 157 155 for (p = line_comment_chars; *p; p++) 158 { 159 lex[(unsigned char) *p] = LEX_IS_LINE_COMMENT_START; 160 } /* declare line comment chars */ 156 lex[(unsigned char) *p] = LEX_IS_LINE_COMMENT_START; 161 157 162 158 for (p = line_separator_chars; *p; p++) 163 { 164 lex[(unsigned char) *p] = LEX_IS_LINE_SEPARATOR; 165 } /* declare line separators */ 159 lex[(unsigned char) *p] = LEX_IS_LINE_SEPARATOR; 160 161 #ifdef tc_parallel_separator_chars 162 /* This macro permits the processor to specify all characters which 163 separate parallel insns on the same line. */ 164 for (p = tc_parallel_separator_chars; *p; p++) 165 lex[(unsigned char) *p] = LEX_IS_PARALLEL_SEPARATOR; 166 #endif 166 167 167 168 /* Only allow slash-star comments if slash is not in use. 168 169 FIXME: This isn't right. We should always permit them. */ 169 170 if (lex['/'] == 0) 170 { 171 lex['/'] = LEX_IS_TWOCHAR_COMMENT_1ST; 172 } 171 lex['/'] = LEX_IS_TWOCHAR_COMMENT_1ST; 173 172 174 173 #ifdef TC_M68K … … 179 178 lex['*'] = LEX_IS_LINE_COMMENT_START; 180 179 /* The MRI documentation says '!' is LEX_IS_COMMENT_START, but 181 180 then it can't be used in an expression. */ 182 181 lex['!'] = LEX_IS_LINE_COMMENT_START; 183 182 } … … 191 190 #endif 192 191 #ifdef TC_D30V 193 /* must do this is we want VLIW instruction with "->" or "<-"*/192 /* Must do this is we want VLIW instruction with "->" or "<-". */ 194 193 lex['-'] = LEX_IS_SYMBOL_COMPONENT; 195 194 #endif 196 } /* do_scrub_begin() */197 198 /* Saved state of the scrubber */195 } 196 197 /* Saved state of the scrubber. */ 199 198 static int state; 200 199 static int old_state; … … 213 212 That's why we have to save it all. */ 214 213 215 struct app_save { 214 struct app_save 215 { 216 216 int state; 217 217 int old_state; … … 299 299 300 300 free (arg); 301 } /* app_pop() */301 } 302 302 303 303 /* @@ This assumes that \n &c are the same on host and target. This is not 304 304 necessarily true. */ 305 305 306 static int 306 307 process_escape (ch) … … 367 368 -2: flush text until a '*' '/' is seen, then go to state old_state 368 369 #ifdef TC_V850 369 12: After seeing a dash, looking for a second dash as a start of comment. 370 12: After seeing a dash, looking for a second dash as a start 371 of comment. 370 372 #endif 371 373 #ifdef DOUBLEBAR_PARALLEL 372 13: After seeing a vertical bar, looking for a second vertical bar as a parallel expression seperator. 374 13: After seeing a vertical bar, looking for a second 375 vertical bar as a parallel expression separator. 373 376 #endif 374 377 */ … … 377 380 constructs like ``.loc 1 20''. This was turning into ``.loc 378 381 120''. States 9 and 10 ensure that a space is never dropped in 379 between characters which could appear in a identifier. Ian382 between characters which could appear in an identifier. Ian 380 383 Taylor, ian@cygnus.com. 381 384 … … 414 417 memory usage. */ 415 418 416 #define PUT(pch) \417 do \418 { \419 *to++ = (pch); \420 if (to >= toend) \421 goto tofull;\422 } \419 #define PUT(pch) \ 420 do \ 421 { \ 422 *to++ = (pch); \ 423 if (to >= toend) \ 424 goto tofull; \ 425 } \ 423 426 while (0) 424 427 … … 440 443 { 441 444 /* The cases in this switch end with continue, in order to 442 443 445 branch back to the top of this while loop and generate the 446 next output character in the appropriate state. */ 444 447 switch (state) 445 448 { … … 524 527 case 5: 525 528 /* We are going to copy everything up to a quote character, 526 527 528 529 with special handling for a backslash. We try to 530 optimize the copying in the simple case without using the 531 GET and PUT macros. */ 529 532 { 530 533 char *s; … … 535 538 ch = *s; 536 539 /* This condition must be changed if the type of any 537 540 other character can be LEX_IS_STRINGQUOTE. */ 538 541 if (ch == '\\' 539 542 || ch == '"' … … 556 559 if (ch == EOF) 557 560 { 558 as_warn (_("end of file in string :inserted '\"'"));561 as_warn (_("end of file in string; inserted '\"'")); 559 562 state = old_state; 560 563 UNGET ('\n'); … … 576 579 { 577 580 /* Just quietly terminate the string. This permits lines like 578 bne label loop if we haven't reach end yet 579 */ 581 bne label loop if we haven't reach end yet. */ 580 582 state = old_state; 581 583 UNGET (ch); … … 599 601 add_newlines++; 600 602 PUT ('\\'); 603 continue; 604 605 case EOF: 606 as_warn (_("end of file in string; '\"' inserted")); 607 PUT ('"'); 601 608 continue; 602 609 … … 620 627 case '7': 621 628 break; 622 #if defined(IGNORE_NONSTANDARD_ESCAPES) | defined(ONLY_STANDARD_ESCAPES) 629 623 630 default: 624 as_warn (_("Unknown escape '\\%c' in string: Ignored"), ch); 631 #ifdef ONLY_STANDARD_ESCAPES 632 as_warn (_("unknown escape '\\%c' in string; ignored"), ch); 633 #endif 625 634 break; 626 #else /* ONLY_STANDARD_ESCAPES */627 default:628 /* Accept \x as x for any x */629 break;630 #endif /* ONLY_STANDARD_ESCAPES */631 632 case EOF:633 as_warn (_("End of file in string: '\"' inserted"));634 PUT ('"');635 continue;636 635 } 637 636 PUT (ch); … … 656 655 PUT (ch); 657 656 continue; 657 658 #ifdef DOUBLEBAR_PARALLEL 659 case 13: 660 ch = GET (); 661 if (ch != '|') 662 abort (); 663 664 /* Reset back to state 1 and pretend that we are parsing a 665 line from just after the first white space. */ 666 state = 1; 667 PUT ('|'); 668 continue; 669 #endif 658 670 } 659 671 660 /* OK, we are somewhere in states 0 through 4 or 9 through 11 */672 /* OK, we are somewhere in states 0 through 4 or 9 through 11. */ 661 673 662 674 /* flushchar: */ … … 696 708 #ifdef TC_M68K 697 709 /* We want to have pseudo-ops which control whether we are in 698 699 700 710 MRI mode or not. Unfortunately, since m68k MRI mode affects 711 the scrubber, that means that we need a special purpose 712 recognizer here. */ 701 713 if (mri_state == NULL) 702 714 { … … 735 747 { 736 748 /* We've read the entire pseudo-op. mips_last_ch is 737 738 749 either '0' or '1' indicating whether to enter or 750 leave MRI mode. */ 739 751 do_scrub_begin (mri_last_ch == '1'); 740 752 mri_state = NULL; 741 753 742 754 /* We continue handling the character as usual. The 743 744 755 main gas reader must also handle the .mri pseudo-op 756 to control expression parsing and the like. */ 745 757 } 746 758 } … … 783 795 { 784 796 /* Only keep this white if there's no white *after* the 785 797 colon. */ 786 798 ch2 = GET (); 787 799 UNGET (ch2); … … 797 809 if (IS_COMMENT (ch) 798 810 || ch == '/' 799 || IS_LINE_SEPARATOR (ch)) 811 || IS_LINE_SEPARATOR (ch) 812 || IS_PARALLEL_SEPARATOR (ch)) 800 813 { 801 814 if (scrub_m68k_mri) … … 870 883 { 871 884 /* We know that ch is not ':', since we tested that 872 873 874 885 case above. Therefore this is not a label, so it 886 must be the opcode, and we've just seen the 887 whitespace after it. */ 875 888 state = 3; 876 889 } … … 904 917 905 918 /* This UNGET will ensure that we count newlines 906 919 correctly. */ 907 920 UNGET (ch2); 908 921 } … … 942 955 if (state == 10) 943 956 { 944 /* Preserve the whitespace in foo "bar" */957 /* Preserve the whitespace in foo "bar". */ 945 958 UNGET (ch); 946 959 state = 3; … … 948 961 949 962 /* PUT didn't jump out. We could just break, but we 950 963 know what will happen, so optimize a bit. */ 951 964 ch = GET (); 952 965 old_state = 3; … … 964 977 if (state == 10) 965 978 { 966 /* Preserve the whitespace in foo 'b' */979 /* Preserve the whitespace in foo 'b'. */ 967 980 UNGET (ch); 968 981 state = 3; … … 993 1006 { 994 1007 #ifdef REQUIRE_CHAR_CLOSE_QUOTE 995 as_warn (_(" Missing close quote:(assumed)"));1008 as_warn (_("missing close quote; (assumed)")); 996 1009 #else 997 1010 if (ch != EOF) … … 1040 1053 break; 1041 1054 1055 case LEX_IS_PARALLEL_SEPARATOR: 1056 state = 1; 1057 PUT (ch); 1058 break; 1059 1042 1060 #ifdef TC_V850 1043 1061 case LEX_IS_DOUBLEDASH_1ST: … … 1054 1072 } 1055 1073 while (ch != EOF && ch != '\n'); 1074 1056 1075 if (ch == EOF) 1057 { 1058 as_warn (_("end of file in comment; newline inserted")); 1059 } 1076 as_warn (_("end of file in comment; newline inserted")); 1077 1060 1078 state = 0; 1061 1079 PUT ('\n'); … … 1065 1083 case LEX_IS_DOUBLEBAR_1ST: 1066 1084 ch2 = GET (); 1085 UNGET (ch2); 1067 1086 if (ch2 != '|') 1068 { 1069 UNGET (ch2); 1070 goto de_fault; 1071 } 1072 /* Reset back to state 1 and pretend that we are parsing a line from 1073 just after the first white space. */ 1074 state = 1; 1075 PUT ('|'); 1087 goto de_fault; 1088 1089 /* Handle '||' in two states as invoking PUT twice might 1090 result in the first one jumping out of this loop. We'd 1091 then lose track of the state and one '|' char. */ 1092 state = 13; 1076 1093 PUT ('|'); 1077 1094 break; … … 1095 1112 UNGET (ch2); 1096 1113 } 1097 } /* bad hack */1114 } 1098 1115 1099 1116 if (state == 0 || state == 1) /* Only comment at start of line. */ … … 1108 1125 } 1109 1126 while (ch != EOF && IS_WHITESPACE (ch)); 1127 1110 1128 if (ch == EOF) 1111 1129 { … … 1114 1132 break; 1115 1133 } 1134 1116 1135 if (ch < '0' || ch > '9' || state != 0 || startch != '#') 1117 1136 { … … 1120 1139 ch = GET (); 1121 1140 if (ch == EOF) 1122 as_warn (_(" EOF in Comment: Newline inserted"));1141 as_warn (_("end of file in comment; newline inserted")); 1123 1142 state = 0; 1124 1143 PUT ('\n'); … … 1206 1225 1207 1226 /* This is a common case. Quickly copy CH and all the 1208 1227 following symbol component or normal characters. */ 1209 1228 if (to + 1 < toend 1210 1229 && mri_state == NULL … … 1227 1246 break; 1228 1247 } 1248 1229 1249 if (s > from) 1230 { 1231 /* Handle the last character normally, for 1232 simplicity. */ 1233 --s; 1234 } 1250 /* Handle the last character normally, for 1251 simplicity. */ 1252 --s; 1253 1235 1254 len = s - from; 1255 1236 1256 if (len > (toend - to) - 1) 1237 1257 len = (toend - to) - 1; 1258 1238 1259 if (len > 0) 1239 1260 { … … 1269 1290 if (state == 0) 1270 1291 { 1271 state = 11; /* Now seeing label definition */1292 state = 11; /* Now seeing label definition. */ 1272 1293 } 1273 1294 else if (state == 1) 1274 1295 { 1275 state = 2; /* Ditto */1296 state = 2; /* Ditto. */ 1276 1297 } 1277 1298 else if (state == 9) … … 1326 1347 } 1327 1348 1328 /* end of app.c */ -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.