00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 static char USMID[] = "\n@(#)5.0_pl/sources/cond_comp.c 5.8 09/21/99 00:21:13\n";
00038
00039
00040
00041
00042
00043 # include <time.h>
00044
00045 # include <sys/time.h>
00046
00047
00048 # include "defines.h"
00049
00050 # include "host.m"
00051 # include "host.h"
00052 # include "target.m"
00053 # include "target.h"
00054
00055 # include "globals.m"
00056 # include "tokens.m"
00057 # include "sytb.m"
00058 # include "p_globals.m"
00059 # include "src_input.m"
00060 # include "cond_comp.m"
00061 # include "debug.m"
00062
00063 # include "globals.h"
00064 # include "tokens.h"
00065 # include "sytb.h"
00066 # include "p_globals.h"
00067 # include "cond_comp.h"
00068
00069
00070
00071
00072
00073
00074 static void cc_get_token(boolean);
00075 static void cc_get_next_char(void);
00076 static void cc_get_stmt(void);
00077 static boolean parse_cc_add_opnd (opnd_type *);
00078 static boolean parse_cc_level_2 (opnd_type *);
00079 static boolean parse_cc_level_3 (opnd_type *);
00080 static boolean parse_cc_level_4 (opnd_type *);
00081 static boolean parse_cc_level_5 (opnd_type *);
00082 static boolean parse_cc_level_6 (opnd_type *);
00083 static boolean parse_cc_level_7 (opnd_type *);
00084 static boolean parse_cc_level_8 (opnd_type *);
00085 static boolean parse_cc_mult_opnd (opnd_type *);
00086 static boolean parse_cc_or_opnd (opnd_type *);
00087 static boolean parse_cc_equiv_opnd (opnd_type *);
00088 static int srch_cc_sym_tbl (char *,int, int *);
00089 static int ntr_cc_sym_tbl(cc_token_type *, int);
00090 static boolean parse_cc_expr (opnd_type *);
00091 static boolean parse_cc_operand (opnd_type *);
00092 static void flush_cc_line(void);
00093 static int fold_cc_expr(opnd_type *);
00094 static void parse_define_str(int);
00095 static void copy_define_str(int, int);
00096 static void scan_cc_line(void);
00097 static void find_line_and_col(int, int *, int *);
00098 static void shift_cc_stmt_buf(int, int);
00099 static void shift_nxt_line(int, int);
00100 static void scan_cc_macro(int, int);
00101 static boolean scan_fortran_macro(int, int, int);
00102 static int expanded_macro_len(int, cc_arg_type *);
00103 static void insert_macro(int, cc_arg_type *, int, int, int);
00104 static void cc_advance_idx(void);
00105 static void adjust_continued_macro(int, int *);
00106 static char *get_dynamic_predef_str(int, int);
00107 static void free_arg_entry(cc_arg_type *);
00108 static cc_arg_type *alloc_arg_entry(int);
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 boolean parse_cc_line(void)
00128
00129 {
00130 int attr_idx;
00131 char ch;
00132 int col;
00133 char delim;
00134 boolean include_found = FALSE;
00135 int line;
00136 int name_idx;
00137 opnd_type opnd;
00138 int str_idx;
00139 char str[MAX_SRC_LINE_SIZE];
00140
00141
00142 TRACE (Func_Entry, "parse_cc_line", NULL);
00143
00144 cc_get_stmt();
00145
00146 CC_NEXT_LA_CH;
00147
00148 if (CC_LA_CH_VALUE != pound) {
00149 find_line_and_col(cc_stmt_buf_idx, &line, &col);
00150 PRINTMSG(line, 1164, Internal, col, "parse_cc_line");
00151 flush_cc_line();
00152 }
00153
00154 CC_NEXT_LA_CH;
00155
00156 cc_get_token(TRUE);
00157
00158 switch (TOKEN_VALUE(cc_token)) {
00159
00160 case Cc_Tok_Kwd_Define :
00161
00162 if (! ignore_source_line) {
00163
00164 cc_get_token(FALSE);
00165
00166 if (TOKEN_VALUE(cc_token) == Cc_Tok_Id) {
00167
00168 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
00169 TOKEN_LEN(cc_token),
00170 &name_idx);
00171
00172 if (attr_idx != NULL_IDX) {
00173
00174 if (CC_AT_DEFINED(attr_idx)) {
00175
00176
00177 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1670, Warning,
00178 TOKEN_COLUMN(cc_token),
00179 TOKEN_STR(cc_token),
00180 0,
00181 STR_ARG);
00182 }
00183 }
00184 else {
00185 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
00186 }
00187
00188 parse_define_str(attr_idx);
00189 }
00190 else {
00191 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1165, Error,
00192 TOKEN_COLUMN(cc_token),
00193 "IDENTIFIER",
00194 0,
00195 STR_ARG);
00196 flush_cc_line();
00197 }
00198 }
00199 else {
00200 flush_cc_line();
00201 }
00202 break;
00203
00204 case Cc_Tok_Kwd_Elif :
00205
00206 if (CC_CURR_BLK_TYPE == Cc_If_Blk ||
00207 CC_CURR_BLK_TYPE == Cc_Ifdef_Blk ||
00208 CC_CURR_BLK_TYPE == Cc_Ifndef_Blk ||
00209 CC_CURR_BLK_TYPE == Cc_Elif_Blk) {
00210
00211
00212
00213
00214 CC_CURR_BLK_TYPE = Cc_Elif_Blk;
00215
00216 if (CC_CURR_BLK_IS_ACTIVE) {
00217
00218 if (! CC_CURR_BLK_DONE) {
00219
00220 scan_cc_line();
00221
00222 # if 0
00223 printf("%s", &(cc_stmt_buf[1]));
00224 # endif
00225
00226 if (CC_LA_CH_VALUE == EOS) {
00227 ntr_next_msg_queue(CC_LA_CH_LINE, 1165, Error,
00228 CC_LA_CH_COLUMN,
00229 "expression",
00230 0,
00231 STR_ARG);
00232 }
00233 else if (parse_cc_expr(&opnd)) {
00234
00235 if (fold_cc_expr(&opnd)) {
00236
00237 ignore_source_line = FALSE;
00238 }
00239 else {
00240 ignore_source_line = TRUE;
00241 }
00242
00243 CC_CURR_BLK_DONE = (ignore_source_line == FALSE);
00244 }
00245 else {
00246 flush_cc_line();
00247 }
00248 }
00249 else {
00250 ignore_source_line = TRUE;
00251 flush_cc_line();
00252 }
00253 }
00254 else {
00255 flush_cc_line();
00256 }
00257 }
00258 else {
00259
00260 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1166, Error,
00261 TOKEN_COLUMN(cc_token),
00262 "No matching IF, IFDEF, or IFNDEF directive",
00263 0,
00264 STR_ARG);
00265 flush_cc_line();
00266 CC_CURR_BLK_IN_ERROR = TRUE;
00267 }
00268
00269 break;
00270
00271 case Cc_Tok_Kwd_Else :
00272
00273 if (CC_CURR_BLK_TYPE == Cc_If_Blk ||
00274 CC_CURR_BLK_TYPE == Cc_Ifdef_Blk ||
00275 CC_CURR_BLK_TYPE == Cc_Ifndef_Blk ||
00276 CC_CURR_BLK_TYPE == Cc_Elif_Blk) {
00277
00278
00279
00280
00281 CC_CURR_BLK_TYPE = Cc_Else_Blk;
00282
00283 if (CC_CURR_BLK_IS_ACTIVE) {
00284
00285 if (! CC_CURR_BLK_DONE) {
00286 ignore_source_line = FALSE;
00287 CC_CURR_BLK_DONE = TRUE;
00288 }
00289 else {
00290 ignore_source_line = TRUE;
00291 }
00292 }
00293 }
00294 else {
00295
00296 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1166, Error,
00297 TOKEN_COLUMN(cc_token),
00298 "No matching IF, IFDEF, or IFNDEF directive",
00299 0,
00300 STR_ARG);
00301 CC_CURR_BLK_IN_ERROR = TRUE;
00302 }
00303
00304 flush_cc_line();
00305 break;
00306
00307 case Cc_Tok_Kwd_Endif :
00308
00309 if (CC_CURR_BLK_TYPE == Cc_If_Blk ||
00310 CC_CURR_BLK_TYPE == Cc_Ifdef_Blk ||
00311 CC_CURR_BLK_TYPE == Cc_Ifndef_Blk ||
00312 CC_CURR_BLK_TYPE == Cc_Elif_Blk ||
00313 CC_CURR_BLK_TYPE == Cc_Else_Blk) {
00314
00315 if (CC_CURR_BLK_IS_ACTIVE) {
00316 ignore_source_line = FALSE;
00317 }
00318
00319
00320
00321 POP_CC_BLK_STK;
00322
00323 }
00324 else {
00325
00326 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1166, Error,
00327 TOKEN_COLUMN(cc_token),
00328 "No matching IF, IFDEF, or IFNDEF directive",
00329 0,
00330 STR_ARG);
00331 CC_CURR_BLK_IN_ERROR = TRUE;
00332 }
00333
00334 flush_cc_line();
00335 break;
00336
00337 case Cc_Tok_Kwd_If :
00338
00339 PUSH_CC_BLK_STK(Cc_If_Blk);
00340
00341 if (! ignore_source_line) {
00342
00343 CC_CURR_BLK_IS_ACTIVE = TRUE;
00344
00345 scan_cc_line();
00346
00347 # if 0
00348 printf("%s", &(cc_stmt_buf[1]));
00349 # endif
00350 if (CC_LA_CH_VALUE == EOS) {
00351 ntr_next_msg_queue(CC_LA_CH_LINE, 1165, Error,
00352 CC_LA_CH_COLUMN,
00353 "expression",
00354 0,
00355 STR_ARG);
00356 }
00357 else if (parse_cc_expr(&opnd)) {
00358
00359 if (fold_cc_expr(&opnd)) {
00360
00361 ignore_source_line = FALSE;
00362 }
00363 else {
00364 ignore_source_line = TRUE;
00365 }
00366
00367 CC_CURR_BLK_DONE = (ignore_source_line == FALSE);
00368 }
00369 else {
00370 flush_cc_line();
00371 }
00372 }
00373 else {
00374 flush_cc_line();
00375 }
00376 break;
00377
00378 case Cc_Tok_Kwd_Ifdef :
00379
00380 PUSH_CC_BLK_STK(Cc_Ifdef_Blk);
00381
00382 if (! ignore_source_line) {
00383
00384 CC_CURR_BLK_IS_ACTIVE = TRUE;
00385
00386 cc_get_token(FALSE);
00387
00388 if (TOKEN_VALUE(cc_token) == Cc_Tok_Id) {
00389
00390 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
00391 TOKEN_LEN(cc_token),
00392 &name_idx);
00393
00394 if (attr_idx != NULL_IDX) {
00395
00396 if (CC_AT_DEFINED(attr_idx)) {
00397 ignore_source_line = FALSE;
00398 }
00399 else {
00400 ignore_source_line = TRUE;
00401 }
00402 }
00403 else {
00404 ignore_source_line = TRUE;
00405 }
00406
00407 CC_CURR_BLK_DONE = (ignore_source_line == FALSE);
00408 }
00409 else {
00410 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1165, Error,
00411 TOKEN_COLUMN(cc_token),
00412 "IDENTIFIER",
00413 0,
00414 STR_ARG);
00415 }
00416
00417 flush_cc_line();
00418 }
00419 else {
00420 flush_cc_line();
00421 }
00422 break;
00423
00424 case Cc_Tok_Kwd_Ifndef :
00425
00426 PUSH_CC_BLK_STK(Cc_Ifndef_Blk);
00427
00428 if (! ignore_source_line) {
00429
00430 CC_CURR_BLK_IS_ACTIVE = TRUE;
00431
00432 cc_get_token(FALSE);
00433
00434 if (TOKEN_VALUE(cc_token) == Cc_Tok_Id) {
00435
00436 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
00437 TOKEN_LEN(cc_token),
00438 &name_idx);
00439
00440 if (attr_idx != NULL_IDX) {
00441
00442 if (CC_AT_DEFINED(attr_idx)) {
00443 ignore_source_line = TRUE;
00444 }
00445 else {
00446 ignore_source_line = FALSE;
00447 }
00448 }
00449 else {
00450 ignore_source_line = FALSE;
00451 }
00452
00453 CC_CURR_BLK_DONE = (ignore_source_line == FALSE);
00454 }
00455 else {
00456 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1165, Error,
00457 TOKEN_COLUMN(cc_token),
00458 "IDENTIFIER",
00459 0,
00460 STR_ARG);
00461 }
00462
00463 flush_cc_line();
00464 }
00465 else {
00466 flush_cc_line();
00467 }
00468 break;
00469
00470 case Cc_Tok_Kwd_Include :
00471
00472 if (! ignore_source_line) {
00473
00474 if (CC_LA_CH_VALUE == quote ||
00475 CC_LA_CH_VALUE == db_quote ||
00476 CC_LA_CH_VALUE == '<') {
00477
00478 if (CC_LA_CH_VALUE == '<') {
00479 delim = '>';
00480 angle_brkt_include = TRUE;
00481 }
00482 else {
00483 delim = CC_LA_CH_VALUE;
00484 }
00485
00486 str_idx = 0;
00487
00488 while ((ch = cc_stmt_buf[++cc_stmt_buf_idx]) != delim &&
00489 ch != eos) {
00490
00491 if (str_idx < MAX_FILE_NAME_SIZE) {
00492 include_file[str_idx++] = ch;
00493 }
00494 else if (str_idx == MAX_FILE_NAME_SIZE) {
00495
00496
00497
00498 find_line_and_col(cc_stmt_buf_idx, &line, &col);
00499 ntr_next_msg_queue(line, 57, Error,
00500 col,
00501 (char *)NULL,
00502 (MAX_FILE_NAME_SIZE - 1),
00503 ARG_ARG);
00504 flush_cc_line();
00505 break;
00506 }
00507 }
00508
00509 include_file[str_idx] = '\0';
00510
00511 if (str_idx == NULL_IDX) {
00512 find_line_and_col(cc_stmt_buf_idx, &line, &col);
00513 ntr_next_msg_queue(line, 58, Error,
00514 col,
00515 (char *)NULL,
00516 0,
00517 NO_ARG);
00518 }
00519 else if (ch == eos) {
00520 find_line_and_col(cc_stmt_buf_idx, &line, &col);
00521 ntr_next_msg_queue(line, 59, Error,
00522 col,
00523 (char *)NULL,
00524 0,
00525 NO_ARG);
00526 }
00527 else {
00528 include_found = TRUE;
00529 }
00530 }
00531 else {
00532 find_line_and_col(cc_stmt_buf_idx, &line, &col);
00533 ntr_next_msg_queue(line, 1165, Error,
00534 col,
00535 "INCLUDE file name",
00536 0,
00537 STR_ARG);
00538 }
00539 }
00540
00541 flush_cc_line();
00542 break;
00543
00544 case Cc_Tok_Kwd_Undef :
00545
00546 if (! ignore_source_line) {
00547
00548 cc_get_token(FALSE);
00549
00550 if (TOKEN_VALUE(cc_token) == Cc_Tok_Id) {
00551
00552 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
00553 TOKEN_LEN(cc_token),
00554 &name_idx);
00555
00556 if (attr_idx != NULL_IDX) {
00557 CC_AT_DEFINED(attr_idx) = FALSE;
00558 }
00559 else {
00560
00561 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
00562 }
00563 }
00564 else {
00565 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1165, Error,
00566 TOKEN_COLUMN(cc_token),
00567 "IDENTIFIER",
00568 0,
00569 STR_ARG);
00570 }
00571
00572 flush_cc_line();
00573 }
00574 else {
00575 flush_cc_line();
00576 }
00577 break;
00578
00579 case Cc_Tok_Kwd_Error :
00580
00581 if (! ignore_source_line) {
00582
00583 str_idx = 0;
00584
00585 while (cc_stmt_buf_idx < MAX_SRC_LINE_SIZE &&
00586 (ch = cc_stmt_buf[cc_stmt_buf_idx]) != eos &&
00587 ch != newline) {
00588
00589 str[str_idx] = ch;
00590 str_idx++;
00591 cc_stmt_buf_idx++;
00592 }
00593
00594 str[str_idx] = '\0';
00595
00596 if (cc_line_continued) {
00597
00598 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1178, Error,
00599 TOKEN_COLUMN(cc_token),
00600 (char *)NULL,
00601 0,
00602 NO_ARG);
00603 }
00604
00605 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1177, Error,
00606 TOKEN_COLUMN(cc_token),
00607 str,
00608 0,
00609 STR_ARG);
00610
00611 flush_cc_line();
00612 }
00613 else {
00614 flush_cc_line();
00615 }
00616 break;
00617
00618 case Cc_Tok_EOS :
00619 break;
00620
00621 case Cc_Tok_Constant:
00622
00623
00624 flush_cc_line();
00625 break;
00626
00627 default:
00628 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1165, Error,
00629 TOKEN_COLUMN(cc_token),
00630 "conditional compilation directive",
00631 0,
00632 STR_ARG);
00633 flush_cc_line();
00634 break;
00635 }
00636
00637 if (CC_LA_CH_VALUE != EOS) {
00638 ntr_next_msg_queue(CC_LA_CH_LINE, 1165, Error,
00639 CC_LA_CH_COLUMN,
00640 EOS_STR,
00641 0,
00642 STR_ARG);
00643 flush_cc_line();
00644 }
00645
00646 TRACE (Func_Exit, "parse_cc_line", NULL);
00647
00648 return(include_found);
00649
00650 }
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668 static void parse_define_str(int attr_idx)
00669
00670 {
00671 int arg_num;
00672 int id_start_idx;
00673 int i;
00674 int start_idx;
00675 cc_darg_type *arg_head = NULL;
00676 cc_darg_type *arg_tail = NULL;
00677
00678
00679 TRACE (Func_Entry, "parse_define_str", NULL);
00680
00681 if (CC_LA_CH_VALUE == LPAREN &&
00682 cc_stmt_buf[cc_stmt_buf_idx-1] != blank &&
00683 cc_stmt_buf[cc_stmt_buf_idx-1] != tab &&
00684 cc_stmt_buf[cc_stmt_buf_idx-1] != '/') {
00685
00686
00687 CC_NEXT_LA_CH;
00688 CC_AT_NUM_ARGS(attr_idx) = 0;
00689
00690 while (CC_LA_CH_VALUE != RPAREN) {
00691 cc_get_token(FALSE);
00692
00693 if (TOKEN_VALUE(cc_token) == Cc_Tok_Id) {
00694 if (arg_head == NULL) {
00695 arg_head = (cc_darg_type *)malloc(sizeof(cc_darg_type));
00696 arg_head->next = NULL;
00697 arg_tail = arg_head;
00698 }
00699 else {
00700 arg_tail->next = (cc_darg_type *)malloc(sizeof(cc_darg_type));
00701 arg_tail = arg_tail->next;
00702 arg_tail->next = NULL;
00703 }
00704
00705 for (i = 0; i < CC_NUM_ID_WDS; i++) {
00706 arg_tail->name.words[i] = TOKEN_STR_WD(cc_token, i);
00707 }
00708 arg_tail->name_len = TOKEN_LEN(cc_token);
00709 CC_AT_NUM_ARGS(attr_idx) += 1;
00710 # if 0
00711 printf("arg %d = >%s<\n", CC_AT_NUM_ARGS(attr_idx),
00712 arg_tail->name.string);
00713 # endif
00714 }
00715 else {
00716 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1165, Error,
00717 TOKEN_COLUMN(cc_token),
00718 "IDENTIFIER",
00719 0,
00720 STR_ARG);
00721 }
00722
00723 if (CC_LA_CH_VALUE == COMMA) {
00724 CC_NEXT_LA_CH;
00725 }
00726 else if (CC_LA_CH_VALUE != RPAREN) {
00727 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1165, Error,
00728 TOKEN_COLUMN(cc_token),
00729 ")",
00730 0,
00731 STR_ARG);
00732 flush_cc_line();
00733 goto EXIT;
00734 }
00735 }
00736
00737
00738 CC_NEXT_LA_CH;
00739
00740 start_idx = cc_stmt_buf_idx;
00741
00742 if (CC_LA_CH_VALUE == EOS) {
00743 CC_AT_STR_LEN(attr_idx) = 0;
00744 CC_AT_DEFINED(attr_idx) = TRUE;
00745 goto EXIT;
00746 }
00747
00748 while (CC_LA_CH_VALUE != EOS) {
00749 if (CC_LA_CH_CLASS == Ch_Class_Letter ||
00750 CC_LA_CH_VALUE == underscore) {
00751
00752 id_start_idx = cc_stmt_buf_idx;
00753 cc_get_token(FALSE);
00754
00755 if (TOKEN_VALUE(cc_token) == Cc_Tok_Id) {
00756
00757 if (strcmp(TOKEN_STR(cc_token), CC_AT_NAME_PTR(attr_idx))
00758 == 0) {
00759
00760 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1549, Warning,
00761 TOKEN_COLUMN(cc_token),
00762 TOKEN_STR(cc_token),
00763 0,
00764 STR_ARG);
00765 flush_cc_line();
00766 goto EXIT;
00767 }
00768 else {
00769 arg_num = 1;
00770 arg_tail = arg_head;
00771 while (arg_tail != NULL) {
00772
00773 if (strcmp(TOKEN_STR(cc_token), arg_tail->name.string)
00774 == 0) {
00775 # if 0
00776 printf("found match for %s\n", TOKEN_STR(cc_token));
00777 # endif
00778
00779 shift_cc_stmt_buf(id_start_idx+TOKEN_LEN(cc_token),
00780 3 - TOKEN_LEN(cc_token));
00781
00782 cc_stmt_buf[id_start_idx] = '\001';
00783 cc_stmt_buf[id_start_idx+1] = TOKEN_LEN(cc_token);
00784 cc_stmt_buf[id_start_idx+2] = arg_num;
00785
00786 cc_stmt_buf_idx = id_start_idx+2;
00787 CC_NEXT_LA_CH;
00788 break;
00789 }
00790 arg_tail = arg_tail->next;
00791 arg_num++;
00792 }
00793 }
00794 }
00795 }
00796 else {
00797 CC_NEXT_LA_CH;
00798 }
00799 }
00800
00801 copy_define_str(attr_idx, start_idx);
00802
00803 flush_cc_line();
00804
00805 # if 0
00806 printf("len = %d >%s<\n", len, CC_AT_STR_PTR(attr_idx));
00807 # endif
00808 }
00809 else if (CC_LA_CH_VALUE == EOS) {
00810 CC_AT_NUM_ARGS(attr_idx) = 0;
00811 CC_AT_STR_LEN(attr_idx) = 0;
00812
00813 }
00814 else {
00815 start_idx = cc_stmt_buf_idx;
00816
00817 while (CC_LA_CH_VALUE != EOS) {
00818 if (CC_LA_CH_CLASS == Ch_Class_Letter ||
00819 CC_LA_CH_VALUE == underscore) {
00820
00821 id_start_idx = cc_stmt_buf_idx;
00822 cc_get_token(FALSE);
00823
00824 if (TOKEN_VALUE(cc_token) == Cc_Tok_Id) {
00825
00826 if (strcmp(TOKEN_STR(cc_token), CC_AT_NAME_PTR(attr_idx))
00827 == 0) {
00828
00829 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1549, Warning,
00830 TOKEN_COLUMN(cc_token),
00831 TOKEN_STR(cc_token),
00832 0,
00833 STR_ARG);
00834 flush_cc_line();
00835 goto EXIT;
00836 }
00837 }
00838 }
00839 else {
00840 CC_NEXT_LA_CH;
00841 }
00842 }
00843
00844 CC_AT_NUM_ARGS(attr_idx) = 0;
00845
00846 copy_define_str(attr_idx, start_idx);
00847
00848 flush_cc_line();
00849
00850 # if 0
00851 printf(">%s<\n", CC_AT_STR_PTR(attr_idx));
00852 # endif
00853 }
00854
00855 CC_AT_DEFINED(attr_idx) = TRUE;
00856
00857 EXIT:
00858
00859 while (arg_head != NULL) {
00860 arg_tail = arg_head->next;
00861 free(arg_head);
00862 arg_head = arg_tail;
00863 }
00864
00865 TRACE (Func_Exit, "parse_define_str", NULL);
00866
00867 return;
00868
00869 }
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887 static void copy_define_str(int attr_idx,
00888 int start_idx)
00889
00890 {
00891 char *char_ptr;
00892 int col;
00893 int idx;
00894 int len;
00895 int line;
00896 int wd_len;
00897
00898 TRACE (Func_Entry, "copy_define_str", NULL);
00899
00900 idx = start_idx;
00901
00902 len = 0;
00903
00904 while (cc_stmt_buf[idx] != newline) {
00905 if (cc_stmt_buf[idx] == '/' &&
00906 cc_stmt_buf[idx+1] == '*') {
00907
00908 idx += 2;
00909 while (! (cc_stmt_buf[idx] == '*' &&
00910 cc_stmt_buf[idx + 1] == '/') &&
00911 cc_stmt_buf[idx] != newline) {
00912 idx++;
00913 }
00914
00915 if (cc_stmt_buf[idx] != newline) {
00916 idx++;
00917 }
00918 }
00919 else if (cc_stmt_buf[idx] == '\001') {
00920
00921
00922 idx += 2;
00923 len += 3;
00924 }
00925 else {
00926 len++;
00927 }
00928 idx++;
00929 }
00930
00931 idx--;
00932
00933 while (cc_stmt_buf[idx] == blank ||
00934 cc_stmt_buf[idx] == tab ||
00935 (cc_stmt_buf[idx] == '/' &&
00936 cc_stmt_buf[idx-1] == '*')) {
00937
00938 if (cc_stmt_buf[idx] == '/' &&
00939 cc_stmt_buf[idx-1] == '*') {
00940
00941 idx -= 2;
00942 while (! (cc_stmt_buf[idx] == '*' &&
00943 cc_stmt_buf[idx - 1] == '/')) {
00944 idx--;
00945 }
00946 idx--;
00947 }
00948 else {
00949 len--;
00950 }
00951
00952 idx--;
00953 }
00954
00955 find_line_and_col(start_idx, &line, &col);
00956 CC_AT_START_LINE(attr_idx) = line;
00957 CC_AT_START_COL(attr_idx) = col;
00958
00959 if (len > 512) {
00960 ntr_next_msg_queue(line, 1630, Error, col,
00961 CC_AT_NAME_PTR(attr_idx),
00962 512,
00963 STR_ARG_ARG);
00964 }
00965
00966 CC_AT_STR_LEN(attr_idx) = len;
00967
00968 wd_len = WORD_LEN(len);
00969 CC_AT_STR_IDX(attr_idx) = str_pool_idx + 1;
00970 TBL_REALLOC_CK(str_pool,wd_len);
00971
00972 str_pool[CC_AT_STR_IDX(attr_idx) + wd_len - 1].name_long = 0;
00973
00974 char_ptr = CC_AT_STR_PTR(attr_idx);
00975
00976 while (len > 0) {
00977 if (cc_stmt_buf[start_idx] == '/' &&
00978 cc_stmt_buf[start_idx+1] == '*') {
00979
00980
00981 start_idx += 2;
00982 while (! (cc_stmt_buf[start_idx] == '*' &&
00983 cc_stmt_buf[start_idx + 1] == '/') &&
00984 cc_stmt_buf[start_idx] != newline) {
00985 start_idx++;
00986 }
00987
00988 if (cc_stmt_buf[start_idx] != newline) {
00989 start_idx++;
00990 }
00991 }
00992 else {
00993 *char_ptr = cc_stmt_buf[start_idx];
00994 char_ptr++;
00995 len--;
00996 }
00997 start_idx++;
00998 }
00999
01000 TRACE (Func_Exit, "copy_define_str", NULL);
01001
01002 return;
01003
01004 }
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022 static void scan_cc_line(void)
01023
01024 {
01025 int attr_idx;
01026 char *char_ptr;
01027 int col;
01028 int i;
01029 int id_start_idx;
01030 int len;
01031 int line;
01032 int name_idx;
01033 int paren_cnt = 0;
01034 int save_cc_stmt_buf_idx;
01035
01036 TRACE (Func_Entry, "scan_cc_line", NULL);
01037
01038 save_cc_stmt_buf_idx = cc_stmt_buf_idx;
01039
01040 while (CC_LA_CH_VALUE != EOS) {
01041 if (CC_LA_CH_CLASS == Ch_Class_Letter ||
01042 CC_LA_CH_VALUE == underscore) {
01043
01044 id_start_idx = cc_stmt_buf_idx;
01045 cc_get_token(TRUE);
01046
01047 switch (TOKEN_VALUE(cc_token)) {
01048
01049 case Cc_Tok_Id :
01050 case Cc_Tok_Kwd_Define :
01051 case Cc_Tok_Kwd_Elif :
01052 case Cc_Tok_Kwd_Else :
01053 case Cc_Tok_Kwd_Endif :
01054 case Cc_Tok_Kwd_If :
01055 case Cc_Tok_Kwd_Ifdef :
01056 case Cc_Tok_Kwd_Ifndef :
01057 case Cc_Tok_Kwd_Include :
01058 case Cc_Tok_Kwd_Undef :
01059
01060 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
01061 TOKEN_LEN(cc_token),
01062 &name_idx);
01063
01064 if (attr_idx != NULL_IDX &&
01065 CC_AT_DEFINED(attr_idx)) {
01066
01067 if (CC_AT_NUM_ARGS(attr_idx) == 0) {
01068
01069 if (CC_AT_DYNAMIC_PREDEF(attr_idx)) {
01070 find_line_and_col(id_start_idx, &line, &col);
01071 char_ptr = get_dynamic_predef_str(attr_idx, line);
01072 len = strlen(char_ptr);
01073 }
01074 else {
01075 char_ptr = CC_AT_STR_PTR(attr_idx);
01076 len = CC_AT_STR_LEN(attr_idx);
01077 }
01078
01079 shift_cc_stmt_buf(id_start_idx+TOKEN_LEN(cc_token),
01080 len - TOKEN_LEN(cc_token));
01081
01082
01083 for (i = 0; i < len; i++) {
01084 cc_stmt_buf[i+id_start_idx] = char_ptr[i];
01085 }
01086
01087 cc_stmt_buf_idx = id_start_idx - 1;
01088 CC_NEXT_LA_CH;
01089 }
01090 else {
01091
01092 scan_cc_macro(attr_idx, id_start_idx);
01093 }
01094 }
01095 break;
01096
01097 case Cc_Tok_Kwd_Defined :
01098
01099
01100 while (CC_LA_CH_VALUE == '(') {
01101 paren_cnt++;
01102 CC_NEXT_LA_CH;
01103 }
01104
01105 cc_get_token(FALSE);
01106
01107 while (paren_cnt) {
01108 if (CC_LA_CH_VALUE != ')') {
01109 flush_cc_line();
01110 break;
01111 }
01112 else {
01113 CC_NEXT_LA_CH;
01114 paren_cnt--;
01115 }
01116 }
01117 break;
01118 }
01119 }
01120 else {
01121 CC_NEXT_LA_CH;
01122 }
01123 }
01124
01125 cc_stmt_buf_idx = save_cc_stmt_buf_idx - 1;
01126 CC_NEXT_LA_CH;
01127
01128 TRACE (Func_Exit, "scan_cc_line", NULL);
01129
01130 return;
01131
01132 }
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150 static void cc_advance_idx(void)
01151
01152 {
01153 int i;
01154 int save_pp_line_idx;
01155
01156 TRACE (Func_Entry, "cc_advance_idx", NULL);
01157
01158 save_pp_line_idx = pp_line_idx;
01159 prev_idx = cc_stmt_buf_idx;
01160
01161 cc_stmt_buf_idx++;
01162
01163 while (PP_LINE_TYPE == Comment_Line ||
01164 cc_stmt_buf_idx == PP_EOL) {
01165
01166
01167
01168 pp_line_idx++;
01169
01170 if (pp_line_idx > end_stmt_line_idx ||
01171 (PP_LINE_TYPE != Continuation_Line &&
01172 PP_LINE_TYPE != Dir_Continuation_Line)) {
01173
01174 cc_stmt_buf_idx = nxt_line_end_idx[save_pp_line_idx];
01175 break;
01176 }
01177
01178 if (source_form == Fixed_Form &&
01179 PP_LINE_TYPE == Continuation_Line) {
01180 cc_stmt_buf_idx = NULL_IDX;
01181
01182 for (i = NXT_COL(1); i < PP_IDX; i++) {
01183 if (VALID_CC_ID_CHAR(nxt_line[i])) {
01184 cc_stmt_buf_idx = i;
01185 break;
01186 }
01187 }
01188
01189 if (cc_stmt_buf_idx == NULL_IDX) {
01190 cc_stmt_buf_idx = PP_IDX + 1;
01191 }
01192 }
01193 else {
01194 cc_stmt_buf_idx = PP_IDX + 1;
01195 }
01196 }
01197
01198 TRACE (Func_Exit, "cc_advance_idx", NULL);
01199
01200 return;
01201
01202 }
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220 boolean scan_fixed_comment(void)
01221
01222 {
01223 int attr_idx;
01224 char *char_ptr;
01225 int col;
01226 boolean found_macro = FALSE;
01227 int i;
01228 int id_start_idx;
01229 int len;
01230 int macro_len;
01231 int name_idx;
01232 int save_pp_line_idx;
01233
01234 TRACE (Func_Entry, "scan_fixed_comment", NULL);
01235
01236 save_pp_line_idx = pp_line_idx;
01237
01238 end_stmt_line_idx = pp_line_idx;
01239
01240 cc_stmt_buf_idx = NXT_COL(0);
01241
01242
01243
01244 PP_LINE_TYPE = Regular_Line;
01245 cc_advance_idx();
01246
01247 id_start_idx = NXT_COL(1);
01248 col = nxt_line_col[NXT_COL(1)];
01249
01250 CC_GET_ID_TOKEN;
01251
01252 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
01253 TOKEN_LEN(cc_token),
01254 &name_idx);
01255
01256 if (attr_idx != NULL_IDX &&
01257 CC_AT_DEFINED(attr_idx)) {
01258
01259 found_macro = TRUE;
01260
01261 if (CC_AT_NUM_ARGS(attr_idx) == 0) {
01262
01263 if (CC_AT_DYNAMIC_PREDEF(attr_idx)) {
01264 char_ptr = get_dynamic_predef_str(attr_idx,
01265 TOKEN_LINE(cc_token));
01266 len = strlen(char_ptr);
01267 }
01268 else {
01269 char_ptr = CC_AT_STR_PTR(attr_idx);
01270 len = CC_AT_STR_LEN(attr_idx);
01271 }
01272
01273 macro_len = (prev_idx - id_start_idx) + 1;
01274 shift_nxt_line(id_start_idx + macro_len,
01275 len - macro_len);
01276
01277 for (i = 0; i < len; i++) {
01278 nxt_line[i+id_start_idx] = char_ptr[i];
01279 nxt_line_col[i+id_start_idx] = col;
01280 }
01281 }
01282 else {
01283 if (! scan_fortran_macro(attr_idx, id_start_idx, pp_line_idx)) {
01284 found_macro = FALSE;
01285 }
01286 }
01287 }
01288
01289 pp_line_idx = save_pp_line_idx;
01290
01291 if (found_macro) {
01292 for (i = NXT_COL(1); i <= nxt_line_end_idx[end_stmt_line_idx]; i++) {
01293 if (nxt_line[i] < 0) {
01294 nxt_line[i] = nxt_line[i] & 0xFF;
01295 }
01296 }
01297 }
01298
01299 PP_LINE_TYPE = Comment_Line;
01300
01301
01302 TRACE (Func_Exit, "scan_fixed_comment", NULL);
01303
01304 return(found_macro);
01305
01306 }
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324 boolean scan_fortran_stmt(void)
01325
01326 {
01327 int attr_idx;
01328 int col;
01329 char *char_ptr;
01330 int i;
01331 int id_start_idx;
01332 int len;
01333 int macro_len;
01334 int name_idx;
01335 boolean found_macro = FALSE;
01336 int save_pp_line_idx;
01337 int end_idx;
01338
01339 TRACE (Func_Entry, "scan_fortran_stmt", NULL);
01340
01341 end_stmt_line_idx = nxt_line_num_lines;
01342 pp_line_idx = 1;
01343
01344 cc_stmt_buf_idx = NXT_COL(0);
01345 cc_advance_idx();
01346
01347 while (cc_stmt_buf_idx < pp_nxt_line_EOL[end_stmt_line_idx]) {
01348
01349 if (nxt_line[cc_stmt_buf_idx] > 0 &&
01350 (ch_class[nxt_line[cc_stmt_buf_idx]] == Ch_Class_Letter ||
01351 nxt_line[cc_stmt_buf_idx] == underscore)) {
01352
01353 id_start_idx = cc_stmt_buf_idx;
01354 col = nxt_line_col[cc_stmt_buf_idx];
01355 save_pp_line_idx = pp_line_idx;
01356
01357 CC_GET_ID_TOKEN;
01358
01359 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
01360 TOKEN_LEN(cc_token),
01361 &name_idx);
01362
01363 if (attr_idx != NULL_IDX &&
01364 CC_AT_DEFINED(attr_idx)) {
01365
01366 found_macro = TRUE;
01367
01368 if (CC_AT_NUM_ARGS(attr_idx) == 0) {
01369
01370 if (CC_AT_DYNAMIC_PREDEF(attr_idx)) {
01371 char_ptr = get_dynamic_predef_str(attr_idx,
01372 TOKEN_LINE(cc_token));
01373 len = strlen(char_ptr);
01374 }
01375 else {
01376 char_ptr = CC_AT_STR_PTR(attr_idx);
01377 len = CC_AT_STR_LEN(attr_idx);
01378 }
01379
01380 end_idx = prev_idx + 1;
01381
01382 adjust_continued_macro(id_start_idx, &end_idx);
01383
01384 macro_len = end_idx - id_start_idx;
01385
01386 shift_nxt_line(end_idx,
01387 len - macro_len);
01388
01389 for (i = 0; i < len; i++) {
01390 nxt_line[i+id_start_idx] = char_ptr[i];
01391 nxt_line_col[i+id_start_idx] = col;
01392 }
01393
01394 cc_stmt_buf_idx = id_start_idx + len - 1;
01395 pp_line_idx = save_pp_line_idx;
01396 cc_advance_idx();
01397 }
01398 else {
01399 if (! scan_fortran_macro(attr_idx, id_start_idx,
01400 save_pp_line_idx)) {
01401 found_macro = FALSE;
01402 goto EXIT;
01403 }
01404 }
01405 }
01406 }
01407 else {
01408 cc_advance_idx();
01409 }
01410 }
01411
01412 EXIT:
01413
01414 if (found_macro) {
01415 for (i = 1; i <= nxt_line_end_idx[end_stmt_line_idx]; i++) {
01416 if (nxt_line[i] < 0) {
01417 nxt_line[i] = nxt_line[i] & 0xFF;
01418 }
01419 }
01420 }
01421
01422 TRACE (Func_Exit, "scan_fortran_stmt", NULL);
01423
01424 return(found_macro);
01425
01426 }
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444 static cc_arg_type *alloc_arg_entry(int num_chars)
01445
01446 {
01447 cc_arg_type *arg_ptr;
01448 int i;
01449
01450
01451 TRACE (Func_Entry, "alloc_arg_entry", NULL);
01452
01453 arg_ptr = (cc_arg_type *)malloc(sizeof(cc_arg_type));
01454
01455
01456 num_chars = ((num_chars+TARGET_CHARS_PER_WORD)/
01457 TARGET_CHARS_PER_WORD) * TARGET_CHARS_PER_WORD;
01458
01459 arg_ptr->name = (char *)malloc(num_chars);
01460
01461 for (i = 0; i < num_chars; i++) {
01462 arg_ptr->name[i] = '\0';
01463 }
01464
01465 TRACE (Func_Exit, "alloc_arg_entry", NULL);
01466
01467 return(arg_ptr);
01468
01469 }
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487 static void free_arg_entry(cc_arg_type *arg_entry)
01488
01489 {
01490
01491
01492 TRACE (Func_Entry, "free_arg_entry", NULL);
01493
01494 free(arg_entry->name);
01495 free(arg_entry);
01496
01497 TRACE (Func_Exit, "free_arg_entry", NULL);
01498
01499 return;
01500
01501 }
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519 static void scan_cc_macro(int attr_idx,
01520 int id_start_idx)
01521
01522 {
01523 int arg_num;
01524 char *char_ptr;
01525 int col;
01526 int i;
01527 int j;
01528 int k;
01529 int len;
01530 int line;
01531 int paren_cnt = 0;
01532 cc_arg_type *arg_head = NULL;
01533 cc_arg_type *arg_tail = NULL;
01534
01535 TRACE (Func_Entry, "scan_cc_macro", NULL);
01536
01537 if (CC_LA_CH_VALUE == LPAREN) {
01538
01539
01540 cc_stmt_buf_idx++;
01541
01542 arg_num = 1;
01543 while (arg_num <= CC_AT_NUM_ARGS(attr_idx)) {
01544
01545 i = 0;
01546 k = cc_stmt_buf_idx;
01547 paren_cnt = 0;
01548
01549 while ((cc_stmt_buf[k] != RPAREN ||
01550 paren_cnt > 0) &&
01551 (cc_stmt_buf[k] != COMMA ||
01552 paren_cnt > 0) &&
01553 cc_stmt_buf[k] != EOS) {
01554
01555 if (cc_stmt_buf[k] == LPAREN ||
01556 cc_stmt_buf[k] == '[') {
01557 paren_cnt++;
01558 }
01559 else if (cc_stmt_buf[k] == RPAREN ||
01560 cc_stmt_buf[k] == ']') {
01561 paren_cnt--;
01562 }
01563
01564 k++;
01565 i++;
01566 }
01567
01568 if (arg_head == NULL) {
01569 arg_head = alloc_arg_entry(i);
01570 arg_head->next = NULL;
01571 arg_tail = arg_head;
01572 }
01573 else {
01574 arg_tail->next = alloc_arg_entry(i);
01575 arg_tail = arg_tail->next;
01576 arg_tail->next = NULL;
01577 }
01578
01579 i = 0;
01580 paren_cnt = 0;
01581
01582 while ((cc_stmt_buf[cc_stmt_buf_idx] != RPAREN ||
01583 paren_cnt > 0) &&
01584 (cc_stmt_buf[cc_stmt_buf_idx] != COMMA ||
01585 paren_cnt > 0) &&
01586 cc_stmt_buf[cc_stmt_buf_idx] != EOS) {
01587
01588 if (cc_stmt_buf[cc_stmt_buf_idx] == LPAREN ||
01589 cc_stmt_buf[cc_stmt_buf_idx] == '[') {
01590 paren_cnt++;
01591 }
01592 else if (cc_stmt_buf[cc_stmt_buf_idx] == RPAREN ||
01593 cc_stmt_buf[cc_stmt_buf_idx] == ']') {
01594 paren_cnt--;
01595 }
01596
01597 arg_tail->name[i] = cc_stmt_buf[cc_stmt_buf_idx];
01598 cc_stmt_buf_idx++;
01599 i++;
01600 }
01601
01602 arg_tail->name_len = i;
01603
01604 if (cc_stmt_buf[cc_stmt_buf_idx] == COMMA &&
01605 arg_num < CC_AT_NUM_ARGS(attr_idx)) {
01606 CC_NEXT_LA_CH;
01607 }
01608 else if (cc_stmt_buf[cc_stmt_buf_idx] == RPAREN &&
01609 arg_num < CC_AT_NUM_ARGS(attr_idx)) {
01610
01611 find_line_and_col(cc_stmt_buf_idx, &line, &col);
01612 ntr_next_msg_queue(line, 1550, Warning, col,
01613 CC_AT_NAME_PTR(attr_idx),
01614 0,
01615 STR_ARG);
01616 flush_cc_line();
01617 goto EXIT;
01618 }
01619
01620 arg_num++;
01621 }
01622
01623 if (cc_stmt_buf[cc_stmt_buf_idx] != RPAREN) {
01624
01625 find_line_and_col(cc_stmt_buf_idx, &line, &col);
01626 ntr_next_msg_queue(line, 1551, Warning, col,
01627 CC_AT_NAME_PTR(attr_idx),
01628 0,
01629 STR_ARG);
01630 flush_cc_line();
01631 goto EXIT;
01632 }
01633
01634
01635
01636 len = CC_AT_STR_LEN(attr_idx);
01637
01638 for (i = 0; i < CC_AT_STR_LEN(attr_idx); i++) {
01639 if ((CC_AT_STR_PTR(attr_idx))[i] == '\001') {
01640 i += 2;
01641 arg_num = 1;
01642 arg_tail = arg_head;
01643 while (arg_num != (CC_AT_STR_PTR(attr_idx))[i]) {
01644 arg_tail = arg_tail->next;
01645 arg_num++;
01646 }
01647
01648 len += (arg_tail->name_len - 3);
01649 }
01650 }
01651
01652
01653
01654
01655 shift_cc_stmt_buf(cc_stmt_buf_idx,
01656 len-((cc_stmt_buf_idx - id_start_idx) + 1));
01657
01658 char_ptr = CC_AT_STR_PTR(attr_idx);
01659
01660 j = 0;
01661 i = 0;
01662 while (i < len) {
01663 if (char_ptr[j] == '\001') {
01664 j += 2;
01665 arg_num = 1;
01666 arg_tail = arg_head;
01667 while (arg_num != char_ptr[j]) {
01668 arg_tail = arg_tail->next;
01669 arg_num++;
01670 }
01671
01672 for (k = 0; k < arg_tail->name_len; k++) {
01673 cc_stmt_buf[i+id_start_idx] = arg_tail->name[k];
01674 i++;
01675 }
01676 }
01677 else {
01678 cc_stmt_buf[i+id_start_idx] = char_ptr[j];
01679 i++;
01680 }
01681
01682 j++;
01683 }
01684
01685 cc_stmt_buf_idx = id_start_idx - 1;
01686 CC_NEXT_LA_CH;
01687 }
01688
01689 EXIT:
01690
01691 while (arg_head != NULL) {
01692 arg_tail = arg_head->next;
01693 free_arg_entry(arg_head);
01694 arg_head = arg_tail;
01695 }
01696
01697 TRACE (Func_Exit, "scan_cc_macro", NULL);
01698
01699 return;
01700
01701 }
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716
01717
01718
01719 static boolean scan_fortran_macro(int attr_idx,
01720 int id_start_idx,
01721 int save_pp_line_idx)
01722
01723 {
01724 int arg_num;
01725 int col;
01726 int i;
01727 int j;
01728 boolean ok = TRUE;
01729 int paren_cnt = 0;
01730 cc_arg_type *arg_head = NULL;
01731 cc_arg_type *arg_tail = NULL;
01732 int save_line_idx;
01733 int save_cc_stmt_buf_idx;
01734
01735
01736 TRACE (Func_Entry, "scan_fortran_macro", NULL);
01737
01738 if (nxt_line[cc_stmt_buf_idx] == lparen) {
01739
01740
01741 col = nxt_line_col[id_start_idx];
01742
01743 cc_advance_idx();
01744
01745 arg_num = 1;
01746 while (arg_num <= CC_AT_NUM_ARGS(attr_idx)) {
01747
01748 while (nxt_line[cc_stmt_buf_idx] == blank ||
01749 nxt_line[cc_stmt_buf_idx] == tab) {
01750 cc_advance_idx();
01751 }
01752
01753 save_line_idx = pp_line_idx;
01754 save_cc_stmt_buf_idx = cc_stmt_buf_idx;
01755
01756 i = 0;
01757 paren_cnt = 0;
01758
01759 while ((nxt_line[cc_stmt_buf_idx] != rparen ||
01760 paren_cnt > 0) &&
01761 (nxt_line[cc_stmt_buf_idx] != comma ||
01762 paren_cnt > 0) &&
01763 nxt_line[cc_stmt_buf_idx] != eos) {
01764
01765 if (nxt_line[cc_stmt_buf_idx] == lparen ||
01766 nxt_line[cc_stmt_buf_idx] == lbrkt) {
01767 paren_cnt++;
01768 }
01769 else if (nxt_line[cc_stmt_buf_idx] == rparen ||
01770 nxt_line[cc_stmt_buf_idx] == rbrkt) {
01771 paren_cnt--;
01772 }
01773
01774 cc_advance_idx();
01775 i++;
01776 }
01777
01778 if (arg_head == NULL) {
01779 arg_head = alloc_arg_entry(i);
01780 arg_head->next = NULL;
01781 arg_tail = arg_head;
01782 }
01783 else {
01784 arg_tail->next = alloc_arg_entry(i);
01785 arg_tail = arg_tail->next;
01786 arg_tail->next = NULL;
01787 }
01788
01789 cc_stmt_buf_idx = save_cc_stmt_buf_idx;
01790 pp_line_idx = save_line_idx;
01791
01792 i = 0;
01793 paren_cnt = 0;
01794
01795 while ((nxt_line[cc_stmt_buf_idx] != rparen ||
01796 paren_cnt > 0) &&
01797 (nxt_line[cc_stmt_buf_idx] != comma ||
01798 paren_cnt > 0) &&
01799 nxt_line[cc_stmt_buf_idx] != eos) {
01800
01801 if (nxt_line[cc_stmt_buf_idx] == lparen ||
01802 nxt_line[cc_stmt_buf_idx] == lbrkt) {
01803 paren_cnt++;
01804 }
01805 else if (nxt_line[cc_stmt_buf_idx] == rparen ||
01806 nxt_line[cc_stmt_buf_idx] == rbrkt) {
01807 paren_cnt--;
01808 }
01809
01810 arg_tail->name[i] = nxt_line[cc_stmt_buf_idx];
01811 cc_advance_idx();
01812 i++;
01813 }
01814
01815 j = i - 1;
01816 while (arg_tail->name[j] == blank ||
01817 arg_tail->name[j] == tab) {
01818 j--;
01819 }
01820
01821 arg_tail->name[++j] = '\0';
01822 arg_tail->name_len = j;
01823
01824
01825 if (nxt_line[cc_stmt_buf_idx] == comma &&
01826 arg_num < CC_AT_NUM_ARGS(attr_idx)) {
01827 cc_advance_idx();
01828 }
01829 else if (nxt_line[cc_stmt_buf_idx] == rparen &&
01830 arg_num < CC_AT_NUM_ARGS(attr_idx)) {
01831
01832 ntr_next_msg_queue(PP_LINE_NUM, 1550, Warning,
01833 nxt_line_col[cc_stmt_buf_idx],
01834 CC_AT_NAME_PTR(attr_idx),
01835 0,
01836 STR_ARG);
01837 ok = FALSE;
01838 goto EXIT;
01839 }
01840
01841 arg_num++;
01842 }
01843
01844 if (nxt_line[cc_stmt_buf_idx] != rparen) {
01845
01846 ntr_next_msg_queue(PP_LINE_NUM, 1551, Warning,
01847 nxt_line_col[cc_stmt_buf_idx],
01848 CC_AT_NAME_PTR(attr_idx),
01849 0,
01850 STR_ARG);
01851 ok = FALSE;
01852 goto EXIT;
01853 }
01854
01855 insert_macro(attr_idx,
01856 arg_head,
01857 id_start_idx,
01858 col,
01859 save_pp_line_idx);
01860
01861 }
01862 else {
01863 ok = FALSE;
01864 }
01865
01866 EXIT:
01867
01868 while (arg_head != NULL) {
01869 arg_tail = arg_head->next;
01870 free_arg_entry(arg_head);
01871 arg_head = arg_tail;
01872 }
01873
01874 TRACE (Func_Exit, "scan_fortran_macro", NULL);
01875
01876 return(ok);
01877
01878 }
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896 void init_cond_comp(void)
01897
01898 {
01899 int ln_idx;
01900 int word;
01901
01902 TRACE (Func_Entry, "init_cond_comp", NULL);
01903
01904
01905
01906 for (word = 0; word < CC_NUM_ID_WDS; word++) {
01907 TOKEN_STR_WD(cc_initial_token, word) = 0;
01908 }
01909
01910 TOKEN_LEN(cc_initial_token) = 0;
01911 TOKEN_VALUE(cc_initial_token) = Cc_Tok_Unknown;
01912 TOKEN_ERR(cc_initial_token) = FALSE;
01913 TOKEN_KIND_STR(cc_initial_token)[0] = EOS;
01914 TOKEN_KIND_LEN(cc_initial_token) = 0;
01915 TOKEN_COLUMN(cc_initial_token) = 0;
01916 TOKEN_LINE(cc_initial_token) = 0;
01917
01918
01919 CHECK_INITIAL_ALLOC (cc_attr_tbl, NULL_IDX);
01920 CHECK_INITIAL_ALLOC (cc_ln_tbl, NULL_IDX);
01921 CHECK_INITIAL_ALLOC (cc_blk_stk_tbl, NULL_IDX);
01922
01923 ln_idx = cc_ln_tbl_idx + 1;
01924
01925 TBL_REALLOC_CK(cc_ln_tbl, 2);
01926 CLEAR_TBL_NTRY(cc_ln_tbl, ln_idx);
01927 CC_LN_NAME_IDX(ln_idx) = NAME_POOL_ZERO_IDX;
01928 CC_LN_NAME_LEN(ln_idx) = HOST_BYTES_PER_WORD;
01929 cc_ln_fw_idx = ln_idx;
01930
01931 CLEAR_TBL_NTRY(cc_ln_tbl, cc_ln_tbl_idx);
01932 CC_LN_NAME_IDX(cc_ln_tbl_idx) = NAME_POOL_ONES_IDX;
01933 CC_LN_NAME_LEN(cc_ln_tbl_idx) = HOST_BYTES_PER_WORD;
01934 cc_ln_lw_idx = cc_ln_tbl_idx;
01935
01936 TRACE (Func_Exit, "init_cond_comp", NULL);
01937
01938 return;
01939
01940 }
01941
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958 void enter_predefined_macros(void)
01959
01960 {
01961 int attr_idx;
01962 int name_idx;
01963
01964
01965 # if defined(_TARGET_OS_UNICOS) || defined(_TARGET_OS_MAX)
01966
01967 union {long int_form;
01968 char char_form[9];
01969 } cpu_type;
01970
01971 # endif
01972
01973
01974 TRACE (Func_Entry, "enter_predefined_macros", NULL);
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986 cc_token = cc_initial_token;
01987
01988 strcpy(TOKEN_STR(cc_token), "__line__");
01989 TOKEN_LEN(cc_token) = 8;
01990
01991 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
01992 TOKEN_LEN(cc_token),
01993 &name_idx);
01994
01995
01996 if (attr_idx == NULL_IDX) {
01997 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
01998 PUT_VALUE_IN_AT_STR(attr_idx, 1);
01999 CC_AT_DEFINED(attr_idx) = TRUE;
02000 CC_AT_DYNAMIC_PREDEF(attr_idx) = TRUE;
02001 line_macro_idx = attr_idx;
02002 }
02003 else {
02004
02005 }
02006
02007
02008
02009
02010
02011 cc_token = cc_initial_token;
02012
02013 strcpy(TOKEN_STR(cc_token), "__LINE__");
02014 TOKEN_LEN(cc_token) = 8;
02015
02016 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02017 TOKEN_LEN(cc_token),
02018 &name_idx);
02019
02020
02021 if (attr_idx == NULL_IDX) {
02022 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02023 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02024 CC_AT_DEFINED(attr_idx) = TRUE;
02025 CC_AT_DYNAMIC_PREDEF(attr_idx) = TRUE;
02026 LINE_macro_idx = attr_idx;
02027 }
02028 else {
02029
02030 }
02031
02032
02033
02034
02035
02036 cc_token = cc_initial_token;
02037
02038 strcpy(TOKEN_STR(cc_token), "__file__");
02039 TOKEN_LEN(cc_token) = 8;
02040
02041 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02042 TOKEN_LEN(cc_token),
02043 &name_idx);
02044
02045
02046 if (attr_idx == NULL_IDX) {
02047 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02048 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02049 CC_AT_DEFINED(attr_idx) = TRUE;
02050 CC_AT_DYNAMIC_PREDEF(attr_idx) = TRUE;
02051 file_macro_idx = attr_idx;
02052 }
02053 else {
02054
02055 }
02056
02057
02058
02059
02060
02061 cc_token = cc_initial_token;
02062
02063 strcpy(TOKEN_STR(cc_token), "__FILE__");
02064 TOKEN_LEN(cc_token) = 8;
02065
02066 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02067 TOKEN_LEN(cc_token),
02068 &name_idx);
02069
02070
02071 if (attr_idx == NULL_IDX) {
02072 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02073 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02074 CC_AT_DEFINED(attr_idx) = TRUE;
02075 CC_AT_DYNAMIC_PREDEF(attr_idx) = TRUE;
02076 FILE_macro_idx = attr_idx;
02077 }
02078 else {
02079
02080 }
02081
02082
02083
02084
02085
02086 cc_token = cc_initial_token;
02087
02088 strcpy(TOKEN_STR(cc_token), "__date__");
02089 TOKEN_LEN(cc_token) = 8;
02090
02091 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02092 TOKEN_LEN(cc_token),
02093 &name_idx);
02094
02095
02096 if (attr_idx == NULL_IDX) {
02097 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02098 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02099 CC_AT_DEFINED(attr_idx) = TRUE;
02100 CC_AT_DYNAMIC_PREDEF(attr_idx) = TRUE;
02101 date_macro_idx = attr_idx;
02102 }
02103 else {
02104
02105 }
02106
02107
02108
02109
02110
02111 cc_token = cc_initial_token;
02112
02113 strcpy(TOKEN_STR(cc_token), "__DATE__");
02114 TOKEN_LEN(cc_token) = 8;
02115
02116 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02117 TOKEN_LEN(cc_token),
02118 &name_idx);
02119
02120
02121 if (attr_idx == NULL_IDX) {
02122 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02123 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02124 CC_AT_DEFINED(attr_idx) = TRUE;
02125 CC_AT_DYNAMIC_PREDEF(attr_idx) = TRUE;
02126 DATE_macro_idx = attr_idx;
02127 }
02128 else {
02129
02130 }
02131
02132
02133
02134
02135
02136 cc_token = cc_initial_token;
02137
02138 strcpy(TOKEN_STR(cc_token), "__time__");
02139 TOKEN_LEN(cc_token) = 8;
02140
02141 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02142 TOKEN_LEN(cc_token),
02143 &name_idx);
02144
02145
02146 if (attr_idx == NULL_IDX) {
02147 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02148 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02149 CC_AT_DEFINED(attr_idx) = TRUE;
02150 CC_AT_DYNAMIC_PREDEF(attr_idx) = TRUE;
02151 time_macro_idx = attr_idx;
02152 }
02153 else {
02154
02155 }
02156
02157
02158
02159
02160
02161 cc_token = cc_initial_token;
02162
02163 strcpy(TOKEN_STR(cc_token), "__TIME__");
02164 TOKEN_LEN(cc_token) = 8;
02165
02166 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02167 TOKEN_LEN(cc_token),
02168 &name_idx);
02169
02170
02171 if (attr_idx == NULL_IDX) {
02172 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02173 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02174 CC_AT_DEFINED(attr_idx) = TRUE;
02175 CC_AT_DYNAMIC_PREDEF(attr_idx) = TRUE;
02176 TIME_macro_idx = attr_idx;
02177 }
02178 else {
02179
02180 }
02181
02182
02183 # ifdef _UNICOS
02184
02185
02186
02187
02188
02189 cc_token = cc_initial_token;
02190
02191 strcpy(TOKEN_STR(cc_token), "_UNICOS");
02192 TOKEN_LEN(cc_token) = 7;
02193
02194 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02195 TOKEN_LEN(cc_token),
02196 &name_idx);
02197
02198
02199 if (attr_idx == NULL_IDX) {
02200 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02201 PUT_VALUE_IN_AT_STR(attr_idx, _UNICOS);
02202 CC_AT_DEFINED(attr_idx) = TRUE;
02203 }
02204
02205
02206 # endif
02207
02208
02209 #if defined(_HOST_OS_UNICOS) || defined(_HOST_OS_SOLARIS) || \
02210 defined(_HOST_OS_MAX) || (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX))
02211
02212
02213
02214
02215
02216 cc_token = cc_initial_token;
02217
02218 strcpy(TOKEN_STR(cc_token), "unix");
02219 TOKEN_LEN(cc_token) = 4;
02220
02221 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02222 TOKEN_LEN(cc_token),
02223 &name_idx);
02224
02225 if (attr_idx == NULL_IDX) {
02226 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02227 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02228 CC_AT_DEFINED(attr_idx) = TRUE;
02229 }
02230
02231
02232
02233
02234
02235
02236 cc_token = cc_initial_token;
02237
02238 strcpy(TOKEN_STR(cc_token), "__unix");
02239 TOKEN_LEN(cc_token) = 6;
02240
02241 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02242 TOKEN_LEN(cc_token),
02243 &name_idx);
02244
02245 if (attr_idx == NULL_IDX) {
02246 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02247 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02248 CC_AT_DEFINED(attr_idx) = TRUE;
02249 }
02250
02251 # endif
02252
02253
02254 #if defined(_TARGET_OS_UNICOS) || defined(_TARGET_OS_MAX)
02255
02256
02257
02258
02259
02260
02261
02262 cc_token = cc_initial_token;
02263
02264 strcpy(TOKEN_STR(cc_token), "cray");
02265 TOKEN_LEN(cc_token) = 4;
02266
02267 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02268 TOKEN_LEN(cc_token),
02269 &name_idx);
02270
02271
02272 if (attr_idx == NULL_IDX) {
02273 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02274 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02275 CC_AT_DEFINED(attr_idx) = TRUE;
02276 }
02277
02278
02279
02280
02281
02282
02283 cc_token = cc_initial_token;
02284
02285 strcpy(TOKEN_STR(cc_token), "CRAY");
02286 TOKEN_LEN(cc_token) = 4;
02287
02288 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02289 TOKEN_LEN(cc_token),
02290 &name_idx);
02291
02292
02293 if (attr_idx == NULL_IDX) {
02294 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02295 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02296 CC_AT_DEFINED(attr_idx) = TRUE;
02297 }
02298
02299
02300
02301
02302
02303
02304 cc_token = cc_initial_token;
02305
02306 strcpy(TOKEN_STR(cc_token), "_CRAY");
02307 TOKEN_LEN(cc_token) = 5;
02308
02309 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02310 TOKEN_LEN(cc_token),
02311 &name_idx);
02312
02313 if (attr_idx == NULL_IDX) {
02314 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02315 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02316 CC_AT_DEFINED(attr_idx) = TRUE;
02317 }
02318
02319
02320
02321
02322
02323
02324 cc_token = cc_initial_token;
02325
02326 strcpy(TOKEN_STR(cc_token), "_MEMSIZE");
02327 TOKEN_LEN(cc_token) = 8;
02328
02329 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02330 TOKEN_LEN(cc_token),
02331 &name_idx);
02332
02333 if (attr_idx == NULL_IDX) {
02334 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02335 PUT_VALUE_IN_AT_STR(attr_idx, target_machine.fld.mcmsz);
02336 CC_AT_DEFINED(attr_idx) = TRUE;
02337 }
02338
02339 #endif
02340
02341
02342 # ifdef _TARGET_OS_UNICOS
02343
02344 # if defined(_GETPMC_AVAILABLE)
02345 cpu_type.int_form = target_machine.fld.mcpmt;
02346 cpu_type.char_form[8] = '\0';
02347 # else
02348 strcpy(cpu_type.char_form, target_machine.fld.mcpmt);
02349 # endif
02350
02351 if (strcmp("CRAY-C90", cpu_type.char_form) == 0) {
02352
02353
02354
02355
02356
02357 cc_token = cc_initial_token;
02358
02359 strcpy(TOKEN_STR(cc_token), "_CRAYC90");
02360 TOKEN_LEN(cc_token) = 8;
02361
02362 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02363 TOKEN_LEN(cc_token),
02364 &name_idx);
02365
02366 if (attr_idx == NULL_IDX) {
02367 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02368 PUT_VALUE_IN_AT_STR(attr_idx, 128);
02369 CC_AT_DEFINED(attr_idx) = TRUE;
02370 }
02371
02372
02373
02374
02375
02376
02377 cc_token = cc_initial_token;
02378
02379 strcpy(TOKEN_STR(cc_token), "_MAXVL");
02380 TOKEN_LEN(cc_token) = 6;
02381
02382 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02383 TOKEN_LEN(cc_token),
02384 &name_idx);
02385
02386 if (attr_idx == NULL_IDX) {
02387 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02388 PUT_VALUE_IN_AT_STR(attr_idx, 128);
02389 CC_AT_DEFINED(attr_idx) = TRUE;
02390 }
02391 }
02392 else if (strcmp("CRAY-TS", cpu_type.char_form) == 0) {
02393
02394
02395
02396
02397
02398 cc_token = cc_initial_token;
02399
02400 strcpy(TOKEN_STR(cc_token), "_CRAYT90");
02401 TOKEN_LEN(cc_token) = 8;
02402
02403 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02404 TOKEN_LEN(cc_token),
02405 &name_idx);
02406
02407 if (attr_idx == NULL_IDX) {
02408 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02409 PUT_VALUE_IN_AT_STR(attr_idx, 128);
02410 CC_AT_DEFINED(attr_idx) = TRUE;
02411 }
02412
02413
02414
02415
02416
02417 cc_token = cc_initial_token;
02418
02419 strcpy(TOKEN_STR(cc_token), "_MAXVL");
02420 TOKEN_LEN(cc_token) = 6;
02421
02422 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02423 TOKEN_LEN(cc_token),
02424 &name_idx);
02425
02426 if (attr_idx == NULL_IDX) {
02427 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02428 PUT_VALUE_IN_AT_STR(attr_idx, 128);
02429 CC_AT_DEFINED(attr_idx) = TRUE;
02430 }
02431
02432
02433
02434
02435
02436
02437 cc_token = cc_initial_token;
02438
02439 strcpy(TOKEN_STR(cc_token), "_ADDR64");
02440 TOKEN_LEN(cc_token) = 7;
02441
02442 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02443 TOKEN_LEN(cc_token),
02444 &name_idx);
02445
02446 if (attr_idx == NULL_IDX) {
02447 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02448 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02449 CC_AT_DEFINED(attr_idx) = TRUE;
02450 }
02451 }
02452 else if (strcmp("CRAY-YMP", cpu_type.char_form) == 0) {
02453
02454
02455
02456
02457
02458 cc_token = cc_initial_token;
02459 strcpy(TOKEN_STR(cc_token), "_MAXVL");
02460 TOKEN_LEN(cc_token) = 6;
02461
02462 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02463 TOKEN_LEN(cc_token),
02464 &name_idx);
02465
02466
02467 if (attr_idx == NULL_IDX) {
02468 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02469 PUT_VALUE_IN_AT_STR(attr_idx, 64);
02470 CC_AT_DEFINED(attr_idx) = TRUE;
02471 }
02472 }
02473
02474 if (target_machine.fld.mcaddr32) {
02475
02476
02477
02478
02479
02480 cc_token = cc_initial_token;
02481
02482 strcpy(TOKEN_STR(cc_token), "YMP");
02483 TOKEN_LEN(cc_token) = 3;
02484
02485 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02486 TOKEN_LEN(cc_token),
02487 &name_idx);
02488
02489 if (attr_idx == NULL_IDX) {
02490 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02491 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02492 CC_AT_DEFINED(attr_idx) = TRUE;
02493 }
02494
02495
02496
02497
02498
02499
02500 cc_token = cc_initial_token;
02501
02502 strcpy(TOKEN_STR(cc_token), "_ADDR32");
02503 TOKEN_LEN(cc_token) = 7;
02504
02505 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02506 TOKEN_LEN(cc_token),
02507 &name_idx);
02508
02509 if (attr_idx == NULL_IDX) {
02510 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02511 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02512 CC_AT_DEFINED(attr_idx) = TRUE;
02513 }
02514 }
02515
02516
02517 if (target_triton && target_ieee) {
02518
02519
02520
02521
02522
02523 cc_token = cc_initial_token;
02524
02525 strcpy(TOKEN_STR(cc_token), "_CRAYIEEE");
02526 TOKEN_LEN(cc_token) = 9;
02527
02528 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02529 TOKEN_LEN(cc_token),
02530 &name_idx);
02531
02532 if (attr_idx == NULL_IDX) {
02533 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02534 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02535 CC_AT_DEFINED(attr_idx) = TRUE;
02536 }
02537
02538 }
02539
02540 # endif
02541
02542
02543 # ifdef _TARGET_OS_MAX
02544
02545
02546
02547
02548
02549 cc_token = cc_initial_token;
02550
02551 strcpy(TOKEN_STR(cc_token), "_CRAYMPP");
02552 TOKEN_LEN(cc_token) = 8;
02553
02554 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02555 TOKEN_LEN(cc_token),
02556 &name_idx);
02557
02558 if (attr_idx == NULL_IDX) {
02559 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02560 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02561 CC_AT_DEFINED(attr_idx) = TRUE;
02562 }
02563
02564
02565
02566
02567
02568
02569 # if defined(_GETPMC_AVAILABLE)
02570 cpu_type.int_form = target_machine.fld.mcpmt;
02571 cpu_type.char_form[8] = '\0';
02572 # else
02573 strcpy(cpu_type.char_form, target_machine.fld.mcpmt);
02574 # endif
02575
02576 cc_token = cc_initial_token;
02577
02578 if (strcmp("CRAY-T3D", cpu_type.char_form) == 0) {
02579 strcpy(TOKEN_STR(cc_token), "_CRAYT3D");
02580 }
02581 else {
02582 strcpy(TOKEN_STR(cc_token), "_CRAYT3E");
02583 }
02584
02585 TOKEN_LEN(cc_token) = 8;
02586
02587 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02588 TOKEN_LEN(cc_token),
02589 &name_idx);
02590
02591 if (attr_idx == NULL_IDX) {
02592 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02593 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02594 CC_AT_DEFINED(attr_idx) = TRUE;
02595 }
02596
02597
02598
02599
02600
02601
02602 cc_token = cc_initial_token;
02603
02604 strcpy(TOKEN_STR(cc_token), "_CRAYIEEE");
02605 TOKEN_LEN(cc_token) = 9;
02606
02607 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02608 TOKEN_LEN(cc_token),
02609 &name_idx);
02610
02611 if (attr_idx == NULL_IDX) {
02612 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02613 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02614 CC_AT_DEFINED(attr_idx) = TRUE;
02615 }
02616
02617
02618
02619
02620
02621 cc_token = cc_initial_token;
02622
02623 strcpy(TOKEN_STR(cc_token), "_ADDR64");
02624 TOKEN_LEN(cc_token) = 7;
02625
02626 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02627 TOKEN_LEN(cc_token),
02628 &name_idx);
02629
02630 if (attr_idx == NULL_IDX) {
02631 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02632 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02633 CC_AT_DEFINED(attr_idx) = TRUE;
02634 }
02635
02636
02637 # endif
02638
02639
02640 #ifdef _TARGET_OS_SOLARIS
02641
02642 cc_token = cc_initial_token;
02643
02644 strcpy(TOKEN_STR(cc_token), "__sparc");
02645 TOKEN_LEN(cc_token) = 7;
02646
02647 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02648 TOKEN_LEN(cc_token),
02649 &name_idx);
02650
02651 if (attr_idx == NULL_IDX) {
02652 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02653 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02654 CC_AT_DEFINED(attr_idx) = TRUE;
02655 }
02656
02657 cc_token = cc_initial_token;
02658
02659 strcpy(TOKEN_STR(cc_token), "sun");
02660 TOKEN_LEN(cc_token) = 3;
02661
02662 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02663 TOKEN_LEN(cc_token),
02664 &name_idx);
02665
02666 if (attr_idx == NULL_IDX) {
02667 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02668 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02669 CC_AT_DEFINED(attr_idx) = TRUE;
02670 }
02671
02672 cc_token = cc_initial_token;
02673
02674 strcpy(TOKEN_STR(cc_token), "_SUN");
02675 TOKEN_LEN(cc_token) = 4;
02676
02677 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02678 TOKEN_LEN(cc_token),
02679 &name_idx);
02680
02681 if (attr_idx == NULL_IDX) {
02682 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02683 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02684 CC_AT_DEFINED(attr_idx) = TRUE;
02685 }
02686
02687 cc_token = cc_initial_token;
02688
02689 strcpy(TOKEN_STR(cc_token), "sparc");
02690 TOKEN_LEN(cc_token) = 5;
02691
02692 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02693 TOKEN_LEN(cc_token),
02694 &name_idx);
02695
02696 if (attr_idx == NULL_IDX) {
02697 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02698 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02699 CC_AT_DEFINED(attr_idx) = TRUE;
02700 }
02701
02702 cc_token = cc_initial_token;
02703
02704 strcpy(TOKEN_STR(cc_token), "_SPARC");
02705 TOKEN_LEN(cc_token) = 6;
02706
02707 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
02708 TOKEN_LEN(cc_token),
02709 &name_idx);
02710
02711 if (attr_idx == NULL_IDX) {
02712 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
02713 PUT_VALUE_IN_AT_STR(attr_idx, 1);
02714 CC_AT_DEFINED(attr_idx) = TRUE;
02715 }
02716
02717
02718 #endif
02719
02720
02721 TRACE (Func_Exit, "enter_predefined_macros", NULL);
02722
02723 return;
02724
02725 }
02726
02727
02728
02729
02730
02731
02732
02733
02734
02735
02736
02737
02738
02739
02740
02741
02742
02743
02744 static void cc_get_token(boolean keyword_expected)
02745
02746 {
02747 int i;
02748 int idx;
02749 boolean its_unsigned = FALSE;
02750 char upper_str[CC_MAX_ID_LEN+1];
02751 char str[80];
02752 long64 the_constant;
02753
02754
02755 TRACE (Func_Entry, "cc_get_token", NULL);
02756
02757 cc_token = cc_initial_token;
02758
02759 TOKEN_LINE(cc_token) = CC_LA_CH_LINE;
02760 TOKEN_COLUMN(cc_token) = CC_LA_CH_COLUMN;
02761
02762 if (CC_LA_CH_VALUE == eos) {
02763 TOKEN_VALUE(cc_token) = Cc_Tok_EOS;
02764 }
02765 else if (CC_LA_CH_CLASS == Ch_Class_Letter ||
02766 CC_LA_CH_VALUE == underscore) {
02767
02768
02769 TOKEN_LEN(cc_token) = 0;
02770
02771 while (cc_stmt_buf[cc_stmt_buf_idx] != newline &&
02772 cc_stmt_buf[cc_stmt_buf_idx] != blank &&
02773 cc_stmt_buf[cc_stmt_buf_idx] != tab &&
02774 VALID_CC_ID_CHAR(cc_stmt_buf[cc_stmt_buf_idx])) {
02775
02776 if (TOKEN_LEN(cc_token) < CC_MAX_ID_LEN) {
02777 ADD_TO_CC_TOKEN_STR(cc_stmt_buf[cc_stmt_buf_idx],
02778 TOKEN_LEN(cc_token));
02779 }
02780
02781 cc_stmt_buf_idx++;
02782 }
02783
02784 cc_stmt_buf_idx--;
02785 CC_NEXT_LA_CH;
02786
02787 TOKEN_VALUE(cc_token) = Cc_Tok_Id;
02788
02789
02790
02791 if (keyword_expected) {
02792
02793 for (i = 0; i < TOKEN_LEN(cc_token); i++) {
02794 if (islower((TOKEN_STR(cc_token))[i])) {
02795 upper_str[i] = TOUPPER((TOKEN_STR(cc_token))[i]);
02796 }
02797 else {
02798 upper_str[i] = (TOKEN_STR(cc_token))[i];
02799 }
02800 }
02801
02802 upper_str[i] ='\0';
02803
02804 switch(upper_str[0]) {
02805 case 'D':
02806 if (TOKEN_LEN(cc_token) == 6 &&
02807 EQUAL_STRS(upper_str, "DEFINE")) {
02808 TOKEN_VALUE(cc_token) = Cc_Tok_Kwd_Define;
02809 }
02810 else if (TOKEN_LEN(cc_token) == 7 &&
02811 EQUAL_STRS(upper_str, "DEFINED")) {
02812 TOKEN_VALUE(cc_token) = Cc_Tok_Kwd_Defined;
02813 }
02814 break;
02815
02816 case 'E':
02817 if (TOKEN_LEN(cc_token) == 4 &&
02818 EQUAL_STRS(upper_str, "ELIF")) {
02819 TOKEN_VALUE(cc_token) = Cc_Tok_Kwd_Elif;
02820 }
02821 else if (TOKEN_LEN(cc_token) == 4 &&
02822 EQUAL_STRS(upper_str, "ELSE")) {
02823 TOKEN_VALUE(cc_token) = Cc_Tok_Kwd_Else;
02824 }
02825 else if (TOKEN_LEN(cc_token) == 5 &&
02826 EQUAL_STRS(upper_str, "ENDIF")) {
02827 TOKEN_VALUE(cc_token) = Cc_Tok_Kwd_Endif;
02828 }
02829 else if (TOKEN_LEN(cc_token) == 5 &&
02830 EQUAL_STRS(upper_str, "ERROR")) {
02831 TOKEN_VALUE(cc_token) = Cc_Tok_Kwd_Error;
02832 }
02833 break;
02834
02835 case 'I':
02836 if (TOKEN_LEN(cc_token) == 2 &&
02837 EQUAL_STRS(upper_str, "IF")) {
02838 TOKEN_VALUE(cc_token) = Cc_Tok_Kwd_If;
02839 }
02840 else if (TOKEN_LEN(cc_token) == 5 &&
02841 EQUAL_STRS(upper_str, "IFDEF")) {
02842 TOKEN_VALUE(cc_token) = Cc_Tok_Kwd_Ifdef;
02843 }
02844 else if (TOKEN_LEN(cc_token) == 6 &&
02845 EQUAL_STRS(upper_str, "IFNDEF")) {
02846 TOKEN_VALUE(cc_token) = Cc_Tok_Kwd_Ifndef;
02847 }
02848 else if (TOKEN_LEN(cc_token) == 7 &&
02849 EQUAL_STRS(upper_str, "INCLUDE")) {
02850 TOKEN_VALUE(cc_token) = Cc_Tok_Kwd_Include;
02851 }
02852
02853 break;
02854
02855 case 'U':
02856 if (TOKEN_LEN(cc_token) == 5 &&
02857 EQUAL_STRS(upper_str, "UNDEF")) {
02858 TOKEN_VALUE(cc_token) = Cc_Tok_Kwd_Undef;
02859 }
02860
02861 break;
02862
02863 }
02864 }
02865 }
02866 else if (CC_LA_CH_CLASS == Ch_Class_Digit) {
02867
02868 idx = 0;
02869 if (CC_LA_CH_VALUE == ZERO) {
02870
02871
02872 str[idx] = CC_LA_CH_VALUE;
02873 idx++;
02874 CC_NEXT_LA_CH;
02875
02876 if (CC_LA_CH_VALUE == 'X' ||
02877 CC_LA_CH_VALUE == 'x') {
02878 str[idx] = CC_LA_CH_VALUE;
02879 idx++;
02880 CC_NEXT_LA_CH;
02881 }
02882 }
02883
02884 while (CC_LA_CH_CLASS == Ch_Class_Digit &&
02885 idx < 79) {
02886 str[idx] = CC_LA_CH_VALUE;
02887 CC_NEXT_LA_CH;
02888 idx++;
02889 }
02890
02891 str[idx] = '\0';
02892
02893 if (CC_LA_CH_VALUE == 'L' ||
02894 CC_LA_CH_VALUE == 'l') {
02895
02896 CC_NEXT_LA_CH;
02897
02898 if (CC_LA_CH_VALUE == 'U' ||
02899 CC_LA_CH_VALUE == 'u') {
02900
02901 CC_NEXT_LA_CH;
02902 its_unsigned = TRUE;
02903 }
02904 }
02905
02906 if (CC_LA_CH_VALUE == 'U' ||
02907 CC_LA_CH_VALUE == 'u') {
02908
02909 CC_NEXT_LA_CH;
02910 its_unsigned = TRUE;
02911
02912 if (CC_LA_CH_VALUE == 'L' ||
02913 CC_LA_CH_VALUE == 'l') {
02914
02915 CC_NEXT_LA_CH;
02916 }
02917 }
02918
02919 if (its_unsigned) {
02920 the_constant = (long64) strtoul(str, NULL, 0);
02921 }
02922 else {
02923 the_constant = (long64) strtol(str, NULL, 0);
02924 }
02925
02926 TOKEN_CONST_TBL_IDX(cc_token) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
02927 the_constant);
02928
02929 TOKEN_VALUE(cc_token) = Cc_Tok_Constant;
02930
02931 }
02932 else {
02933
02934 switch(CC_LA_CH_VALUE) {
02935
02936 case '#':
02937
02938 CC_NEXT_LA_CH;
02939 break;
02940
02941 case '+':
02942 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Add;
02943
02944 CC_NEXT_LA_CH;
02945 break;
02946
02947 case '/':
02948 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Div;
02949
02950 CC_NEXT_LA_CH;
02951 break;
02952
02953 case '%':
02954 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Mod;
02955
02956 CC_NEXT_LA_CH;
02957 break;
02958
02959 case '*':
02960 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Mult;
02961
02962 CC_NEXT_LA_CH;
02963 break;
02964
02965 case '-':
02966 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Sub;
02967
02968 CC_NEXT_LA_CH;
02969 break;
02970
02971 case '!':
02972 if (cc_stmt_buf[cc_stmt_buf_idx + 1] == '=') {
02973 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Ne;
02974 CC_NEXT_LA_CH;
02975 }
02976 else {
02977 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Not;
02978 }
02979
02980 CC_NEXT_LA_CH;
02981 break;
02982
02983 case '~':
02984 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Bnot;
02985
02986 CC_NEXT_LA_CH;
02987 break;
02988
02989 case '^':
02990 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Neqv;
02991
02992 CC_NEXT_LA_CH;
02993 break;
02994
02995 case '=':
02996 if (cc_stmt_buf[cc_stmt_buf_idx+1] == '=') {
02997 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Eq;
02998 CC_NEXT_LA_CH;
02999 }
03000
03001 CC_NEXT_LA_CH;
03002 break;
03003
03004 case '>':
03005
03006 if (cc_stmt_buf[cc_stmt_buf_idx + 1] == '=') {
03007 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Ge;
03008 CC_NEXT_LA_CH;
03009 }
03010 else if (cc_stmt_buf[cc_stmt_buf_idx + 1] == '>') {
03011 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Rshift;
03012 CC_NEXT_LA_CH;
03013 }
03014 else {
03015 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Gt;
03016 }
03017
03018 CC_NEXT_LA_CH;
03019 break;
03020
03021 case '<':
03022
03023 if (cc_stmt_buf[cc_stmt_buf_idx + 1] == '=') {
03024 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Le;
03025 CC_NEXT_LA_CH;
03026 }
03027 else if (cc_stmt_buf[cc_stmt_buf_idx + 1] == '<') {
03028 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Lshift;
03029 CC_NEXT_LA_CH;
03030 }
03031 else {
03032 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Lt;
03033 }
03034
03035 CC_NEXT_LA_CH;
03036 break;
03037
03038 case '&':
03039
03040 if (cc_stmt_buf[cc_stmt_buf_idx + 1] == '&') {
03041 TOKEN_VALUE(cc_token) = Cc_Tok_Op_And;
03042 CC_NEXT_LA_CH;
03043 }
03044 else {
03045 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Band;
03046 }
03047
03048 CC_NEXT_LA_CH;
03049 break;
03050
03051 case '|':
03052
03053 if (cc_stmt_buf[cc_stmt_buf_idx + 1] == '|') {
03054 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Or;
03055 CC_NEXT_LA_CH;
03056 }
03057 else {
03058 TOKEN_VALUE(cc_token) = Cc_Tok_Op_Bor;
03059 }
03060
03061 CC_NEXT_LA_CH;
03062 break;
03063
03064 }
03065
03066 }
03067
03068 TRACE (Func_Exit, "cc_get_token", NULL);
03069
03070 return;
03071
03072 }
03073
03074
03075
03076
03077
03078
03079
03080
03081
03082
03083
03084
03085
03086
03087
03088
03089
03090 static void cc_get_next_char(void)
03091
03092 {
03093
03094 int col;
03095 int line;
03096
03097
03098 TRACE (Func_Entry, "cc_get_next_char", NULL);
03099
03100 cc_stmt_buf_idx++;
03101
03102 BACK:
03103
03104
03105 while (cc_stmt_buf[cc_stmt_buf_idx] == blank ||
03106 cc_stmt_buf[cc_stmt_buf_idx] == tab) {
03107
03108 cc_stmt_buf_idx++;
03109 }
03110
03111 if (cc_stmt_buf[cc_stmt_buf_idx] == '/' &&
03112 cc_stmt_buf[cc_stmt_buf_idx + 1] == '*') {
03113
03114 cc_stmt_buf_idx += 2;
03115
03116 while (! (cc_stmt_buf[cc_stmt_buf_idx] == '*' &&
03117 cc_stmt_buf[cc_stmt_buf_idx + 1] == '/') &&
03118 cc_stmt_buf[cc_stmt_buf_idx] != newline) {
03119 cc_stmt_buf_idx++;
03120 }
03121
03122 if (cc_stmt_buf[cc_stmt_buf_idx] != newline) {
03123 cc_stmt_buf_idx += 2;
03124 goto BACK;
03125 }
03126 }
03127
03128 if (cc_stmt_buf[cc_stmt_buf_idx] == newline) {
03129 CC_LA_CH_VALUE = eos;
03130 }
03131 else {
03132 CC_LA_CH_VALUE = cc_stmt_buf[cc_stmt_buf_idx];
03133 }
03134
03135 find_line_and_col(cc_stmt_buf_idx, &line, &col);
03136 CC_LA_CH_LINE = line;
03137 CC_LA_CH_COLUMN = col;
03138 CC_LA_CH_CLASS = (CC_LA_CH_VALUE == (char) EOF) ?
03139 Ch_Class_EOF : ch_class[CC_LA_CH_VALUE];
03140
03141
03142 TRACE (Func_Exit, "cc_get_next_char", NULL);
03143
03144 return;
03145
03146 }
03147
03148
03149
03150
03151
03152
03153
03154
03155
03156
03157
03158
03159
03160
03161
03162
03163
03164 static void cc_get_stmt(void)
03165
03166 {
03167 int char_start_idx;
03168 int comment_start_idx;
03169 char delim;
03170 int idx;
03171 boolean in_char_context = FALSE;
03172 boolean is_define_dir = FALSE;
03173 int save_idx;
03174 int start_col;
03175 int start_line;
03176
03177 TRACE (Func_Entry, "cc_get_stmt", NULL);
03178
03179 cc_line_continued = FALSE;
03180
03181 cc_stmt_buf_len = cc_stmt_buf_idx;
03182 cc_stmt_buf_idx = NULL_IDX;
03183
03184 CC_NEXT_LA_CH;
03185
03186 CC_NEXT_LA_CH;
03187
03188 cc_get_token(TRUE);
03189
03190 if (TOKEN_VALUE(cc_token) == Cc_Tok_Kwd_Define) {
03191 is_define_dir = TRUE;
03192 }
03193
03194 cc_stmt_buf_idx = NULL_IDX;
03195
03196 while (cc_stmt_buf[++cc_stmt_buf_idx] != eos) {
03197
03198 if (cc_stmt_buf[cc_stmt_buf_idx] == QUOTE ||
03199 cc_stmt_buf[cc_stmt_buf_idx] == DBL_QUOTE) {
03200
03201 if (in_char_context) {
03202
03203 if (delim == cc_stmt_buf[cc_stmt_buf_idx] &&
03204 delim != cc_stmt_buf[cc_stmt_buf_idx+1]) {
03205 in_char_context = FALSE;
03206 }
03207 else if (delim == cc_stmt_buf[cc_stmt_buf_idx] &&
03208 delim == cc_stmt_buf[cc_stmt_buf_idx+1]) {
03209 cc_stmt_buf_idx++;
03210 }
03211 }
03212 else {
03213
03214
03215 in_char_context = TRUE;
03216 char_start_idx = cc_stmt_buf_idx;
03217 delim = cc_stmt_buf[cc_stmt_buf_idx];
03218 }
03219 }
03220
03221 if (! in_char_context &&
03222 cc_stmt_buf[cc_stmt_buf_idx] == '/' &&
03223 cc_stmt_buf[cc_stmt_buf_idx + 1] == '*') {
03224
03225 comment_start_idx = cc_stmt_buf_idx;
03226 start_line = cc_stmt_buf_line[cc_stmt_buf_num_lines].line;
03227 start_col = comment_start_idx -
03228 cc_stmt_buf_line[cc_stmt_buf_num_lines].start_idx;
03229 cc_stmt_buf_idx += 2;
03230
03231 while (! (cc_stmt_buf[cc_stmt_buf_idx] == '*' &&
03232 cc_stmt_buf[cc_stmt_buf_idx + 1] == '/')) {
03233
03234 # if 0
03235 if (cc_stmt_buf[cc_stmt_buf_idx] == eos ||
03236 cc_stmt_buf_idx >= MAX_STMT_CHAR_SIZE - MAX_SRC_LINE_SIZE) {
03237 ntr_next_msg_queue(start_line, xxxx, Error,
03238 start_col,
03239 (char *)NULL,
03240 0,
03241 NO_ARG);
03242 goto EXIT;
03243 }
03244 # endif
03245
03246 if (cc_stmt_buf[cc_stmt_buf_idx] == newline) {
03247 cc_stmt_buf_idx--;
03248 save_idx = cc_stmt_buf_idx;
03249 read_line(TRUE);
03250 cc_stmt_buf_len = cc_stmt_buf_idx;
03251 cc_line_continued = TRUE;
03252 cc_stmt_buf_idx = save_idx;
03253
03254 if (on_off_flags.preprocess_only || on_off_flags.save_dot_i) {
03255
03256 fprintf(dot_i_fptr, "\n");
03257 }
03258 }
03259 cc_stmt_buf_idx++;
03260 }
03261
03262 cc_stmt_buf_idx += 2;
03263 }
03264
03265
03266 if (cc_stmt_buf[cc_stmt_buf_idx] == newline &&
03267 cc_stmt_buf[cc_stmt_buf_idx - 1] == '\\') {
03268 cc_stmt_buf_idx -= 2;
03269
03270 save_idx = cc_stmt_buf_idx;
03271 read_line(TRUE);
03272 cc_stmt_buf_len = cc_stmt_buf_idx;
03273 cc_line_continued = TRUE;
03274 cc_stmt_buf_idx = save_idx;
03275
03276 if (on_off_flags.preprocess_only || on_off_flags.save_dot_i) {
03277
03278 fprintf(dot_i_fptr, "\n");
03279 }
03280
03281 }
03282 else if (is_define_dir &&
03283 cc_stmt_buf[cc_stmt_buf_idx] == amp &&
03284 source_form == Free_Form) {
03285
03286 idx = cc_stmt_buf_idx + 1;
03287
03288 while (cc_stmt_buf[idx] == blank ||
03289 cc_stmt_buf[idx] == tab) {
03290 idx++;
03291 }
03292
03293 if (cc_stmt_buf[idx] == '!' ||
03294 cc_stmt_buf[idx] == newline) {
03295
03296 cc_stmt_buf_idx--;
03297
03298 save_idx = cc_stmt_buf_idx;
03299 read_line(TRUE);
03300 cc_stmt_buf_len = cc_stmt_buf_idx;
03301 cc_line_continued = TRUE;
03302 cc_stmt_buf_idx = save_idx;
03303
03304 idx = cc_stmt_buf_idx + 1;
03305
03306 while (cc_stmt_buf[idx] == blank ||
03307 cc_stmt_buf[idx] == tab) {
03308 idx++;
03309 }
03310
03311 if (cc_stmt_buf[idx] == amp) {
03312 shift_cc_stmt_buf(idx+1,
03313 cc_stmt_buf_idx - idx);
03314 }
03315
03316 if (on_off_flags.preprocess_only || on_off_flags.save_dot_i) {
03317
03318 fprintf(dot_i_fptr, "\n");
03319 }
03320 }
03321 }
03322 else if (! in_char_context &&
03323 is_define_dir &&
03324 cc_stmt_buf[cc_stmt_buf_idx] == '!') {
03325
03326 idx = cc_stmt_buf_idx;
03327 while (cc_stmt_buf[idx] != newline) {
03328 idx++;
03329 }
03330
03331 if (cc_stmt_buf[idx-1] == '\\') {
03332 idx--;
03333 }
03334
03335 shift_cc_stmt_buf(idx,
03336 cc_stmt_buf_idx - idx);
03337 cc_stmt_buf_idx--;
03338
03339 }
03340 }
03341
03342 if (in_char_context) {
03343 find_line_and_col(char_start_idx, &start_line, &start_col);
03344 ntr_next_msg_queue(start_line, 1631, Warning,
03345 start_col,
03346 (char *)NULL,
03347 0,
03348 NO_ARG);
03349 }
03350
03351 # if 0
03352 EXIT:
03353 # endif
03354
03355 cc_stmt_buf_line[cc_stmt_buf_num_lines+1].line =
03356 cc_stmt_buf_line[cc_stmt_buf_num_lines].line;
03357 cc_stmt_buf_line[cc_stmt_buf_num_lines+1].start_idx = cc_stmt_buf_idx;
03358 cc_stmt_buf_len = cc_stmt_buf_idx;
03359 cc_stmt_buf[cc_stmt_buf_idx+1] = '\0';
03360 cc_stmt_buf_idx = NULL_IDX;
03361
03362 TRACE (Func_Exit, "cc_get_stmt", NULL);
03363
03364 return;
03365
03366 }
03367
03368
03369
03370
03371
03372
03373
03374
03375
03376
03377
03378
03379
03380
03381
03382
03383 static boolean parse_cc_expr (opnd_type *result)
03384
03385 {
03386 opnd_type opnd;
03387 boolean parsed_ok = TRUE;
03388
03389 TRACE (Func_Entry, "parse_cc_expr", NULL);
03390
03391 parsed_ok = parse_cc_level_8(&opnd);
03392
03393 COPY_OPND((*result), opnd)
03394
03395 # if 0
03396 print_ir(OPND_IDX(opnd));
03397 # endif
03398
03399 TRACE (Func_Exit, "parse_cc_expr", NULL);
03400
03401 return(parsed_ok);
03402 }
03403
03404
03405
03406
03407
03408
03409
03410
03411
03412
03413
03414
03415
03416
03417
03418
03419
03420 static boolean parse_cc_mult_opnd(opnd_type *result)
03421
03422 {
03423 int ir_idx = NULL_IDX;
03424 opnd_type opnd;
03425 boolean parsed_ok = TRUE;
03426
03427
03428 TRACE (Func_Entry, "parse_cc_mult_opnd", NULL);
03429
03430 if ((cc_stmt_buf[cc_stmt_buf_idx] == '!' &&
03431 cc_stmt_buf[cc_stmt_buf_idx+1] != '=') ||
03432 cc_stmt_buf[cc_stmt_buf_idx] == '~' ||
03433 cc_stmt_buf[cc_stmt_buf_idx] == '+' ||
03434 cc_stmt_buf[cc_stmt_buf_idx] == '-') {
03435
03436 cc_get_token(FALSE);
03437
03438 NTR_IR_TBL(ir_idx);
03439 OPND_FLD((*result)) = IR_Tbl_Idx;
03440 OPND_IDX((*result)) = ir_idx;
03441 switch (TOKEN_VALUE(cc_token)) {
03442 case Cc_Tok_Op_Add :
03443 IR_OPR(ir_idx) = Uplus_Opr;
03444 break;
03445 case Cc_Tok_Op_Sub :
03446 IR_OPR(ir_idx) = Uminus_Opr;
03447 break;
03448 case Cc_Tok_Op_Bnot :
03449 IR_OPR(ir_idx) = Bnot_Opr;
03450 break;
03451 case Cc_Tok_Op_Not :
03452 IR_OPR(ir_idx) = Not_Opr;
03453 break;
03454 }
03455
03456 IR_LINE_NUM(ir_idx) = TOKEN_LINE(cc_token);
03457 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(cc_token);
03458 }
03459
03460 parsed_ok = parse_cc_operand(&opnd);
03461
03462 if (ir_idx) {
03463 COPY_OPND(IR_OPND_L(ir_idx), opnd);
03464 }
03465 else {
03466 COPY_OPND((*result), opnd);
03467 }
03468
03469 TRACE (Func_Exit, "parse_cc_mult_opnd", NULL);
03470
03471 return(parsed_ok);
03472 }
03473
03474
03475
03476
03477
03478
03479
03480
03481
03482
03483
03484
03485
03486
03487
03488
03489
03490 static boolean parse_cc_add_opnd(opnd_type *result)
03491
03492 {
03493 int ir_idx;
03494 opnd_type opnd;
03495 boolean parsed_ok = TRUE;
03496
03497 TRACE (Func_Entry, "parse_cc_add_opnd", NULL);
03498
03499 parsed_ok = parse_cc_mult_opnd(&opnd) && parsed_ok;
03500
03501 if (CC_LA_CH_VALUE == '+' ||
03502 CC_LA_CH_VALUE == '/' ||
03503 CC_LA_CH_VALUE == '%' ||
03504 CC_LA_CH_VALUE == '*' ||
03505 CC_LA_CH_VALUE == '-' ||
03506 CC_LA_CH_VALUE == '!' ||
03507 CC_LA_CH_VALUE == '~' ||
03508 CC_LA_CH_VALUE == '^' ||
03509 CC_LA_CH_VALUE == '=' ||
03510 CC_LA_CH_VALUE == '>' ||
03511 CC_LA_CH_VALUE == '<' ||
03512 CC_LA_CH_VALUE == '&' ||
03513 CC_LA_CH_VALUE == '|') {
03514
03515 cc_get_token(FALSE);
03516 }
03517
03518 while (TOKEN_VALUE(cc_token) == Cc_Tok_Op_Mult ||
03519 TOKEN_VALUE(cc_token) == Cc_Tok_Op_Div ||
03520 TOKEN_VALUE(cc_token) == Cc_Tok_Op_Mod) {
03521
03522 NTR_IR_TBL(ir_idx);
03523 switch (TOKEN_VALUE(cc_token)) {
03524 case Cc_Tok_Op_Mult :
03525 IR_OPR(ir_idx) = Mult_Opr;
03526 break;
03527 case Cc_Tok_Op_Div :
03528 IR_OPR(ir_idx) = Div_Opr;
03529 break;
03530 case Cc_Tok_Op_Mod :
03531 IR_OPR(ir_idx) = Mod_Opr;
03532 break;
03533 }
03534 IR_LINE_NUM(ir_idx) = TOKEN_LINE(cc_token);
03535 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(cc_token);
03536
03537 COPY_OPND(IR_OPND_L(ir_idx), opnd);
03538
03539 parsed_ok = parse_cc_mult_opnd(&opnd) && parsed_ok;
03540
03541 COPY_OPND(IR_OPND_R(ir_idx), opnd);
03542
03543 OPND_FLD(opnd) = IR_Tbl_Idx;
03544 OPND_IDX(opnd) = ir_idx;
03545
03546 if (CC_LA_CH_VALUE == '+' ||
03547 CC_LA_CH_VALUE == '/' ||
03548 CC_LA_CH_VALUE == '%' ||
03549 CC_LA_CH_VALUE == '*' ||
03550 CC_LA_CH_VALUE == '-' ||
03551 CC_LA_CH_VALUE == '!' ||
03552 CC_LA_CH_VALUE == '~' ||
03553 CC_LA_CH_VALUE == '^' ||
03554 CC_LA_CH_VALUE == '=' ||
03555 CC_LA_CH_VALUE == '>' ||
03556 CC_LA_CH_VALUE == '<' ||
03557 CC_LA_CH_VALUE == '&' ||
03558 CC_LA_CH_VALUE == '|') {
03559
03560 cc_get_token(FALSE);
03561 }
03562 }
03563
03564 COPY_OPND((*result), opnd)
03565
03566 TRACE (Func_Exit, "parse_cc_add_opnd", NULL);
03567
03568 return(parsed_ok);
03569 }
03570
03571
03572
03573
03574
03575
03576
03577
03578
03579
03580
03581
03582
03583
03584
03585
03586
03587 static boolean parse_cc_level_2(opnd_type *result)
03588
03589 {
03590 int ir_idx = NULL_IDX;
03591 opnd_type opnd;
03592 boolean parsed_ok = TRUE;
03593
03594 TRACE (Func_Entry, "parse_cc_level_2", NULL);
03595
03596 parsed_ok = parse_cc_add_opnd(&opnd);
03597
03598 if (ir_idx) {
03599 COPY_OPND(IR_OPND_L(ir_idx), opnd);
03600 OPND_FLD(opnd) = IR_Tbl_Idx;
03601 OPND_IDX(opnd) = ir_idx;
03602 }
03603
03604 while (TOKEN_VALUE(cc_token) == Cc_Tok_Op_Add ||
03605 TOKEN_VALUE(cc_token) == Cc_Tok_Op_Sub) {
03606
03607 NTR_IR_TBL(ir_idx);
03608 switch (TOKEN_VALUE(cc_token)) {
03609 case Cc_Tok_Op_Add :
03610 IR_OPR(ir_idx) = Plus_Opr;
03611 break;
03612 case Cc_Tok_Op_Sub :
03613 IR_OPR(ir_idx) = Minus_Opr;
03614 }
03615 IR_LINE_NUM(ir_idx) = TOKEN_LINE(cc_token);
03616 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(cc_token);
03617
03618 COPY_OPND(IR_OPND_L(ir_idx), opnd);
03619
03620 parsed_ok = parse_cc_add_opnd(&opnd) && parsed_ok;
03621
03622 COPY_OPND(IR_OPND_R(ir_idx), opnd);
03623
03624 OPND_FLD(opnd) = IR_Tbl_Idx;
03625 OPND_IDX(opnd) = ir_idx;
03626 }
03627
03628 COPY_OPND((*result), opnd)
03629
03630 TRACE (Func_Exit, "parse_cc_level_2", NULL);
03631
03632 return(parsed_ok);
03633 }
03634
03635
03636
03637
03638
03639
03640
03641
03642
03643
03644
03645
03646
03647
03648
03649
03650
03651 static boolean parse_cc_level_3(opnd_type *result)
03652
03653 {
03654 int ir_idx = NULL_IDX;
03655 opnd_type opnd;
03656 boolean parsed_ok = TRUE;
03657
03658 TRACE (Func_Entry, "parse_cc_level_3", NULL);
03659
03660 parsed_ok = parse_cc_level_2(&opnd);
03661
03662 while (TOKEN_VALUE(cc_token) == Cc_Tok_Op_Lshift ||
03663 TOKEN_VALUE(cc_token) == Cc_Tok_Op_Rshift) {
03664
03665 NTR_IR_TBL(ir_idx);
03666 switch (TOKEN_VALUE(cc_token)) {
03667 case Cc_Tok_Op_Lshift :
03668 IR_OPR(ir_idx) = Shiftl_Opr;
03669 break;
03670 case Cc_Tok_Op_Rshift :
03671 IR_OPR(ir_idx) = Shiftr_Opr;
03672 }
03673 IR_LINE_NUM(ir_idx) = TOKEN_LINE(cc_token);
03674 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(cc_token);
03675
03676 COPY_OPND(IR_OPND_L(ir_idx), opnd);
03677
03678 parsed_ok = parse_cc_level_2(&opnd) && parsed_ok;
03679
03680 COPY_OPND(IR_OPND_R(ir_idx), opnd);
03681
03682 OPND_FLD(opnd) = IR_Tbl_Idx;
03683 OPND_IDX(opnd) = ir_idx;
03684 }
03685
03686 COPY_OPND((*result), opnd)
03687
03688 TRACE (Func_Exit, "parse_cc_level_3", NULL);
03689
03690 return(parsed_ok);
03691 }
03692
03693
03694
03695
03696
03697
03698
03699
03700
03701
03702
03703
03704
03705
03706
03707
03708
03709 static boolean parse_cc_level_4(opnd_type *result)
03710
03711 {
03712 int ir_idx;
03713 opnd_type opnd;
03714 boolean parsed_ok = TRUE;
03715
03716 TRACE (Func_Entry, "parse_cc_level_4", NULL);
03717
03718 parsed_ok = parse_cc_level_3(&opnd);
03719
03720 if (TOKEN_VALUE(cc_token) == Cc_Tok_Op_Ge ||
03721 TOKEN_VALUE(cc_token) == Cc_Tok_Op_Gt ||
03722 TOKEN_VALUE(cc_token) == Cc_Tok_Op_Le ||
03723 TOKEN_VALUE(cc_token) == Cc_Tok_Op_Lt) {
03724
03725 NTR_IR_TBL(ir_idx);
03726 switch (TOKEN_VALUE(cc_token)) {
03727 case Cc_Tok_Op_Ge :
03728 IR_OPR(ir_idx) = Ge_Opr;
03729 break;
03730 case Cc_Tok_Op_Gt :
03731 IR_OPR(ir_idx) = Gt_Opr;
03732 break;
03733 case Cc_Tok_Op_Le :
03734 IR_OPR(ir_idx) = Le_Opr;
03735 break;
03736 case Cc_Tok_Op_Lt :
03737 IR_OPR(ir_idx) = Lt_Opr;
03738 break;
03739 }
03740 IR_LINE_NUM(ir_idx) = TOKEN_LINE(cc_token);
03741 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(cc_token);
03742
03743 COPY_OPND(IR_OPND_L(ir_idx), opnd);
03744
03745 parsed_ok = parse_cc_level_3(&opnd) && parsed_ok;
03746
03747 COPY_OPND(IR_OPND_R(ir_idx), opnd);
03748
03749 OPND_FLD(opnd) = IR_Tbl_Idx;
03750 OPND_IDX(opnd) = ir_idx;
03751 }
03752
03753 COPY_OPND((*result), opnd)
03754
03755 TRACE (Func_Exit, "parse_cc_level_4", NULL);
03756
03757 return(parsed_ok);
03758 }
03759
03760
03761
03762
03763
03764
03765
03766
03767
03768
03769
03770
03771
03772
03773
03774
03775
03776 static boolean parse_cc_level_5(opnd_type *result)
03777
03778 {
03779 int ir_idx;
03780 opnd_type opnd;
03781 boolean parsed_ok = TRUE;
03782
03783 TRACE (Func_Entry, "parse_cc_level_5", NULL);
03784
03785 parsed_ok = parse_cc_level_4(&opnd);
03786
03787 if (TOKEN_VALUE(cc_token) == Cc_Tok_Op_Eq ||
03788 TOKEN_VALUE(cc_token) == Cc_Tok_Op_Ne) {
03789
03790 NTR_IR_TBL(ir_idx);
03791 switch (TOKEN_VALUE(cc_token)) {
03792 case Cc_Tok_Op_Eq :
03793 IR_OPR(ir_idx) = Eq_Opr;
03794 break;
03795 case Cc_Tok_Op_Ne :
03796 IR_OPR(ir_idx) = Ne_Opr;
03797 break;
03798 }
03799 IR_LINE_NUM(ir_idx) = TOKEN_LINE(cc_token);
03800 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(cc_token);
03801
03802 COPY_OPND(IR_OPND_L(ir_idx), opnd);
03803
03804 parsed_ok = parse_cc_level_4(&opnd) && parsed_ok;
03805
03806 COPY_OPND(IR_OPND_R(ir_idx), opnd);
03807
03808 OPND_FLD(opnd) = IR_Tbl_Idx;
03809 OPND_IDX(opnd) = ir_idx;
03810 }
03811
03812 COPY_OPND((*result), opnd)
03813
03814 TRACE (Func_Exit, "parse_cc_level_5", NULL);
03815
03816 return(parsed_ok);
03817 }
03818
03819
03820
03821
03822
03823
03824
03825
03826
03827
03828
03829
03830
03831
03832
03833
03834
03835 static boolean parse_cc_or_opnd(opnd_type *result)
03836
03837 {
03838 int ir_idx;
03839 opnd_type opnd;
03840 boolean parsed_ok = TRUE;
03841
03842 TRACE (Func_Entry, "parse_cc_or_opnd", NULL);
03843
03844 parsed_ok = parse_cc_level_5(&opnd);
03845
03846 while (TOKEN_VALUE(cc_token) == Cc_Tok_Op_Band) {
03847
03848 NTR_IR_TBL(ir_idx);
03849 IR_OPR(ir_idx) = Band_Opr;
03850 IR_LINE_NUM(ir_idx) = TOKEN_LINE(cc_token);
03851 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(cc_token);
03852
03853 COPY_OPND(IR_OPND_L(ir_idx), opnd)
03854
03855 parsed_ok = parse_cc_level_5(&opnd) && parsed_ok;
03856
03857 COPY_OPND(IR_OPND_R(ir_idx), opnd)
03858
03859 OPND_FLD(opnd) = IR_Tbl_Idx;
03860 OPND_IDX(opnd) = ir_idx;
03861 }
03862
03863 COPY_OPND((*result), opnd)
03864
03865 TRACE (Func_Exit, "parse_cc_or_opnd", NULL);
03866
03867 return(parsed_ok);
03868 }
03869
03870
03871
03872
03873
03874
03875
03876
03877
03878
03879
03880
03881
03882
03883
03884
03885
03886 static boolean parse_cc_level_6(opnd_type *result)
03887
03888 {
03889 int ir_idx;
03890 opnd_type opnd;
03891 boolean parsed_ok = TRUE;
03892
03893 TRACE (Func_Entry, "parse_cc_level_6", NULL);
03894
03895 parsed_ok = parse_cc_or_opnd(&opnd);
03896
03897 while (TOKEN_VALUE(cc_token) == Cc_Tok_Op_Neqv) {
03898
03899 NTR_IR_TBL(ir_idx);
03900 IR_OPR(ir_idx) = Neqv_Opr;
03901 IR_LINE_NUM(ir_idx) = TOKEN_LINE(cc_token);
03902 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(cc_token);
03903
03904 COPY_OPND(IR_OPND_L(ir_idx), opnd)
03905
03906 parsed_ok = parse_cc_equiv_opnd(&opnd) && parsed_ok;
03907
03908 COPY_OPND(IR_OPND_R(ir_idx), opnd)
03909
03910 OPND_FLD(opnd) = IR_Tbl_Idx;
03911 OPND_IDX(opnd) = ir_idx;
03912 }
03913
03914 COPY_OPND((*result), opnd)
03915
03916 TRACE (Func_Exit, "parse_cc_level_6", NULL);
03917
03918 return(parsed_ok);
03919 }
03920
03921
03922
03923
03924
03925
03926
03927
03928
03929
03930
03931
03932
03933
03934
03935
03936
03937 static boolean parse_cc_equiv_opnd(opnd_type *result)
03938
03939 {
03940 int ir_idx;
03941 opnd_type opnd;
03942 boolean parsed_ok = TRUE;
03943
03944 TRACE (Func_Entry, "parse_cc_equiv_opnd", NULL);
03945
03946 parsed_ok = parse_cc_level_6(&opnd);
03947
03948 while (TOKEN_VALUE(cc_token) == Cc_Tok_Op_Bor) {
03949
03950 NTR_IR_TBL(ir_idx);
03951 IR_OPR(ir_idx) = Bor_Opr;
03952 IR_LINE_NUM(ir_idx) = TOKEN_LINE(cc_token);
03953 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(cc_token);
03954
03955 COPY_OPND(IR_OPND_L(ir_idx), opnd)
03956
03957 parsed_ok = parse_cc_level_6(&opnd) && parsed_ok;
03958
03959 COPY_OPND(IR_OPND_R(ir_idx), opnd)
03960
03961 OPND_FLD(opnd) = IR_Tbl_Idx;
03962 OPND_IDX(opnd) = ir_idx;
03963 }
03964
03965 COPY_OPND((*result), opnd)
03966
03967 TRACE (Func_Exit, "parse_cc_equiv_opnd", NULL);
03968
03969 return(parsed_ok);
03970 }
03971
03972
03973
03974
03975
03976
03977
03978
03979
03980
03981
03982
03983
03984
03985
03986
03987
03988 static boolean parse_cc_level_7(opnd_type *result)
03989
03990 {
03991 int ir_idx;
03992 opnd_type opnd;
03993 boolean parsed_ok = TRUE;
03994
03995 TRACE (Func_Entry, "parse_cc_level_7", NULL);
03996
03997 parsed_ok = parse_cc_equiv_opnd(&opnd);
03998
03999 while (TOKEN_VALUE(cc_token) == Cc_Tok_Op_And) {
04000
04001 NTR_IR_TBL(ir_idx);
04002 IR_OPR(ir_idx) = And_Opr;
04003 IR_LINE_NUM(ir_idx) = TOKEN_LINE(cc_token);
04004 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(cc_token);
04005
04006 COPY_OPND(IR_OPND_L(ir_idx), opnd)
04007
04008 parsed_ok = parse_cc_equiv_opnd(&opnd) && parsed_ok;
04009
04010 COPY_OPND(IR_OPND_R(ir_idx), opnd)
04011
04012 OPND_FLD(opnd) = IR_Tbl_Idx;
04013 OPND_IDX(opnd) = ir_idx;
04014 }
04015
04016 COPY_OPND((*result), opnd)
04017
04018 TRACE (Func_Exit, "parse_cc_level_7", NULL);
04019
04020 return(parsed_ok);
04021 }
04022
04023
04024
04025
04026
04027
04028
04029
04030
04031
04032
04033
04034
04035
04036
04037
04038
04039 static boolean parse_cc_level_8(opnd_type *result)
04040
04041 {
04042 int ir_idx;
04043 opnd_type opnd;
04044 boolean parsed_ok = TRUE;
04045
04046 TRACE (Func_Entry, "parse_cc_level_8", NULL);
04047
04048 parsed_ok = parse_cc_level_7(&opnd);
04049
04050 while (TOKEN_VALUE(cc_token) == Cc_Tok_Op_Or) {
04051
04052 NTR_IR_TBL(ir_idx);
04053 IR_OPR(ir_idx) = Or_Opr;
04054 IR_LINE_NUM(ir_idx) = TOKEN_LINE(cc_token);
04055 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(cc_token);
04056
04057 COPY_OPND(IR_OPND_L(ir_idx), opnd)
04058
04059 parsed_ok = parse_cc_level_7(&opnd) && parsed_ok;
04060
04061 COPY_OPND(IR_OPND_R(ir_idx), opnd)
04062
04063 OPND_FLD(opnd) = IR_Tbl_Idx;
04064 OPND_IDX(opnd) = ir_idx;
04065 }
04066
04067 COPY_OPND((*result), opnd)
04068
04069 TRACE (Func_Exit, "parse_cc_level_8", NULL);
04070
04071 return(parsed_ok);
04072 }
04073
04074
04075
04076
04077
04078
04079
04080
04081
04082
04083
04084
04085
04086
04087
04088
04089 static boolean parse_cc_operand (opnd_type *the_opnd)
04090
04091 {
04092 int attr_idx;
04093 int col;
04094 int ir_idx;
04095 int line;
04096 int name_idx;
04097 int paren_cnt = 0;
04098 boolean parsed_ok = TRUE;
04099
04100
04101 TRACE (Func_Entry, "parse_cc_operand", NULL);
04102
04103 if (CC_LA_CH_VALUE == '(' ) {
04104
04105 line = CC_LA_CH_LINE;
04106 col = CC_LA_CH_COLUMN;
04107
04108 CC_NEXT_LA_CH;
04109
04110 if (!parse_cc_expr(the_opnd)) {
04111 parsed_ok = FALSE;
04112 }
04113 else if (CC_LA_CH_VALUE == ')') {
04114
04115 NTR_IR_TBL(ir_idx);
04116 IR_OPR(ir_idx) = Paren_Opr;
04117 COPY_OPND(IR_OPND_L(ir_idx), (*the_opnd));
04118 OPND_FLD((*the_opnd)) = IR_Tbl_Idx;
04119 OPND_IDX((*the_opnd)) = ir_idx;
04120 IR_LINE_NUM(ir_idx) = line;
04121 IR_COL_NUM(ir_idx) = col;
04122
04123 CC_NEXT_LA_CH;
04124 goto EXIT;
04125 }
04126 else {
04127
04128 ntr_next_msg_queue(CC_LA_CH_LINE, 1165, Error,
04129 CC_LA_CH_COLUMN,
04130 ")",
04131 0,
04132 STR_ARG);
04133 parsed_ok = FALSE;
04134 flush_cc_line();
04135 }
04136 goto EXIT;
04137 }
04138 else if (CC_LA_CH_CLASS == Ch_Class_Digit ||
04139 CC_LA_CH_CLASS == Ch_Class_Letter ||
04140 CC_LA_CH_VALUE == underscore) {
04141
04142 cc_get_token(TRUE);
04143
04144 OPND_LINE_NUM((*the_opnd)) = TOKEN_LINE(cc_token);
04145 OPND_COL_NUM((*the_opnd)) = TOKEN_COLUMN(cc_token);
04146 OPND_FLD((*the_opnd)) = CN_Tbl_Idx;
04147
04148 switch (TOKEN_VALUE(cc_token)) {
04149
04150 case Cc_Tok_Id :
04151 case Cc_Tok_Kwd_Define :
04152 case Cc_Tok_Kwd_Elif :
04153 case Cc_Tok_Kwd_Else :
04154 case Cc_Tok_Kwd_Endif :
04155 case Cc_Tok_Kwd_If :
04156 case Cc_Tok_Kwd_Ifdef :
04157 case Cc_Tok_Kwd_Ifndef :
04158 case Cc_Tok_Kwd_Include :
04159 case Cc_Tok_Kwd_Undef :
04160
04161
04162
04163
04164
04165 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
04166 TOKEN_LEN(cc_token),
04167 &name_idx);
04168
04169 if (attr_idx != NULL_IDX &&
04170 CC_AT_DEFINED(attr_idx)) {
04171
04172 PRINTMSG(TOKEN_LINE(cc_token), 626, Internal,
04173 TOKEN_COLUMN(cc_token),
04174 "defined macro to be replaced", "parse_cc_operand");
04175
04176 }
04177
04178 OPND_IDX((*the_opnd)) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 0);
04179 break;
04180
04181 case Cc_Tok_Constant :
04182
04183 OPND_IDX((*the_opnd)) = TOKEN_CONST_TBL_IDX(cc_token);
04184 break;
04185
04186 case Cc_Tok_Kwd_Defined :
04187
04188 while (CC_LA_CH_VALUE == '(') {
04189 paren_cnt++;
04190 CC_NEXT_LA_CH;
04191 }
04192
04193 cc_get_token(FALSE);
04194
04195 if (TOKEN_VALUE(cc_token) != Tok_Id) {
04196 ntr_next_msg_queue(TOKEN_LINE(cc_token), 1165, Error,
04197 TOKEN_COLUMN(cc_token),
04198 "IDENTIFIER",
04199 0,
04200 STR_ARG);
04201 parsed_ok = FALSE;
04202 flush_cc_line();
04203 }
04204 else {
04205
04206 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
04207 TOKEN_LEN(cc_token),
04208 &name_idx);
04209
04210
04211 if (attr_idx != NULL_IDX &&
04212 CC_AT_DEFINED(attr_idx)) {
04213
04214
04215 OPND_IDX((*the_opnd)) = CN_INTEGER_ONE_IDX;
04216 }
04217 else {
04218
04219 OPND_IDX((*the_opnd)) = CN_INTEGER_ZERO_IDX;
04220 }
04221 }
04222
04223 while (paren_cnt) {
04224 if (CC_LA_CH_VALUE != ')') {
04225 ntr_next_msg_queue(CC_LA_CH_LINE, 1165, Error,
04226 CC_LA_CH_COLUMN,
04227 ")",
04228 0,
04229 STR_ARG);
04230 parsed_ok = FALSE;
04231 flush_cc_line();
04232 break;
04233 }
04234 else {
04235 CC_NEXT_LA_CH;
04236 paren_cnt--;
04237 }
04238 }
04239
04240 break;
04241 }
04242 }
04243 else {
04244 ntr_next_msg_queue(CC_LA_CH_LINE, 1165, Error,
04245 CC_LA_CH_COLUMN,
04246 "identifier or integer constant",
04247 0,
04248 STR_ARG);
04249 parsed_ok = FALSE;
04250 flush_cc_line();
04251 }
04252
04253 EXIT:
04254 TRACE (Func_Exit, "parse_cc_operand", NULL);
04255
04256 return(parsed_ok);
04257
04258 }
04259
04260
04261
04262
04263
04264
04265
04266
04267
04268
04269
04270
04271
04272
04273
04274
04275
04276 static int srch_cc_sym_tbl (char *name_str,
04277 int name_len,
04278 int *name_idx)
04279
04280 {
04281 int idx;
04282 long tst_val;
04283
04284
04285 TRACE (Func_Entry, "srch_cc_sym_tbl", name_str);
04286
04287 tst_val = srch_name_tbl(name_str,
04288 name_len,
04289 &idx,
04290 cc_ln_tbl,
04291 str_pool,
04292 cc_ln_fw_idx,
04293 cc_ln_lw_idx);
04294
04295 *name_idx = idx;
04296
04297 if (tst_val != 0) {
04298 idx = NULL_IDX;
04299 TRACE (Func_Exit, "srch_cc_sym_tbl", NULL);
04300 }
04301 else {
04302 TRACE (Func_Exit, "srch_cc_sym_tbl",
04303 &str_pool[CC_LN_NAME_IDX(idx)].name_char);
04304 idx = CC_LN_ATTR_IDX(idx);
04305 }
04306 return (idx);
04307
04308 }
04309
04310
04311
04312
04313
04314
04315
04316
04317
04318
04319
04320
04321
04322
04323
04324
04325
04326
04327
04328
04329
04330
04331
04332
04333
04334 static int ntr_cc_sym_tbl(cc_token_type *token,
04335 int name_idx)
04336
04337 {
04338 register int attr_idx;
04339 register int i;
04340 register int np_idx;
04341
04342 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
04343 register long *name_tbl_base;
04344 # endif
04345
04346
04347 TRACE (Func_Entry, "ntr_cc_sym_tbl", TOKEN_STR(*token));
04348
04349 TBL_REALLOC_CK(cc_ln_tbl, 1);
04350
04351 NTR_CC_NAME_POOL((long *) TOKEN_STR(*token), TOKEN_LEN(*token), np_idx);
04352
04353
04354
04355 NTR_CC_ATTR_TBL(attr_idx);
04356 CC_AT_NAME_LEN(attr_idx) = TOKEN_LEN(*token);
04357 CC_AT_NAME_IDX(attr_idx) = np_idx;
04358
04359 cc_ln_lw_idx = cc_ln_tbl_idx;
04360
04361
04362
04363
04364 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
04365
04366 name_tbl_base = (long *) cc_ln_tbl;
04367
04368 for (i = cc_ln_tbl_idx; i >= name_idx; i--) {
04369 name_tbl_base [i] = name_tbl_base [i-1];
04370 }
04371 # else
04372
04373 for (i = cc_ln_tbl_idx; i >= name_idx; i--) {
04374 cc_ln_tbl [i] = cc_ln_tbl [i-1];
04375 }
04376 # endif
04377
04378 CLEAR_TBL_NTRY(cc_ln_tbl, name_idx);
04379 CC_LN_ATTR_IDX(name_idx) = attr_idx;
04380 CC_LN_NAME_IDX(name_idx) = np_idx;
04381 CC_LN_NAME_LEN(name_idx) = TOKEN_LEN(*token);
04382
04383 TRACE (Func_Exit, "ntr_cc_sym_tbl", TOKEN_STR(*token));
04384
04385 return (attr_idx);
04386
04387 }
04388
04389
04390
04391
04392
04393
04394
04395
04396
04397
04398
04399
04400
04401
04402
04403
04404
04405 static void flush_cc_line(void)
04406
04407 {
04408 int col;
04409 int line;
04410
04411 TRACE (Func_Entry, "flush_cc_line", NULL);
04412
04413 cc_stmt_buf_idx = cc_stmt_buf_len;
04414
04415 find_line_and_col(cc_stmt_buf_idx, &line, &col);
04416 CC_LA_CH_VALUE = eos;
04417 CC_LA_CH_LINE = line;
04418 CC_LA_CH_COLUMN = col;
04419 CC_LA_CH_CLASS = ch_class[CC_LA_CH_VALUE];
04420
04421 cc_get_token(FALSE);
04422
04423 TRACE (Func_Exit, "flush_cc_line", NULL);
04424
04425 return;
04426
04427 }
04428
04429
04430
04431
04432
04433
04434
04435
04436
04437
04438
04439
04440
04441
04442
04443
04444
04445 boolean enter_cmd_line_cc_define(char *str,
04446 char *value,
04447 boolean is_define)
04448
04449 {
04450 int attr_idx;
04451 int idx;
04452 int name_idx;
04453 boolean ok = TRUE;
04454 int tidx;
04455
04456 TRACE (Func_Entry, "enter_cmd_line_cc_define", NULL);
04457
04458 idx = 0;
04459 while (str[idx] == ' ' || str[idx] == '\t') {
04460 idx++;
04461 }
04462
04463 tidx = 0;
04464
04465 if (ch_class[str[idx]] == Ch_Class_Letter ||
04466 str[idx] == underscore) {
04467
04468 cc_token = cc_initial_token;
04469
04470 while (ch_class[str[idx]] == Ch_Class_Letter ||
04471 ch_class[str[idx]] == Ch_Class_Digit ||
04472 str[idx] == underscore ||
04473 str[idx] == dollar ||
04474 str[idx] == at_sign) {
04475
04476 (TOKEN_STR(cc_token))[tidx] = str[idx];
04477 tidx++;
04478 idx++;
04479 }
04480
04481 TOKEN_LEN(cc_token) = tidx;
04482
04483 attr_idx = srch_cc_sym_tbl(TOKEN_STR(cc_token),
04484 TOKEN_LEN(cc_token),
04485 &name_idx);
04486
04487 if (attr_idx == NULL_IDX) {
04488 attr_idx = ntr_cc_sym_tbl(&cc_token, name_idx);
04489 }
04490
04491 if (is_define) {
04492 CC_AT_DEFINED(attr_idx) = TRUE;
04493
04494 if (value != NULL) {
04495 strcpy(temp_id_str.string, value);
04496 CC_AT_STR_LEN(attr_idx) = strlen(temp_id_str.string);
04497 NTR_CC_NAME_POOL(temp_id_str.words, CC_AT_STR_LEN(attr_idx),
04498 CC_AT_STR_IDX(attr_idx));
04499 }
04500 else {
04501 PUT_VALUE_IN_AT_STR(attr_idx, 1);
04502 }
04503 }
04504 else {
04505 CC_AT_DEFINED(attr_idx) = FALSE;
04506 }
04507 }
04508 else {
04509 ok = FALSE;
04510 }
04511
04512
04513 TRACE (Func_Exit, "enter_cmd_line_cc_define", NULL);
04514
04515 return(ok);
04516
04517 }
04518
04519
04520
04521
04522
04523
04524
04525
04526
04527
04528
04529
04530
04531
04532
04533
04534
04535 static int fold_cc_expr(opnd_type *opnd)
04536
04537 {
04538 int l_value;
04539 int ir_idx;
04540 opnd_type loc_opnd;
04541 int r_value;
04542 long result;
04543
04544 TRACE (Func_Entry, "fold_cc_expr", NULL);
04545
04546 switch (OPND_FLD((*opnd))) {
04547 case CN_Tbl_Idx :
04548 result = (long) CN_INT_TO_C(OPND_IDX((*opnd)));
04549 break;
04550
04551 case IR_Tbl_Idx :
04552 ir_idx = OPND_IDX((*opnd));
04553
04554 COPY_OPND(loc_opnd, IR_OPND_L(ir_idx));
04555
04556 l_value = fold_cc_expr(&loc_opnd);
04557
04558 if (IR_FLD_R(ir_idx) != NO_Tbl_Idx) {
04559 COPY_OPND(loc_opnd, IR_OPND_R(ir_idx));
04560
04561 r_value = fold_cc_expr(&loc_opnd);
04562 }
04563
04564 switch (IR_OPR(ir_idx)) {
04565 case Uplus_Opr :
04566 result = l_value;
04567 break;
04568
04569 case Uminus_Opr :
04570 result = -l_value;
04571 break;
04572
04573 case Plus_Opr :
04574 result = l_value + r_value;
04575 break;
04576
04577 case Minus_Opr :
04578 result = l_value - r_value;
04579 break;
04580
04581 case Div_Opr :
04582 result = l_value / r_value;
04583 break;
04584
04585 case Mod_Opr :
04586 result = l_value % r_value;
04587 break;
04588
04589 case Mult_Opr :
04590 result = l_value * r_value;
04591 break;
04592
04593 case Not_Opr :
04594 result = (l_value != 0 ? 0 : 1);
04595 break;
04596
04597 case Bnot_Opr :
04598 result = ~l_value;
04599 break;
04600
04601 case Ne_Opr :
04602 result = (l_value != r_value ? 1 : 0);
04603 break;
04604
04605 case Eq_Opr :
04606 result = (l_value == r_value ? 1 : 0);
04607 break;
04608
04609 case Lt_Opr :
04610 result = (l_value < r_value ? 1 : 0);
04611 break;
04612
04613 case Le_Opr :
04614 result = (l_value <= r_value ? 1 : 0);
04615 break;
04616
04617 case Gt_Opr :
04618 result = (l_value > r_value ? 1 : 0);
04619 break;
04620
04621 case Ge_Opr :
04622 result = (l_value >= r_value ? 1 : 0);
04623 break;
04624
04625 case Neqv_Opr :
04626 result = l_value ^ r_value;
04627 break;
04628
04629 case And_Opr :
04630 result = (l_value && r_value ? 1 : 0);
04631 break;
04632
04633 case Band_Opr :
04634 result = l_value & r_value;
04635 break;
04636
04637 case Or_Opr :
04638 result = (l_value || r_value ? 1 : 0);
04639 break;
04640
04641 case Bor_Opr :
04642 result = l_value | r_value;
04643 break;
04644
04645 case Shiftl_Opr :
04646 result = l_value << r_value;
04647 break;
04648
04649 case Shiftr_Opr :
04650 result = l_value >> r_value;
04651 break;
04652
04653 case Paren_Opr :
04654 result = l_value;
04655 break;
04656
04657 default:
04658 PRINTMSG(IR_LINE_NUM(ir_idx), 1164, Internal,
04659 IR_COL_NUM(ir_idx), "parse_cc_line");
04660 break;
04661 }
04662 break;
04663
04664 default:
04665 PRINTMSG(OPND_LINE_NUM((*opnd)), 1164, Internal,
04666 OPND_COL_NUM((*opnd)), "parse_cc_line");
04667 break;
04668 }
04669
04670 TRACE (Func_Exit, "fold_cc_expr", NULL);
04671
04672 return(result);
04673
04674 }
04675
04676
04677
04678
04679
04680
04681
04682
04683
04684
04685
04686
04687
04688
04689
04690
04691
04692 static void find_line_and_col(int idx,
04693 int *line,
04694 int *col)
04695
04696 {
04697 int i = 1;
04698
04699 TRACE (Func_Entry,"find_line_and_col" , NULL);
04700
04701 if (cc_stmt_buf_num_lines == 1) {
04702 *line = cc_stmt_buf_line[1].line;
04703 *col = idx;
04704 }
04705 else {
04706 for (i = 2; i <= cc_stmt_buf_num_lines+1; i++) {
04707 if (cc_stmt_buf_line[i].start_idx >= idx) {
04708 *line = cc_stmt_buf_line[i-1].line;
04709 *col = idx - cc_stmt_buf_line[i-1].start_idx;
04710 break;
04711 }
04712 }
04713 # ifdef _DEBUG
04714 if (i > cc_stmt_buf_num_lines + 1) {
04715 PRINTMSG(PP_LINE_NUM, 626, Internal, 1,
04716 "valid line num", "find_line_and_col");
04717 }
04718 # endif
04719 }
04720
04721
04722 TRACE (Func_Exit, "find_line_and_col", NULL);
04723
04724 return;
04725
04726 }
04727
04728
04729
04730
04731
04732
04733
04734
04735
04736
04737
04738
04739
04740
04741
04742
04743
04744 static void shift_cc_stmt_buf(int start_idx,
04745 int shift)
04746
04747 {
04748 int i;
04749
04750 TRACE (Func_Entry, "shift_cc_stmt_buf", NULL);
04751
04752 if (shift > 0) {
04753 for (i = cc_stmt_buf_len+1; i >= start_idx; i--) {
04754 cc_stmt_buf[i+shift] = cc_stmt_buf[i];
04755 }
04756 }
04757 else if (shift < 0) {
04758 for (i = start_idx; i <= cc_stmt_buf_len+1; i++) {
04759 cc_stmt_buf[i+shift] = cc_stmt_buf[i];
04760 }
04761 }
04762
04763 for (i = 1; i <= cc_stmt_buf_num_lines + 1; i++) {
04764 if (cc_stmt_buf_line[i].start_idx >= start_idx) {
04765 cc_stmt_buf_line[i].start_idx += shift;
04766 }
04767 }
04768
04769 cc_stmt_buf_len += shift;
04770
04771 TRACE (Func_Exit, "shift_cc_stmt_buf", NULL);
04772
04773 return;
04774
04775 }
04776
04777
04778
04779
04780
04781
04782
04783
04784
04785
04786
04787
04788
04789
04790
04791
04792
04793 static void shift_nxt_line(int start_idx,
04794 int shift)
04795
04796 {
04797 int end_line;
04798 int i;
04799 int curr_line = NULL_IDX;
04800
04801 TRACE (Func_Entry, "shift_nxt_line", NULL);
04802
04803 for (i = 1; i <= nxt_line_num_lines; i++) {
04804 if (start_idx >= nxt_line_start_idx[i] &&
04805 start_idx <= nxt_line_end_idx[i]) {
04806 curr_line = i;
04807 break;
04808 }
04809 }
04810
04811 # ifdef _DEBUG
04812 if (start_idx == NULL_IDX) {
04813 PRINTMSG(pp_nxt_line_num[1], 626, Internal, 1,
04814 "valid start_idx", "shift_nxt_line");
04815 }
04816 # endif
04817
04818 if (extra_nxt_line) {
04819 end_line = extra_nxt_line;
04820 }
04821 else {
04822 end_line = nxt_line_num_lines;
04823 }
04824
04825 if (nxt_line_end_idx[end_line]+shift >= MAX_STMT_CHAR_SIZE) {
04826 PRINTMSG(pp_nxt_line_num[end_line], 1593, Limit, 0);
04827 }
04828
04829 if (shift > 0) {
04830 for (i = nxt_line_end_idx[end_line]; i >= start_idx; i--) {
04831 nxt_line[i+shift] = nxt_line[i];
04832 nxt_line_col[i+shift] = nxt_line_col[i];
04833 }
04834 }
04835 else if (shift < 0) {
04836 for (i = start_idx; i <= nxt_line_end_idx[end_line]; i++) {
04837 nxt_line[i+shift] = nxt_line[i];
04838 nxt_line_col[i+shift] = nxt_line_col[i];
04839 }
04840 }
04841
04842 nxt_line_end_idx[curr_line] += shift;
04843 pp_nxt_line_length[curr_line] += shift;
04844 pp_nxt_line_EOL[curr_line] += shift;
04845 pp_orig_line_size[curr_line] += shift;
04846
04847 for (i = curr_line + 1; i <= end_line; i++) {
04848 nxt_line_start_idx[i] += shift;
04849 nxt_line_end_idx[i] += shift;
04850 pp_nxt_line_EOL[i] += shift;
04851 }
04852
04853 TRACE (Func_Exit, "shift_nxt_line", NULL);
04854
04855 return;
04856
04857 }
04858
04859
04860
04861
04862
04863
04864
04865
04866
04867
04868
04869
04870
04871
04872
04873
04874
04875 static int expanded_macro_len(int attr_idx,
04876 cc_arg_type *arg_head)
04877
04878 {
04879 int arg_num;
04880 cc_arg_type *arg_tail;
04881 int i;
04882 int len;
04883
04884 TRACE (Func_Entry, "expanded_macro_len", NULL);
04885
04886 len = CC_AT_STR_LEN(attr_idx);
04887
04888 for (i = 0; i < CC_AT_STR_LEN(attr_idx); i++) {
04889 if ((CC_AT_STR_PTR(attr_idx))[i] == '\001') {
04890 i += 2;
04891 arg_num = 1;
04892 arg_tail = arg_head;
04893 while (arg_num != (CC_AT_STR_PTR(attr_idx))[i]) {
04894 arg_tail = arg_tail->next;
04895 arg_num++;
04896 }
04897
04898 len += (arg_tail->name_len - 3);
04899 }
04900 }
04901
04902 TRACE (Func_Exit, "expanded_macro_len", NULL);
04903
04904 return(len);
04905
04906 }
04907
04908
04909
04910
04911
04912
04913
04914
04915
04916
04917
04918
04919
04920
04921
04922
04923
04924 static void insert_macro(int attr_idx,
04925 cc_arg_type *arg_head,
04926 int id_start_idx,
04927 int col,
04928 int save_pp_line_idx)
04929
04930 {
04931 int arg_num;
04932 cc_arg_type *arg_tail;
04933 char *char_ptr;
04934 int i;
04935 int j;
04936 int k;
04937 int len;
04938 int end_idx;
04939
04940 TRACE (Func_Entry, "insert_macro", NULL);
04941
04942
04943
04944
04945 end_idx = cc_stmt_buf_idx + 1;
04946
04947 adjust_continued_macro(id_start_idx, &end_idx);
04948
04949 len = expanded_macro_len(attr_idx, arg_head);
04950
04951 shift_nxt_line(end_idx,
04952 len-(end_idx - id_start_idx));
04953
04954 char_ptr = CC_AT_STR_PTR(attr_idx);
04955
04956 j = 0;
04957 i = 0;
04958 while (i < len) {
04959 if (char_ptr[j] == '\001') {
04960 j += 2;
04961 arg_num = 1;
04962 arg_tail = arg_head;
04963 while (arg_num != char_ptr[j]) {
04964 arg_tail = arg_tail->next;
04965 arg_num++;
04966 }
04967
04968 for (k = 0; k < arg_tail->name_len; k++) {
04969 nxt_line[i+id_start_idx] = arg_tail->name[k];
04970 nxt_line_col[i+id_start_idx] = col;
04971 i++;
04972 }
04973 }
04974 else {
04975 nxt_line[i+id_start_idx] = char_ptr[j];
04976 nxt_line_col[i+id_start_idx] = col;
04977 i++;
04978 }
04979
04980 j++;
04981 }
04982
04983 cc_stmt_buf_idx = id_start_idx + len - 1;
04984 pp_line_idx = save_pp_line_idx;
04985 cc_advance_idx();
04986
04987
04988 TRACE (Func_Exit, "insert_macro", NULL);
04989
04990 return;
04991
04992 }
04993
04994
04995
04996
04997
04998
04999
05000
05001
05002
05003
05004
05005
05006
05007
05008
05009
05010 static void adjust_continued_macro(int start_idx,
05011 int *end_idx)
05012
05013 {
05014 int start_line = NULL_IDX;
05015 int end_line = NULL_IDX;
05016 int i;
05017 boolean keep_end_line = FALSE;
05018
05019 TRACE (Func_Entry, "adjust_continued_macro", NULL);
05020
05021 for (i = 1; i <= nxt_line_num_lines; i++) {
05022 if (start_idx >= nxt_line_start_idx[i] &&
05023 start_idx <= nxt_line_end_idx[i]) {
05024
05025 start_line = i;
05026 }
05027
05028 if (*end_idx >= nxt_line_start_idx[i] &&
05029 *end_idx <= nxt_line_end_idx[i]) {
05030
05031 end_line = i;
05032 }
05033
05034 if (start_line != NULL_IDX && end_line != NULL_IDX) {
05035 break;
05036 }
05037 }
05038
05039 if (end_line > start_line) {
05040
05041
05042 for (i = *end_idx; i < pp_nxt_line_EOL[end_line]; i++) {
05043 if (nxt_line[i] != blank &&
05044 nxt_line[i] != tab) {
05045 keep_end_line = TRUE;
05046 break;
05047 }
05048 }
05049
05050 if (keep_end_line) {
05051
05052
05053 for (i = pp_nxt_line_idx[end_line]+1; i < *end_idx; i++) {
05054 nxt_line[i] = blank;
05055 }
05056
05057
05058
05059 end_line--;
05060 }
05061
05062 *end_idx = pp_nxt_line_EOL[end_line];
05063
05064
05065
05066 if (end_line > start_line) {
05067 pp_orig_line_size[start_line] += nxt_line_end_idx[end_line] -
05068 nxt_line_end_idx[start_line];
05069 nxt_line_end_idx[start_line] = nxt_line_end_idx[end_line];
05070 pp_nxt_line_EOL[start_line] = pp_nxt_line_EOL[end_line];
05071 pp_nxt_line_length[start_line] = nxt_line_end_idx[start_line] -
05072 nxt_line_start_idx[start_line];
05073
05074 for (i = end_line + 1;
05075 i <= (extra_nxt_line ? extra_nxt_line : end_stmt_line_idx);
05076 i++) {
05077 nxt_line_start_idx[i-(end_line-start_line)] = nxt_line_start_idx[i];
05078 nxt_line_end_idx[i-(end_line-start_line)] = nxt_line_end_idx[i];
05079 pp_orig_line_size[i-(end_line-start_line)] = pp_orig_line_size[i];
05080 pp_nxt_line_EOL[i-(end_line-start_line)] = pp_nxt_line_EOL[i];
05081 pp_nxt_line_length[i-(end_line-start_line)] = pp_nxt_line_length[i];
05082 pp_nxt_line_idx[i-(end_line-start_line)] = pp_nxt_line_idx[i];
05083 pp_nxt_line_type[i-(end_line-start_line)] = pp_nxt_line_type[i];
05084 pp_nxt_line_num[i-(end_line-start_line)] = pp_nxt_line_num[i];
05085 pp_change_source_form[i-(end_line-start_line)] =
05086 pp_change_source_form[i];
05087 pp_expected_line[i-(end_line-start_line)] =
05088 pp_expected_line[i];
05089 }
05090
05091 nxt_line_num_lines -= (end_line - start_line);
05092 end_stmt_line_idx -= (end_line - start_line);
05093
05094 if (extra_nxt_line != NULL_IDX) {
05095 extra_nxt_line -= (end_line - start_line);
05096 }
05097 }
05098 }
05099
05100 TRACE (Func_Exit, "adjust_continued_macro", NULL);
05101
05102 return;
05103
05104 }
05105
05106
05107
05108
05109
05110
05111
05112
05113
05114
05115
05116
05117
05118
05119
05120
05121
05122 static char *get_dynamic_predef_str(int attr_idx,
05123 int line)
05124
05125 {
05126 time_t clock;
05127 int file_line;
05128 int g_idx;
05129 struct tm *tmptr;
05130
05131 static char str[MAX_PATH_NAME_SIZE + 1];
05132
05133 TRACE (Func_Entry, "get_dynamic_predef_str", NULL);
05134
05135 str[0] = '\0';
05136
05137 if (attr_idx == line_macro_idx || attr_idx == LINE_macro_idx) {
05138 GLOBAL_LINE_TO_FILE_LINE(line, g_idx, file_line);
05139 sprintf(str, "%d", file_line);
05140 }
05141 else if (attr_idx == file_macro_idx || attr_idx == FILE_macro_idx) {
05142 get_curr_file_name(str);
05143 }
05144 else if (attr_idx == date_macro_idx || attr_idx == DATE_macro_idx) {
05145 clock = time(NULL);
05146 tmptr = localtime(&clock);
05147 sprintf(str, "\"%02d/%02d/%02d\"",
05148 tmptr->tm_mon+1, tmptr->tm_mday,
05149 (tmptr->tm_year % 100));
05150
05151 }
05152 else if (attr_idx == time_macro_idx || attr_idx == TIME_macro_idx) {
05153 clock = time(NULL);
05154 tmptr = localtime(&clock);
05155 sprintf(str, "\"%02d:%02d:%02d\"",
05156 tmptr->tm_hour, tmptr->tm_min, tmptr->tm_sec);
05157 }
05158
05159 TRACE (Func_Exit, "get_dynamic_predef_str", NULL);
05160
05161 return(str);
05162
05163 }