Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 00037 static char USMID[] = "\n@(#)5.0_pl/sources/p_asg_expr.c 5.3 06/17/99 09:28:10\n"; 00038 00039 # include "defines.h" /* Machine dependent ifdefs */ 00040 00041 # include "host.m" /* Host machine dependent macros.*/ 00042 # include "host.h" /* Host machine dependent header.*/ 00043 # include "target.m" /* Target machine dependent macros.*/ 00044 # include "target.h" /* Target machine dependent header.*/ 00045 00046 # include "globals.m" 00047 # include "tokens.m" 00048 # include "sytb.m" 00049 # include "p_globals.m" 00050 # include "debug.m" 00051 00052 # include "globals.h" 00053 # include "tokens.h" 00054 # include "sytb.h" 00055 # include "p_globals.h" 00056 00057 00058 /*****************************************************************\ 00059 |* function prototypes of static functions declared in this file *| 00060 \*****************************************************************/ 00061 00062 boolean parse_level_1 (opnd_type *); 00063 boolean parse_mult_opnd (opnd_type *); 00064 boolean parse_add_opnd (opnd_type *); 00065 boolean parse_level_2 (opnd_type *); 00066 boolean parse_level_3 (opnd_type *); 00067 boolean parse_level_4 (opnd_type *); 00068 boolean parse_and_opnd (opnd_type *); 00069 boolean parse_or_opnd (opnd_type *); 00070 boolean parse_equiv_opnd (opnd_type *); 00071 boolean parse_level_5 (opnd_type *); 00072 boolean parse_lhs (opnd_type *, int); 00073 00074 00075 /******************************************************************************\ 00076 |* *| 00077 |* Description: *| 00078 |* BRIEF DESCRIPTION OF THIS FUNCTION'S PURPOSE *| 00079 |* *| 00080 |* Input parameters: *| 00081 |* NONE *| 00082 |* *| 00083 |* Output parameters: *| 00084 |* NONE *| 00085 |* *| 00086 |* Returns: *| 00087 |* NONE *| 00088 |* *| 00089 \******************************************************************************/ 00090 00091 void parse_assignment_stmt (void) 00092 00093 { 00094 int attr_idx; 00095 int buf_idx; 00096 int col; 00097 int host_attr_idx; 00098 int host_name_idx; 00099 int ir_idx; 00100 int line; 00101 int name_idx; 00102 opnd_type opnd = INIT_OPND_TYPE; 00103 stmt_category_type save_curr_stmt_category; 00104 char str[2]; 00105 int stmt_num; 00106 00107 00108 TRACE (Func_Entry, "parse_assignment_stmt", NULL); 00109 00110 00111 attr_idx = srch_sym_tbl (TOKEN_STR(token), TOKEN_LEN(token), &name_idx); 00112 00113 if (attr_idx == NULL_IDX) { /* search host sym tab */ 00114 host_attr_idx = srch_host_sym_tbl(TOKEN_STR(token), 00115 TOKEN_LEN(token), 00116 &host_name_idx, 00117 FALSE); 00118 00119 if (host_attr_idx != NULL_IDX && IS_STMT_ENTITY(host_attr_idx)) { 00120 00121 /* do not hook up to host stmt entities */ 00122 host_attr_idx = NULL_IDX; 00123 } 00124 00125 if (host_attr_idx != NULL_IDX) { 00126 00127 /* Make entry in local name table for this item. Make a new attr */ 00128 /* and attr_link them together. */ 00129 00130 attr_idx = ntr_host_in_sym_tbl(&token, name_idx, host_attr_idx, 00131 host_name_idx, TRUE); 00132 } 00133 else { /* enter attr in local symbol table */ 00134 attr_idx = ntr_sym_tbl(&token, name_idx); 00135 SET_IMPL_TYPE(attr_idx); 00136 } 00137 } 00138 00139 if (AT_OBJ_CLASS(attr_idx) == Data_Obj) { 00140 ATD_SEEN_OUTSIDE_IMP_DO(attr_idx) = TRUE; 00141 } 00142 00143 if (curr_stmt_category < Executable_Stmt_Cat && 00144 LA_CH_VALUE == LPAREN && 00145 AT_ATTR_LINK(attr_idx) == NULL_IDX && 00146 AT_OBJ_CLASS(attr_idx) == Data_Obj && 00147 ATD_ARRAY_IDX(attr_idx) == NULL_IDX && 00148 (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != Character || 00149 ! is_substring_ref())) { 00150 00151 parse_stmt_func_stmt(attr_idx, name_idx); 00152 goto EXIT; 00153 } 00154 00155 /* The WHERE block is marked as not allowing executables, because the only */ 00156 /* statement allowed in a WHERE block is the assignment statement. So if */ 00157 /* CURR_BLK_NO_EXEC is set, have to check that this isn't a WHERE block. */ 00158 00159 00160 /* Likewise, the FORALL block is marked as not allowing executables, */ 00161 /* because the only statements allowed in a FORALL construct are: */ 00162 /* * assignment statement (including pointer assignment statement) */ 00163 /* * WHERE statement or WHERE construct */ 00164 /* * another FORALL construct or FORALL statement */ 00165 /* So if CURR_BLK_NO_EXEC is set, also have to check that this isn't a */ 00166 /* FORALL block. */ 00167 00168 if (CURR_BLK_NO_EXEC && 00169 CURR_BLK != Where_Else_Blk && 00170 CURR_BLK != Where_Then_Blk && 00171 CURR_BLK != Where_Else_Mask_Blk && 00172 CURR_BLK != Forall_Blk) { 00173 00174 if (iss_blk_stk_err()) { 00175 parse_err_flush(Find_EOS, NULL); 00176 goto EXIT; 00177 } 00178 } 00179 00180 save_curr_stmt_category = curr_stmt_category; 00181 curr_stmt_category = Executable_Stmt_Cat; 00182 NTR_IR_TBL(ir_idx); 00183 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx; 00184 00185 if (!parse_lhs(&opnd, attr_idx)) { 00186 parse_err_flush(Find_EOS, NULL); 00187 goto EXIT; 00188 } 00189 00190 COPY_OPND(IR_OPND_L(ir_idx), opnd); 00191 00192 IR_LINE_NUM(ir_idx) = LA_CH_LINE; 00193 IR_COL_NUM(ir_idx) = LA_CH_COLUMN; 00194 00195 line = LA_CH_LINE; 00196 col = LA_CH_COLUMN; 00197 buf_idx = LA_CH_BUF_IDX; 00198 stmt_num = LA_CH_STMT_NUM; 00199 00200 if (LA_CH_VALUE == EOS) { 00201 PRINTMSG(line, 724, Error, col, EOS_STR); 00202 curr_stmt_category = save_curr_stmt_category; 00203 } 00204 else if (MATCHED_TOKEN_CLASS(Tok_Class_Punct) && 00205 (TOKEN_VALUE(token) == Tok_Punct_Eq || 00206 TOKEN_VALUE(token) == Tok_Punct_Rename)) { 00207 IR_OPR(ir_idx) = (TOKEN_VALUE(token) == Tok_Punct_Eq) ? Asg_Opr : 00208 Ptr_Asg_Opr; 00209 parse_expr(&opnd); 00210 COPY_OPND(IR_OPND_R(ir_idx), opnd); 00211 } 00212 else { 00213 reset_lex(buf_idx, stmt_num); 00214 str[0] = LA_CH_VALUE; 00215 str[1] = '\0'; 00216 PRINTMSG(line, 724, Error, col, str); 00217 parse_err_flush(Find_EOS, NULL); 00218 curr_stmt_category = save_curr_stmt_category; 00219 } 00220 00221 if (LA_CH_VALUE != EOS) { 00222 parse_err_flush(Find_EOS, "operator or " EOS_STR); 00223 } 00224 00225 EXIT: 00226 00227 NEXT_LA_CH; 00228 00229 TRACE (Func_Exit, "parse_assignment_stmt", NULL); 00230 00231 return; 00232 00233 } /* parse_assignment_stmt */ 00234 00235 00236 /******************************************************************************\ 00237 |* *| 00238 |* Description: *| 00239 |* BNF level-5-expr { defined-binary-op level-5-expr } *| 00240 |* *| 00241 |* Input parameters: *| 00242 |* NONE *| 00243 |* *| 00244 |* Output parameters: *| 00245 |* NONE *| 00246 |* *| 00247 |* Returns: *| 00248 |* *| 00249 \******************************************************************************/ 00250 00251 boolean parse_expr (opnd_type *result) 00252 00253 { 00254 int attr_idx; 00255 int host_attr_idx; 00256 int host_name_idx; 00257 int ir_idx; 00258 int list1_idx; 00259 int list2_idx; 00260 int name_idx; 00261 opnd_type opnd = INIT_OPND_TYPE; 00262 boolean parsed_ok = TRUE; 00263 00264 TRACE (Func_Entry, "parse_expr", NULL); 00265 00266 00267 parsed_ok = parse_level_5(&opnd); 00268 00269 while (TOKEN_VALUE(token) == Tok_Op_Defined) { 00270 00271 NTR_IR_TBL(ir_idx); 00272 IR_OPR(ir_idx) = Defined_Bin_Opr; 00273 00274 attr_idx = srch_sym_tbl (TOKEN_STR(token), TOKEN_LEN(token), &name_idx); 00275 host_attr_idx = attr_idx; 00276 00277 if (attr_idx == NULL_IDX) { 00278 host_attr_idx = srch_host_sym_tbl(TOKEN_STR(token), 00279 TOKEN_LEN(token), 00280 &host_name_idx, 00281 TRUE); 00282 00283 if (host_attr_idx) { 00284 attr_idx = ntr_host_in_sym_tbl(&token, 00285 name_idx, 00286 host_attr_idx, 00287 host_name_idx, 00288 TRUE); 00289 00290 attr_idx = host_attr_idx; 00291 } 00292 } 00293 else if (AT_ATTR_LINK(attr_idx)) { 00294 host_attr_idx = AT_ATTR_LINK(attr_idx); 00295 while (AT_ATTR_LINK(host_attr_idx)) { 00296 host_attr_idx = AT_ATTR_LINK(attr_idx); 00297 } 00298 } 00299 00300 if (attr_idx == NULL_IDX || AT_OBJ_CLASS(host_attr_idx) != Interface) { 00301 00302 /* error .. no defined opr */ 00303 00304 PRINTMSG(TOKEN_LINE(token), 318, Error, TOKEN_COLUMN(token), 00305 TOKEN_STR(token)); 00306 parsed_ok = FALSE; 00307 } 00308 else if (AT_NOT_VISIBLE(host_attr_idx)) { 00309 PRINTMSG(TOKEN_LINE(token), 486, Error, 00310 TOKEN_COLUMN(token), 00311 AT_OBJ_NAME_PTR(host_attr_idx), 00312 AT_OBJ_NAME_PTR(AT_MODULE_IDX((host_attr_idx)))); 00313 parsed_ok = FALSE; 00314 } 00315 00316 IR_FLD_L(ir_idx) = AT_Tbl_Idx; 00317 IR_IDX_L(ir_idx) = attr_idx; 00318 00319 IR_LINE_NUM_L(ir_idx) = TOKEN_LINE(token); 00320 IR_COL_NUM_L(ir_idx) = TOKEN_COLUMN(token); 00321 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 00322 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 00323 00324 00325 NTR_IR_LIST_TBL(list1_idx); 00326 NTR_IR_LIST_TBL(list2_idx); 00327 IR_FLD_R(ir_idx) = IL_Tbl_Idx; 00328 IR_LIST_CNT_R(ir_idx) = 2; 00329 IR_IDX_R(ir_idx) = list1_idx; 00330 IL_NEXT_LIST_IDX(list1_idx) = list2_idx; 00331 IL_PREV_LIST_IDX(list2_idx) = list1_idx; 00332 00333 COPY_OPND(IL_OPND(list1_idx), opnd); 00334 00335 parsed_ok = parse_level_5(&opnd) && parsed_ok; 00336 00337 COPY_OPND(IL_OPND(list2_idx), opnd); 00338 00339 OPND_FLD(opnd) = IR_Tbl_Idx; 00340 OPND_IDX(opnd) = ir_idx; 00341 } 00342 00343 COPY_OPND((*result), opnd) 00344 00345 TRACE (Func_Exit, "parse_expr", NULL); 00346 00347 return(parsed_ok); 00348 } /* parse_expr */ 00349 00350 /******************************************************************************\ 00351 |* *| 00352 |* Description: *| 00353 |* BNF [defined_unary_op] primary *| 00354 |* *| 00355 |* Input parameters: *| 00356 |* NONE *| 00357 |* *| 00358 |* Output parameters: *| 00359 |* NONE *| 00360 |* *| 00361 |* Returns: *| 00362 |* NOTHING *| 00363 |* *| 00364 \******************************************************************************/ 00365 00366 boolean parse_level_1(opnd_type *result) 00367 00368 { 00369 int attr_idx; 00370 int def_idx = NULL_IDX; 00371 int host_attr_idx; 00372 int host_name_idx; 00373 int name_idx; 00374 opnd_type opnd = INIT_OPND_TYPE; 00375 boolean parsed_ok = TRUE; 00376 00377 TRACE (Func_Entry, "parse_level_1", NULL); 00378 00379 if (LA_CH_VALUE == DOT && matched_specific_token(Tok_Op_Defined, 00380 Tok_Class_Op)) { 00381 /* have defined_unary_op */ 00382 00383 NTR_IR_TBL(def_idx); 00384 IR_OPR(def_idx) = Defined_Un_Opr; 00385 attr_idx = srch_sym_tbl (TOKEN_STR(token), TOKEN_LEN(token), &name_idx); 00386 host_attr_idx = attr_idx; 00387 00388 if (attr_idx == NULL_IDX) { 00389 host_attr_idx = srch_host_sym_tbl(TOKEN_STR(token), 00390 TOKEN_LEN(token), 00391 &host_name_idx, 00392 TRUE); 00393 00394 if (host_attr_idx) { 00395 attr_idx = ntr_host_in_sym_tbl(&token, 00396 name_idx, 00397 host_attr_idx, 00398 host_name_idx, 00399 TRUE); 00400 00401 attr_idx = host_attr_idx; 00402 } 00403 } 00404 else if (AT_ATTR_LINK(attr_idx)) { 00405 host_attr_idx = AT_ATTR_LINK(attr_idx); 00406 while (AT_ATTR_LINK(host_attr_idx)) { 00407 host_attr_idx = AT_ATTR_LINK(attr_idx); 00408 } 00409 } 00410 00411 if (attr_idx == NULL_IDX || AT_OBJ_CLASS(host_attr_idx) != Interface) { 00412 00413 /* error .. no defined opr */ 00414 00415 PRINTMSG(TOKEN_LINE(token), 318, Error, TOKEN_COLUMN(token), 00416 TOKEN_STR(token)); 00417 parsed_ok = FALSE; 00418 } 00419 else if (AT_NOT_VISIBLE(host_attr_idx)) { 00420 PRINTMSG(TOKEN_LINE(token), 486, Error, 00421 TOKEN_COLUMN(token), 00422 AT_OBJ_NAME_PTR(host_attr_idx), 00423 AT_OBJ_NAME_PTR(AT_MODULE_IDX((host_attr_idx)))); 00424 parsed_ok = FALSE; 00425 } 00426 else { 00427 00428 IR_FLD_L(def_idx) = AT_Tbl_Idx; 00429 IR_IDX_L(def_idx) = attr_idx; 00430 00431 IR_LINE_NUM_L(def_idx) = TOKEN_LINE(token); 00432 IR_COL_NUM_L(def_idx) = TOKEN_COLUMN(token); 00433 IR_LINE_NUM(def_idx) = TOKEN_LINE(token); 00434 IR_COL_NUM(def_idx) = TOKEN_COLUMN(token); 00435 } 00436 } 00437 00438 parsed_ok = parse_operand(&opnd) && parsed_ok; 00439 00440 if (def_idx) { 00441 COPY_OPND(IR_OPND_R(def_idx), opnd) 00442 OPND_FLD((*result)) = IR_Tbl_Idx; 00443 OPND_IDX((*result)) = def_idx; 00444 } 00445 else { 00446 COPY_OPND((*result), opnd) 00447 } 00448 TRACE (Func_Exit, "parse_level_1", NULL); 00449 00450 return(parsed_ok); 00451 } /* parse_level_1 */ 00452 00453 /******************************************************************************\ 00454 |* *| 00455 |* Description: *| 00456 |* BNF level-1-expr [** mult_opnd] *| 00457 |* *| 00458 |* Input parameters: *| 00459 |* NONE *| 00460 |* *| 00461 |* Output parameters: *| 00462 |* NONE *| 00463 |* *| 00464 |* Returns: *| 00465 |* NOTHING *| 00466 |* *| 00467 \******************************************************************************/ 00468 00469 boolean parse_mult_opnd(opnd_type *result) 00470 00471 { 00472 int ir_idx; 00473 opnd_type opnd = INIT_OPND_TYPE; 00474 boolean parsed_ok = TRUE; 00475 00476 00477 TRACE (Func_Entry, "parse_mult_opnd", NULL); 00478 00479 parsed_ok = parse_level_1(&opnd); 00480 00481 if (MATCHED_TOKEN_CLASS(Tok_Class_Op)) { 00482 00483 if (TOKEN_VALUE(token) == Tok_Op_Power) { 00484 00485 NTR_IR_TBL(ir_idx); 00486 IR_OPR(ir_idx) = Power_Opr; 00487 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 00488 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 00489 00490 COPY_OPND(IR_OPND_L(ir_idx), opnd) 00491 00492 parsed_ok = parse_mult_opnd(&opnd) && parsed_ok; 00493 00494 COPY_OPND(IR_OPND_R(ir_idx), opnd) 00495 00496 OPND_FLD((*result)) = IR_Tbl_Idx; 00497 OPND_IDX((*result)) = ir_idx; 00498 } 00499 else if (TOKEN_VALUE(token) == Tok_Const_True || 00500 TOKEN_VALUE(token) == Tok_Const_False) { 00501 00502 PRINTMSG(TOKEN_LINE(token), 197, Error, TOKEN_COLUMN(token), 00503 "operator", "logical literal constant"); 00504 parse_err_flush(Find_Expr_End, NULL); 00505 parsed_ok = FALSE; 00506 } 00507 else if (TOKEN_VALUE(token) == Tok_Op_Assign || 00508 TOKEN_VALUE(token) == Tok_Op_Deref || 00509 TOKEN_VALUE(token) == Tok_Op_Ptr_Assign || 00510 TOKEN_VALUE(token) == Tok_Op_Not) { 00511 00512 reset_lex(TOKEN_BUF_IDX(token), TOKEN_STMT_NUM(token)); 00513 COPY_OPND((*result),opnd); 00514 } 00515 else { 00516 COPY_OPND((*result),opnd); 00517 } 00518 } 00519 else { 00520 COPY_OPND((*result),opnd); 00521 } 00522 00523 TRACE (Func_Exit, "parse_mult_opnd", NULL); 00524 00525 return(parsed_ok); 00526 } /* parse_mult_opnd */ 00527 00528 /******************************************************************************\ 00529 |* *| 00530 |* Description: *| 00531 |* BNF mult_opnd {mult-op mult_opnd} *| 00532 |* *| 00533 |* Input parameters: *| 00534 |* NONE *| 00535 |* *| 00536 |* Output parameters: *| 00537 |* NONE *| 00538 |* *| 00539 |* Returns: *| 00540 |* NOTHING *| 00541 |* *| 00542 \******************************************************************************/ 00543 00544 boolean parse_add_opnd(opnd_type *result) 00545 00546 { 00547 int ir_idx; 00548 opnd_type opnd = INIT_OPND_TYPE; 00549 boolean parsed_ok = TRUE; 00550 00551 TRACE (Func_Entry, "parse_add_opnd", NULL); 00552 00553 parsed_ok = parse_mult_opnd(&opnd); 00554 00555 while (TOKEN_VALUE(token) == Tok_Op_Mult || 00556 TOKEN_VALUE(token) == Tok_Op_Div) { 00557 00558 NTR_IR_TBL(ir_idx); 00559 switch (TOKEN_VALUE(token)) { 00560 case Tok_Op_Mult : 00561 IR_OPR(ir_idx) = Mult_Opr; 00562 break; 00563 case Tok_Op_Div : 00564 IR_OPR(ir_idx) = Div_Opr; 00565 } 00566 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 00567 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 00568 00569 COPY_OPND(IR_OPND_L(ir_idx), opnd); 00570 00571 parsed_ok = parse_mult_opnd(&opnd) && parsed_ok; 00572 00573 COPY_OPND(IR_OPND_R(ir_idx), opnd); 00574 00575 OPND_FLD(opnd) = IR_Tbl_Idx; 00576 OPND_IDX(opnd) = ir_idx; 00577 } 00578 00579 COPY_OPND((*result), opnd) 00580 00581 TRACE (Func_Exit, "parse_add_opnd", NULL); 00582 00583 return(parsed_ok); 00584 } /* parse_add_opnd */ 00585 00586 /******************************************************************************\ 00587 |* *| 00588 |* Description: *| 00589 |* BNF [add-op] add-opnd {add-op add-opnd} *| 00590 |* *| 00591 |* Input parameters: *| 00592 |* NONE *| 00593 |* *| 00594 |* Output parameters: *| 00595 |* NONE *| 00596 |* *| 00597 |* Returns: *| 00598 |* NOTHING *| 00599 |* *| 00600 \******************************************************************************/ 00601 00602 boolean parse_level_2(opnd_type *result) 00603 00604 { 00605 int ir_idx = NULL_IDX; 00606 opnd_type opnd = INIT_OPND_TYPE; 00607 boolean parsed_ok = TRUE; 00608 00609 TRACE (Func_Entry, "parse_level_2", NULL); 00610 00611 if (LA_CH_VALUE == PLUS || LA_CH_VALUE == MINUS) { 00612 NTR_IR_TBL(ir_idx); 00613 switch (LA_CH_VALUE) { 00614 case PLUS : 00615 IR_OPR(ir_idx) = Uplus_Opr; 00616 break; 00617 case MINUS : 00618 IR_OPR(ir_idx) = Uminus_Opr; 00619 } 00620 IR_LINE_NUM(ir_idx) = LA_CH_LINE; 00621 IR_COL_NUM(ir_idx) = LA_CH_COLUMN; 00622 NEXT_LA_CH; 00623 } 00624 00625 parsed_ok = parse_add_opnd(&opnd); 00626 00627 if (ir_idx) { 00628 COPY_OPND(IR_OPND_L(ir_idx), opnd); 00629 OPND_FLD(opnd) = IR_Tbl_Idx; 00630 OPND_IDX(opnd) = ir_idx; 00631 } 00632 00633 while (TOKEN_VALUE(token) == Tok_Op_Add || 00634 TOKEN_VALUE(token) == Tok_Op_Sub) { 00635 00636 NTR_IR_TBL(ir_idx); 00637 switch (TOKEN_VALUE(token)) { 00638 case Tok_Op_Add : 00639 IR_OPR(ir_idx) = Plus_Opr; 00640 break; 00641 case Tok_Op_Sub : 00642 IR_OPR(ir_idx) = Minus_Opr; 00643 } 00644 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 00645 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 00646 00647 COPY_OPND(IR_OPND_L(ir_idx), opnd); 00648 00649 parsed_ok = parse_add_opnd(&opnd) && parsed_ok; 00650 00651 COPY_OPND(IR_OPND_R(ir_idx), opnd); 00652 00653 OPND_FLD(opnd) = IR_Tbl_Idx; 00654 OPND_IDX(opnd) = ir_idx; 00655 } 00656 00657 COPY_OPND((*result), opnd) 00658 00659 TRACE (Func_Exit, "parse_level_2", NULL); 00660 00661 return(parsed_ok); 00662 } /* parse_level_2 */ 00663 00664 /******************************************************************************\ 00665 |* *| 00666 |* Description: *| 00667 |* BNF level-2-expr { // level-2-expr } *| 00668 |* *| 00669 |* Input parameters: *| 00670 |* NONE *| 00671 |* *| 00672 |* Output parameters: *| 00673 |* NONE *| 00674 |* *| 00675 |* Returns: *| 00676 |* NOTHING *| 00677 |* *| 00678 \******************************************************************************/ 00679 00680 boolean parse_level_3(opnd_type *result) 00681 00682 { 00683 int ir_idx; 00684 opnd_type opnd = INIT_OPND_TYPE; 00685 boolean parsed_ok = TRUE; 00686 00687 TRACE (Func_Entry, "parse_level_3", NULL); 00688 00689 parsed_ok = parse_level_2(&opnd); 00690 00691 while (TOKEN_VALUE(token) == Tok_Op_Concat) { 00692 00693 NTR_IR_TBL(ir_idx); 00694 IR_OPR(ir_idx) = Concat_Opr; 00695 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 00696 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 00697 00698 COPY_OPND(IR_OPND_L(ir_idx), opnd); 00699 00700 parsed_ok = parse_level_2(&opnd) && parsed_ok; 00701 00702 COPY_OPND(IR_OPND_R(ir_idx), opnd); 00703 00704 OPND_FLD(opnd) = IR_Tbl_Idx; 00705 OPND_IDX(opnd) = ir_idx; 00706 } 00707 00708 COPY_OPND((*result), opnd) 00709 00710 TRACE (Func_Exit, "parse_level_3", NULL); 00711 00712 return(parsed_ok); 00713 } /* parse_level_3 */ 00714 00715 /******************************************************************************\ 00716 |* *| 00717 |* Description: *| 00718 |* BNF [level-3-expr rel-op] level-3-expr *| 00719 |* *| 00720 |* Input parameters: *| 00721 |* NONE *| 00722 |* *| 00723 |* Output parameters: *| 00724 |* NONE *| 00725 |* *| 00726 |* Returns: *| 00727 |* NOTHING *| 00728 |* *| 00729 \******************************************************************************/ 00730 00731 boolean parse_level_4(opnd_type *result) 00732 00733 { 00734 int ir_idx; 00735 opnd_type opnd = INIT_OPND_TYPE; 00736 boolean parsed_ok = TRUE; 00737 00738 TRACE (Func_Entry, "parse_level_4", NULL); 00739 00740 parsed_ok = parse_level_3(&opnd); 00741 00742 if (TOKEN_VALUE(token) == Tok_Op_Eq || 00743 TOKEN_VALUE(token) == Tok_Op_Ne || 00744 TOKEN_VALUE(token) == Tok_Op_Ge || 00745 TOKEN_VALUE(token) == Tok_Op_Gt || 00746 TOKEN_VALUE(token) == Tok_Op_Le || 00747 TOKEN_VALUE(token) == Tok_Op_Lt || 00748 TOKEN_VALUE(token) == Tok_Op_Lg) { 00749 00750 NTR_IR_TBL(ir_idx); 00751 switch (TOKEN_VALUE(token)) { 00752 case Tok_Op_Eq : 00753 IR_OPR(ir_idx) = Eq_Opr; 00754 break; 00755 case Tok_Op_Ne : 00756 IR_OPR(ir_idx) = Ne_Opr; 00757 break; 00758 case Tok_Op_Ge : 00759 IR_OPR(ir_idx) = Ge_Opr; 00760 break; 00761 case Tok_Op_Gt : 00762 IR_OPR(ir_idx) = Gt_Opr; 00763 break; 00764 case Tok_Op_Le : 00765 IR_OPR(ir_idx) = Le_Opr; 00766 break; 00767 case Tok_Op_Lt : 00768 IR_OPR(ir_idx) = Lt_Opr; 00769 break; 00770 case Tok_Op_Lg : 00771 IR_OPR(ir_idx) = Lg_Opr; 00772 PRINTMSG(TOKEN_LINE(token), 1243, Ansi, TOKEN_COLUMN(token)); 00773 break; 00774 } 00775 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 00776 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 00777 00778 COPY_OPND(IR_OPND_L(ir_idx), opnd); 00779 00780 parsed_ok = parse_level_3(&opnd) && parsed_ok; 00781 00782 COPY_OPND(IR_OPND_R(ir_idx), opnd); 00783 00784 OPND_FLD(opnd) = IR_Tbl_Idx; 00785 OPND_IDX(opnd) = ir_idx; 00786 } 00787 00788 COPY_OPND((*result), opnd) 00789 00790 TRACE (Func_Exit, "parse_level_4", NULL); 00791 00792 return(parsed_ok); 00793 } /* parse_level_4 */ 00794 00795 /******************************************************************************\ 00796 |* *| 00797 |* Description: *| 00798 |* BNF [not-op] level-4-expr *| 00799 |* *| 00800 |* Input parameters: *| 00801 |* NONE *| 00802 |* *| 00803 |* Output parameters: *| 00804 |* NONE *| 00805 |* *| 00806 |* Returns: *| 00807 |* NOTHING *| 00808 |* *| 00809 \******************************************************************************/ 00810 00811 boolean parse_and_opnd(opnd_type *result) 00812 00813 { 00814 int buf_idx; 00815 int i; 00816 int ir_idx = NULL_IDX; 00817 char op[8]; 00818 opnd_type opnd = INIT_OPND_TYPE; 00819 boolean parsed_ok = TRUE; 00820 int stmt_num; 00821 00822 00823 TRACE (Func_Entry, "parse_and_opnd", NULL); 00824 00825 if (LA_CH_VALUE == DOT) { 00826 buf_idx = LA_CH_BUF_IDX; 00827 stmt_num = LA_CH_STMT_NUM; 00828 00829 NEXT_LA_CH; 00830 00831 for (i = 0; i < 4; i++) { 00832 op[i] = LA_CH_VALUE; 00833 00834 if (LA_CH_VALUE == DOT || 00835 LA_CH_VALUE == EOS) { 00836 break; 00837 } 00838 NEXT_LA_CH; 00839 } 00840 00841 reset_lex(buf_idx, stmt_num); 00842 00843 if (((i == 1 && strncmp(op, "N.", 2) == 0) || 00844 (i == 3 && strncmp(op, "NOT.", 4) == 0)) && 00845 matched_specific_token(Tok_Op_Not, Tok_Class_Op)) { 00846 00847 NTR_IR_TBL(ir_idx); 00848 OPND_FLD((*result)) = IR_Tbl_Idx; 00849 OPND_IDX((*result)) = ir_idx; 00850 IR_OPR(ir_idx) = Not_Opr; 00851 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 00852 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 00853 } 00854 } 00855 00856 parsed_ok = parse_level_4(&opnd); 00857 00858 if (ir_idx) { 00859 COPY_OPND(IR_OPND_L(ir_idx), opnd); 00860 } 00861 else { 00862 COPY_OPND((*result), opnd); 00863 } 00864 00865 TRACE (Func_Exit, "parse_and_opnd", NULL); 00866 00867 return(parsed_ok); 00868 } /* parse_and_opnd */ 00869 00870 /******************************************************************************\ 00871 |* *| 00872 |* Description: *| 00873 |* BNF and_opnd { and_op and_opnd } *| 00874 |* *| 00875 |* Input parameters: *| 00876 |* NONE *| 00877 |* *| 00878 |* Output parameters: *| 00879 |* NONE *| 00880 |* *| 00881 |* Returns: *| 00882 |* NOTHING *| 00883 |* *| 00884 \******************************************************************************/ 00885 00886 boolean parse_or_opnd(opnd_type *result) 00887 00888 { 00889 int ir_idx; 00890 opnd_type opnd = INIT_OPND_TYPE; 00891 boolean parsed_ok = TRUE; 00892 00893 TRACE (Func_Entry, "parse_or_opnd", NULL); 00894 00895 parsed_ok = parse_and_opnd(&opnd); 00896 00897 while (TOKEN_VALUE(token) == Tok_Op_And) { 00898 00899 NTR_IR_TBL(ir_idx); 00900 IR_OPR(ir_idx) = And_Opr; 00901 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 00902 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 00903 00904 COPY_OPND(IR_OPND_L(ir_idx), opnd) 00905 00906 parsed_ok = parse_and_opnd(&opnd) && parsed_ok; 00907 00908 COPY_OPND(IR_OPND_R(ir_idx), opnd) 00909 00910 OPND_FLD(opnd) = IR_Tbl_Idx; 00911 OPND_IDX(opnd) = ir_idx; 00912 } 00913 00914 COPY_OPND((*result), opnd) 00915 00916 TRACE (Func_Exit, "parse_or_opnd", NULL); 00917 00918 return(parsed_ok); 00919 } /* parse_or_opnd */ 00920 00921 /******************************************************************************\ 00922 |* *| 00923 |* Description: *| 00924 |* BNF or_opnd { or_op or_opnd } *| 00925 |* *| 00926 |* Input parameters: *| 00927 |* NONE *| 00928 |* *| 00929 |* Output parameters: *| 00930 |* NONE *| 00931 |* *| 00932 |* Returns: *| 00933 |* NOTHING *| 00934 |* *| 00935 \******************************************************************************/ 00936 00937 boolean parse_equiv_opnd(opnd_type *result) 00938 00939 { 00940 int ir_idx; 00941 opnd_type opnd = INIT_OPND_TYPE; 00942 boolean parsed_ok = TRUE; 00943 00944 TRACE (Func_Entry, "parse_equiv_opnd", NULL); 00945 00946 parsed_ok = parse_or_opnd(&opnd); 00947 00948 while (TOKEN_VALUE(token) == Tok_Op_Or) { 00949 00950 NTR_IR_TBL(ir_idx); 00951 IR_OPR(ir_idx) = Or_Opr; 00952 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 00953 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 00954 00955 COPY_OPND(IR_OPND_L(ir_idx), opnd) 00956 00957 parsed_ok = parse_or_opnd(&opnd) && parsed_ok; 00958 00959 COPY_OPND(IR_OPND_R(ir_idx), opnd) 00960 00961 OPND_FLD(opnd) = IR_Tbl_Idx; 00962 OPND_IDX(opnd) = ir_idx; 00963 } 00964 00965 COPY_OPND((*result), opnd) 00966 00967 TRACE (Func_Exit, "parse_equiv_opnd", NULL); 00968 00969 return(parsed_ok); 00970 } /* parse_equiv_opnd */ 00971 00972 /******************************************************************************\ 00973 |* *| 00974 |* Description: *| 00975 |* BNF equiv-opnd { equiv-op equiv-opnd } *| 00976 |* *| 00977 |* Input parameters: *| 00978 |* NONE *| 00979 |* *| 00980 |* Output parameters: *| 00981 |* NONE *| 00982 |* *| 00983 |* Returns: *| 00984 |* NOTHING *| 00985 |* *| 00986 \******************************************************************************/ 00987 00988 boolean parse_level_5(opnd_type *result) 00989 00990 { 00991 int ir_idx; 00992 opnd_type opnd = INIT_OPND_TYPE; 00993 boolean parsed_ok = TRUE; 00994 00995 TRACE (Func_Entry, "parse_level_5", NULL); 00996 00997 parsed_ok = parse_equiv_opnd(&opnd); 00998 00999 while (TOKEN_VALUE(token) == Tok_Op_Eqv || 01000 TOKEN_VALUE(token) == Tok_Op_Neqv) { 01001 01002 NTR_IR_TBL(ir_idx); 01003 switch (TOKEN_VALUE(token)) { 01004 case Tok_Op_Eqv : 01005 IR_OPR(ir_idx) = Eqv_Opr; 01006 break; 01007 case Tok_Op_Neqv : 01008 IR_OPR(ir_idx) = Neqv_Opr; 01009 } 01010 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 01011 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 01012 01013 COPY_OPND(IR_OPND_L(ir_idx), opnd) 01014 01015 parsed_ok = parse_equiv_opnd(&opnd) && parsed_ok; 01016 01017 COPY_OPND(IR_OPND_R(ir_idx), opnd) 01018 01019 OPND_FLD(opnd) = IR_Tbl_Idx; 01020 OPND_IDX(opnd) = ir_idx; 01021 } 01022 01023 COPY_OPND((*result), opnd) 01024 01025 TRACE (Func_Exit, "parse_level_5", NULL); 01026 01027 return(parsed_ok); 01028 } /* parse_level_5 */ 01029 01030 /******************************************************************************\ 01031 |* *| 01032 |* Description: *| 01033 |* <description> *| 01034 |* *| 01035 |* Input parameters: *| 01036 |* NONE *| 01037 |* *| 01038 |* Output parameters: *| 01039 |* NONE *| 01040 |* *| 01041 |* Returns: *| 01042 |* NOTHING *| 01043 |* *| 01044 \******************************************************************************/ 01045 boolean parse_operand (opnd_type *the_opnd) 01046 01047 { 01048 opnd_type cmplx_opnd = INIT_OPND_TYPE; 01049 int cmplx_lin_type; 01050 int cmplx_dcl_val; 01051 int cmplx_desc; 01052 int col; 01053 int cx_l = NULL_IDX; 01054 int cx_r = NULL_IDX; 01055 long_type constant[MAX_WORDS_FOR_NUMERIC]; 01056 expr_arg_type exp_desc; 01057 int ir_idx; 01058 int line; 01059 int list_idx; 01060 int list2_idx; 01061 opnd_type opnd = INIT_OPND_TYPE; 01062 boolean parsed_ok = TRUE; 01063 boolean save_in_constructor; 01064 int type_idx; 01065 int type_l; 01066 int type_r; 01067 01068 01069 TRACE (Func_Entry, "parse_operand", NULL); 01070 01071 if (LA_CH_VALUE == LPAREN && matched_specific_token(Tok_Punct_Lparen, 01072 Tok_Class_Punct)) { 01073 01074 line = TOKEN_LINE(token); 01075 col = TOKEN_COLUMN(token); 01076 01077 if (!parse_expr(the_opnd)) { 01078 parsed_ok = FALSE; 01079 } 01080 else if (LA_CH_VALUE == RPAREN) { 01081 /* insert paren_opr */ 01082 NTR_IR_TBL(ir_idx); 01083 IR_OPR(ir_idx) = Paren_Opr; 01084 COPY_OPND(IR_OPND_L(ir_idx), (*the_opnd)); 01085 OPND_FLD((*the_opnd)) = IR_Tbl_Idx; 01086 OPND_IDX((*the_opnd)) = ir_idx; 01087 IR_LINE_NUM(ir_idx) = line; 01088 IR_COL_NUM(ir_idx) = col; 01089 01090 NEXT_LA_CH; 01091 goto EXIT; 01092 } 01093 /* Assume complex constant - Try to fold */ 01094 else if (OPND_FLD((*the_opnd)) == CN_Tbl_Idx) { 01095 cx_l = OPND_IDX((*the_opnd)); 01096 } 01097 else if (OPND_FLD((*the_opnd)) == AT_Tbl_Idx && 01098 AT_OBJ_CLASS(OPND_IDX((*the_opnd))) == Data_Obj && 01099 ATD_CLASS(OPND_IDX((*the_opnd))) == Constant && 01100 ATD_FLD(OPND_IDX((*the_opnd))) == CN_Tbl_Idx) { 01101 01102 cx_l = ATD_CONST_IDX(OPND_IDX((*the_opnd))); 01103 } 01104 else if (OPND_FLD((*the_opnd)) == IR_Tbl_Idx && 01105 (IR_OPR(OPND_IDX((*the_opnd))) == Uplus_Opr || 01106 IR_OPR(OPND_IDX((*the_opnd))) == Uminus_Opr) && 01107 (IR_FLD_L(OPND_IDX((*the_opnd))) == CN_Tbl_Idx || 01108 (IR_FLD_L(OPND_IDX((*the_opnd))) == AT_Tbl_Idx && 01109 AT_OBJ_CLASS(IR_IDX_L(OPND_IDX((*the_opnd)))) == Data_Obj && 01110 ATD_CLASS(IR_IDX_L(OPND_IDX((*the_opnd)))) == Constant && 01111 ATD_FLD(IR_IDX_L(OPND_IDX((*the_opnd)))) == CN_Tbl_Idx))) { 01112 01113 exp_desc.rank = 0; 01114 xref_state = CIF_No_Usage_Rec; 01115 comp_gen_expr = TRUE; 01116 parsed_ok = expr_semantics(the_opnd, &exp_desc); 01117 comp_gen_expr = FALSE; 01118 01119 if (OPND_FLD((*the_opnd)) == CN_Tbl_Idx) { 01120 cx_l = OPND_IDX((*the_opnd)); 01121 } 01122 } 01123 01124 if (cx_l && 01125 (TYP_TYPE(CN_TYPE_IDX(cx_l)) == Real || 01126 TYP_TYPE(CN_TYPE_IDX(cx_l)) == Integer) && 01127 LA_CH_VALUE == COMMA ) { 01128 /* Have complex const */ 01129 NEXT_LA_CH; 01130 01131 if (!parse_expr(&cmplx_opnd)) { 01132 parsed_ok = FALSE; 01133 } 01134 else { 01135 01136 if (OPND_FLD(cmplx_opnd) == CN_Tbl_Idx) { 01137 cx_r = OPND_IDX(cmplx_opnd); 01138 } 01139 else if (OPND_FLD(cmplx_opnd) == AT_Tbl_Idx && 01140 AT_OBJ_CLASS(OPND_IDX(cmplx_opnd)) == Data_Obj && 01141 ATD_CLASS(OPND_IDX(cmplx_opnd)) == Constant && 01142 ATD_FLD(OPND_IDX(cmplx_opnd)) == CN_Tbl_Idx) { 01143 01144 cx_r = ATD_CONST_IDX(OPND_IDX(cmplx_opnd)); 01145 } 01146 else if (OPND_FLD(cmplx_opnd) == IR_Tbl_Idx && 01147 (IR_OPR(OPND_IDX(cmplx_opnd)) == Uplus_Opr || 01148 IR_OPR(OPND_IDX(cmplx_opnd)) == Uminus_Opr) && 01149 (IR_FLD_L(OPND_IDX(cmplx_opnd)) == CN_Tbl_Idx || 01150 (IR_FLD_L(OPND_IDX(cmplx_opnd)) == AT_Tbl_Idx && 01151 AT_OBJ_CLASS(IR_IDX_L(OPND_IDX(cmplx_opnd)))==Data_Obj && 01152 ATD_CLASS(IR_IDX_L(OPND_IDX(cmplx_opnd))) == Constant && 01153 ATD_FLD(IR_IDX_L(OPND_IDX(cmplx_opnd))) == CN_Tbl_Idx))){ 01154 01155 exp_desc.rank = 0; 01156 xref_state = CIF_No_Usage_Rec; 01157 comp_gen_expr = TRUE; 01158 parsed_ok = expr_semantics(&cmplx_opnd, &exp_desc); 01159 comp_gen_expr = FALSE; 01160 01161 if (OPND_FLD(cmplx_opnd) == CN_Tbl_Idx) { 01162 cx_r = OPND_IDX(cmplx_opnd); 01163 } 01164 } 01165 01166 01167 if (cx_r && 01168 (TYP_TYPE(CN_TYPE_IDX(cx_r)) == Real || 01169 TYP_TYPE(CN_TYPE_IDX(cx_r)) == Integer)) { 01170 type_r = CN_TYPE_IDX(cx_r); 01171 type_l = CN_TYPE_IDX(cx_l); 01172 01173 if (TYP_TYPE(type_l) == Real && 01174 TYP_TYPE(type_r) == Real) { 01175 01176 if (TYP_LINEAR(type_l) > TYP_LINEAR(type_r)) { 01177 cmplx_lin_type = TYP_LINEAR(type_l); 01178 cmplx_dcl_val = TYP_DCL_VALUE(type_l); 01179 cmplx_desc = TYP_DESC(type_l); 01180 } 01181 else { 01182 cmplx_lin_type = TYP_LINEAR(type_r); 01183 cmplx_dcl_val = TYP_DCL_VALUE(type_r); 01184 cmplx_desc = TYP_DESC(type_r); 01185 } 01186 } 01187 else if (TYP_TYPE(type_l) == Real && 01188 TYP_TYPE(type_r) == Integer) { 01189 cmplx_lin_type = TYP_LINEAR(type_l); 01190 cmplx_dcl_val = TYP_DCL_VALUE(type_l); 01191 cmplx_desc = TYP_DESC(type_l); 01192 01193 } 01194 else if (TYP_TYPE(type_l) == Integer && 01195 TYP_TYPE(type_r) == Real) { 01196 cmplx_lin_type = TYP_LINEAR(type_r); 01197 cmplx_dcl_val = TYP_DCL_VALUE(type_r); 01198 cmplx_desc = TYP_DESC(type_r); 01199 01200 } 01201 else { /* both integer */ 01202 cmplx_lin_type = REAL_DEFAULT_TYPE; 01203 cmplx_dcl_val = 0; 01204 cmplx_desc = 0; 01205 } 01206 01207 type_idx = cmplx_lin_type; 01208 parsed_ok = folder_driver((char *)&CN_CONST(cx_l), 01209 type_l, 01210 NULL, 01211 NULL_IDX, 01212 constant, 01213 &type_idx, 01214 line, 01215 col, 01216 1, 01217 Cvrt_Opr) && parsed_ok; 01218 01219 type_idx = cmplx_lin_type; 01220 parsed_ok = folder_driver((char *)&CN_CONST(cx_r), 01221 type_r, 01222 NULL, 01223 NULL_IDX, 01224 &(constant[num_host_wds[cmplx_lin_type]]), 01225 &type_idx, 01226 line, 01227 col, 01228 1, 01229 Cvrt_Opr) && parsed_ok; 01230 01231 switch(cmplx_lin_type) { 01232 case Real_4 : 01233 cmplx_lin_type = Complex_4; 01234 # if defined(_WHIRL_HOST64_TARGET64) 01235 { 01236 float *p = (float*)(&constant); 01237 p[1] = p[2]; 01238 } 01239 # endif 01240 break; 01241 01242 case Real_8 : 01243 cmplx_lin_type = Complex_8; 01244 break; 01245 01246 case Real_16 : 01247 cmplx_lin_type = Complex_16; 01248 break; 01249 01250 } 01251 01252 OPND_FLD((*the_opnd)) = CN_Tbl_Idx; 01253 01254 CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX); 01255 TYP_TYPE(TYP_WORK_IDX) = Complex; 01256 TYP_LINEAR(TYP_WORK_IDX) = (linear_type_type) cmplx_lin_type; 01257 TYP_DCL_VALUE(TYP_WORK_IDX) = cmplx_dcl_val; 01258 TYP_DESC(TYP_WORK_IDX) = (type_desc_type) cmplx_desc; 01259 type_idx = ntr_type_tbl(); 01260 01261 OPND_IDX((*the_opnd)) = ntr_const_tbl(type_idx, 01262 FALSE, 01263 constant); 01264 } 01265 else { 01266 parse_err_flush(Find_Rparen, "CONSTANT"); 01267 parsed_ok = FALSE; 01268 } 01269 } 01270 } 01271 01272 if (LA_CH_VALUE == RPAREN) { 01273 NEXT_LA_CH; 01274 } 01275 else if (parse_err_flush(Find_Rparen, ")")) { 01276 NEXT_LA_CH; 01277 parsed_ok = FALSE; 01278 } 01279 else { 01280 parsed_ok = FALSE; 01281 } 01282 goto EXIT; 01283 } 01284 else if (LA_CH_CLASS == Ch_Class_Digit || 01285 LA_CH_CLASS == Ch_Class_Letter || 01286 LA_CH_VALUE == DOT || 01287 LA_CH_VALUE == QUOTE || 01288 LA_CH_VALUE == DBL_QUOTE) { 01289 01290 if (MATCHED_TOKEN_CLASS(Tok_Class_Opnd)) { 01291 OPND_LINE_NUM((*the_opnd)) = TOKEN_LINE(token); 01292 OPND_COL_NUM((*the_opnd)) = TOKEN_COLUMN(token); 01293 OPND_FLD((*the_opnd)) = CN_Tbl_Idx; 01294 01295 switch (TOKEN_VALUE(token)) { 01296 01297 case Tok_Id : 01298 01299 if (! parse_deref(the_opnd, NULL_IDX)) { 01300 parsed_ok = FALSE; 01301 } 01302 break; 01303 01304 case Tok_Const_Char : 01305 01306 if (LA_CH_VALUE == LPAREN && is_substring_ref ()) { 01307 NTR_IR_TBL(ir_idx); 01308 IR_OPR(ir_idx) = Substring_Opr; 01309 IR_LINE_NUM(ir_idx) = LA_CH_LINE; 01310 IR_COL_NUM(ir_idx) = LA_CH_COLUMN; 01311 OPND_FLD((*the_opnd)) = IR_Tbl_Idx; 01312 OPND_IDX((*the_opnd)) = ir_idx; 01313 IR_FLD_L(ir_idx) = CN_Tbl_Idx; 01314 IR_IDX_L(ir_idx) = TOKEN_CONST_TBL_IDX(token); 01315 IR_LINE_NUM_L(ir_idx) = TOKEN_LINE(token); 01316 IR_COL_NUM_L(ir_idx) = TOKEN_COLUMN(token); 01317 01318 IR_FLD_R(ir_idx) = IL_Tbl_Idx; 01319 IR_LIST_CNT_R(ir_idx) = 2; 01320 NTR_IR_LIST_TBL(list_idx); 01321 NTR_IR_LIST_TBL(list2_idx); 01322 IR_IDX_R(ir_idx) = list_idx; 01323 IL_NEXT_LIST_IDX(list_idx) = list2_idx; 01324 IL_PREV_LIST_IDX(list2_idx) = list_idx; 01325 01326 /* consume ( */ 01327 NEXT_LA_CH; 01328 01329 if (LA_CH_VALUE != COLON) { 01330 parsed_ok = parse_expr(&opnd) && parsed_ok; 01331 COPY_OPND(IL_OPND(list_idx), opnd); 01332 } 01333 01334 if (LA_CH_VALUE != COLON) { 01335 if (parse_err_flush(Find_Rparen, ":")) { 01336 NEXT_LA_CH; 01337 } 01338 parsed_ok = FALSE; 01339 goto EXIT; 01340 } 01341 else { 01342 NEXT_LA_CH; 01343 } 01344 if (LA_CH_VALUE != RPAREN) { 01345 parsed_ok = parse_expr(&opnd) && parsed_ok; 01346 COPY_OPND(IL_OPND(list2_idx), opnd); 01347 } 01348 01349 if (LA_CH_VALUE != RPAREN) { 01350 01351 if (parse_err_flush(Find_Rparen, ")")) { 01352 NEXT_LA_CH; 01353 } 01354 parsed_ok = FALSE; 01355 } 01356 else { 01357 NEXT_LA_CH; 01358 } 01359 } 01360 else { 01361 OPND_IDX((*the_opnd)) = TOKEN_CONST_TBL_IDX(token); 01362 } 01363 break; 01364 01365 case Tok_Const_Hollerith : 01366 case Tok_Const_Boolean : 01367 case Tok_Const_Boz : 01368 case Tok_Const_Int : 01369 case Tok_Const_Real : 01370 case Tok_Const_Dbl : 01371 case Tok_Const_Quad : 01372 case Tok_Const_False : 01373 case Tok_Const_True : 01374 01375 OPND_IDX((*the_opnd)) = TOKEN_CONST_TBL_IDX(token); 01376 break; 01377 } 01378 } 01379 else if (TOKEN_VALUE(token) == Tok_Unknown) { 01380 parsed_ok = FALSE; 01381 parse_err_flush(Find_Expr_End, parse_operand_insert); 01382 } 01383 else { 01384 parsed_ok = FALSE; 01385 parse_err_flush(Find_Expr_End, NULL); 01386 } 01387 } 01388 else if (LA_CH_VALUE == LPAREN && matched_specific_token(Tok_Punct_Lbrkt, 01389 Tok_Class_Punct)) { 01390 01391 /* Have array constructor */ 01392 01393 NTR_IR_TBL(ir_idx); 01394 IR_OPR(ir_idx) = Array_Construct_Opr; 01395 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 01396 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 01397 OPND_FLD((*the_opnd)) = IR_Tbl_Idx; 01398 OPND_IDX((*the_opnd)) = ir_idx; 01399 01400 save_in_constructor = in_constructor; 01401 in_constructor = TRUE; 01402 parsed_ok = parse_io_list(&opnd) && parsed_ok; 01403 in_constructor = save_in_constructor; 01404 01405 COPY_OPND(IR_OPND_R(ir_idx), opnd); 01406 01407 if (LA_CH_VALUE == SLASH && matched_specific_token(Tok_Punct_Rbrkt, 01408 Tok_Class_Punct)) { 01409 01410 /* intentionally blank */ 01411 } 01412 else { 01413 parse_err_flush(Find_EOS, "/)"); 01414 parsed_ok = FALSE; 01415 } 01416 } 01417 else { 01418 parsed_ok = FALSE; 01419 parse_err_flush(Find_Expr_End, parse_operand_insert); 01420 01421 if (LA_CH_VALUE == EOS) { 01422 TOKEN_STR_WD(token, 0) = 0; 01423 TOKEN_VALUE(token) = Tok_EOS; 01424 TOKEN_KIND_STR(token)[0] = EOS; 01425 TOKEN_KIND_LEN(token) = 0; 01426 TOKEN_LEN(token) = 0; 01427 TOKEN_LINE(token) = LA_CH_LINE; 01428 TOKEN_COLUMN(token) = LA_CH_COLUMN; 01429 } 01430 } 01431 01432 EXIT: 01433 TRACE (Func_Exit, "parse_operand", NULL); 01434 01435 return(parsed_ok); 01436 01437 } /* parse_operand */ 01438 01439 /******************************************************************************\ 01440 |* *| 01441 |* Description: *| 01442 |* Parse structure/array dereference on lhs of assignment. *| 01443 |* *| 01444 |* Input parameters: *| 01445 |* NONE *| 01446 |* *| 01447 |* Output parameters: *| 01448 |* result_opnd - opnd_type, points to root of tree returned. *| 01449 |* *| 01450 |* Returns: *| 01451 |* TRUE if parsed ok *| 01452 |* *| 01453 \******************************************************************************/ 01454 01455 boolean parse_lhs (opnd_type *result_opnd, 01456 int attr_idx) 01457 01458 { 01459 01460 int array_idx; 01461 int amb_attr_idx; 01462 token_type attr_name; 01463 int col; 01464 int ir_idx; 01465 int line; 01466 int list_idx; 01467 int list2_idx; 01468 int list3_idx; 01469 opnd_type opnd = INIT_OPND_TYPE; 01470 boolean parsed_ok = TRUE; 01471 int rank; 01472 int subs_idx = NULL_IDX; 01473 int substring_idx; 01474 int trip_idx; 01475 01476 01477 TRACE (Func_Entry, "parse_lhs", NULL); 01478 01479 attr_name = token; 01480 01481 amb_attr_idx = attr_idx; 01482 01483 while (AT_ATTR_LINK(amb_attr_idx)) { 01484 amb_attr_idx = AT_ATTR_LINK(amb_attr_idx); 01485 } 01486 01487 /* if local attr has problem, quit */ 01488 01489 if (AT_DCL_ERR(attr_idx)) { 01490 SH_ERR_FLG(curr_stmt_sh_idx) = TRUE; 01491 01492 parse_err_flush(Find_Ref_End, NULL); 01493 parsed_ok = FALSE; 01494 goto EXIT; 01495 } 01496 01497 /* Now lets see what this attr is */ 01498 01499 switch (AT_OBJ_CLASS(amb_attr_idx)) { 01500 case Data_Obj : 01501 01502 break; 01503 01504 case Pgm_Unit : 01505 /* must be result var of local or host function, not interface or */ 01506 /* other external */ 01507 01508 if (ATP_PGM_UNIT(amb_attr_idx) == Function && 01509 ATP_SCP_ALIVE(amb_attr_idx)) { 01510 01511 if (ATP_RSLT_NAME(amb_attr_idx)) { 01512 01513 /* error .. assigned function name not result name */ 01514 01515 PRINTMSG(TOKEN_LINE(token), 299, Error, 01516 TOKEN_COLUMN(token)); 01517 parse_err_flush(Find_Ref_End, NULL); 01518 parsed_ok = FALSE; 01519 goto EXIT; 01520 } 01521 else { 01522 attr_idx = ATP_RSLT_IDX(amb_attr_idx); 01523 amb_attr_idx = attr_idx; 01524 } 01525 } 01526 else { 01527 01528 if (AT_NOT_VISIBLE(amb_attr_idx)) { 01529 PRINTMSG(TOKEN_LINE(token), 486, Error, 01530 TOKEN_COLUMN(token), 01531 AT_OBJ_NAME_PTR(amb_attr_idx), 01532 AT_OBJ_NAME_PTR(AT_MODULE_IDX((amb_attr_idx)))); 01533 } 01534 else { /* can't assign to pgm unit other than current function */ 01535 PRINTMSG(TOKEN_LINE(token), 281, Error, 01536 TOKEN_COLUMN(token)); 01537 } 01538 parsed_ok = FALSE; 01539 parse_err_flush(Find_Ref_End, NULL); 01540 goto EXIT; 01541 } 01542 01543 break; 01544 01545 default : 01546 01547 if (AT_NOT_VISIBLE(amb_attr_idx)) { 01548 PRINTMSG(TOKEN_LINE(token), 486, Error, 01549 TOKEN_COLUMN(token), 01550 AT_OBJ_NAME_PTR(amb_attr_idx), 01551 AT_OBJ_NAME_PTR(AT_MODULE_IDX((amb_attr_idx)))); 01552 } 01553 else { /* can't assign this to a program unit */ 01554 PRINTMSG(TOKEN_LINE(token), 281, Error, 01555 TOKEN_COLUMN(token)); 01556 } 01557 01558 parsed_ok = FALSE; 01559 parse_err_flush(Find_Ref_End, NULL); 01560 goto EXIT; 01561 } 01562 01563 OPND_FLD((*result_opnd)) = AT_Tbl_Idx; 01564 OPND_IDX((*result_opnd)) = attr_idx; 01565 OPND_LINE_NUM((*result_opnd)) = TOKEN_LINE(token); 01566 OPND_COL_NUM((*result_opnd)) = TOKEN_COLUMN(token); 01567 01568 # ifdef COARRAY_FORTRAN 01569 if (LA_CH_VALUE != PERCENT && LA_CH_VALUE != LPAREN && 01570 ((! cmd_line_flags.co_array_fortran) || LA_CH_VALUE != LBRKT)) 01571 # else 01572 if (LA_CH_VALUE != PERCENT && LA_CH_VALUE != LPAREN) 01573 # endif 01574 { 01575 goto EXIT; 01576 } 01577 01578 01579 if (LA_CH_VALUE == LPAREN) { 01580 /* do that array stuff */ 01581 array_idx = ATD_ARRAY_IDX(amb_attr_idx); 01582 01583 if (array_idx) { 01584 01585 rank = 0; 01586 NTR_IR_TBL(subs_idx); 01587 IR_FLD_L(subs_idx) = AT_Tbl_Idx; 01588 IR_IDX_L(subs_idx) = attr_idx; 01589 IR_LINE_NUM_L(subs_idx) = TOKEN_LINE(token); 01590 IR_COL_NUM_L(subs_idx) = TOKEN_COLUMN(token); 01591 01592 /* LA_CH is '(' */ 01593 IR_LINE_NUM(subs_idx) = LA_CH_LINE; 01594 IR_COL_NUM(subs_idx) = LA_CH_COLUMN; 01595 01596 IR_OPR(subs_idx) = Subscript_Opr; 01597 IR_FLD_R(subs_idx) = IL_Tbl_Idx; 01598 01599 list_idx = NULL_IDX; 01600 01601 do { 01602 NEXT_LA_CH; 01603 01604 if (list_idx == NULL_IDX) { 01605 NTR_IR_LIST_TBL(list_idx); 01606 IR_IDX_R(subs_idx) = list_idx; 01607 } 01608 else { 01609 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx)); 01610 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx; 01611 list_idx = IL_NEXT_LIST_IDX(list_idx); 01612 } 01613 01614 if (LA_CH_VALUE != COLON) { 01615 parsed_ok = parse_expr(&opnd) && parsed_ok; 01616 COPY_OPND(IL_OPND(list_idx), opnd); 01617 } 01618 01619 /* do some text stuff here */ 01620 01621 if (LA_CH_VALUE == COLON) { 01622 NTR_IR_TBL(trip_idx); 01623 IR_LINE_NUM(trip_idx) = LA_CH_LINE; 01624 IR_COL_NUM(trip_idx) = LA_CH_COLUMN; 01625 01626 NEXT_LA_CH; 01627 01628 IR_OPR(trip_idx) = Triplet_Opr; 01629 IR_FLD_L(trip_idx) = IL_Tbl_Idx; 01630 IR_LIST_CNT_L(trip_idx) = 3; 01631 NTR_IR_LIST_TBL(list2_idx); 01632 IR_IDX_L(trip_idx) = list2_idx; 01633 IL_OPND(list2_idx) = IL_OPND(list_idx); 01634 IL_FLD(list_idx) = IR_Tbl_Idx; 01635 IL_IDX(list_idx) = trip_idx; 01636 NTR_IR_LIST_TBL(list3_idx); 01637 IL_NEXT_LIST_IDX(list2_idx) = list3_idx; 01638 IL_PREV_LIST_IDX(list3_idx) = list2_idx; 01639 01640 if (LA_CH_VALUE != COLON && 01641 LA_CH_VALUE != COMMA && 01642 LA_CH_VALUE != RPAREN) { 01643 parsed_ok = parse_expr(&opnd) && parsed_ok; 01644 COPY_OPND(IL_OPND(list3_idx), opnd); 01645 } 01646 01647 NTR_IR_LIST_TBL(list2_idx); 01648 IL_NEXT_LIST_IDX(list3_idx) = list2_idx; 01649 IL_PREV_LIST_IDX(list2_idx) = list3_idx; 01650 01651 if (LA_CH_VALUE == COLON) { 01652 NEXT_LA_CH; 01653 parsed_ok = parse_expr(&opnd) && parsed_ok; 01654 COPY_OPND(IL_OPND(list2_idx), opnd); 01655 } 01656 } 01657 rank++; 01658 } 01659 while (LA_CH_VALUE == COMMA); 01660 01661 if (! matched_specific_token(Tok_Punct_Rparen, Tok_Class_Punct)) { 01662 if (parse_err_flush(Find_Rparen, ")")) { 01663 NEXT_LA_CH; 01664 } 01665 parsed_ok = FALSE; 01666 goto EXIT; 01667 } 01668 01669 IR_LIST_CNT_R(subs_idx) = rank; 01670 01671 } /* if (array_idx) */ 01672 01673 /* now check for possible substring reference */ 01674 01675 if (LA_CH_VALUE == LPAREN) { 01676 01677 if (is_substring_ref ()) { 01678 01679 if (TYP_TYPE(ATD_TYPE_IDX(amb_attr_idx)) != Character) { 01680 01681 PRINTMSG(TOKEN_LINE(token), 508, Error, TOKEN_COLUMN(token)); 01682 parsed_ok = FALSE; 01683 parse_err_flush(Find_Ref_End, NULL); 01684 goto EXIT; 01685 } 01686 01687 NTR_IR_TBL(substring_idx); 01688 IR_OPR(substring_idx) = Substring_Opr; 01689 IR_LINE_NUM(substring_idx) = LA_CH_LINE; 01690 IR_COL_NUM(substring_idx) = LA_CH_COLUMN; 01691 OPND_FLD((*result_opnd)) = IR_Tbl_Idx; 01692 OPND_IDX((*result_opnd)) = substring_idx; 01693 01694 if (subs_idx) { 01695 IR_FLD_L(substring_idx) = IR_Tbl_Idx; 01696 IR_IDX_L(substring_idx) = subs_idx; 01697 01698 } 01699 else { 01700 IR_FLD_L(substring_idx) = AT_Tbl_Idx; 01701 IR_IDX_L(substring_idx) = attr_idx; 01702 IR_LINE_NUM_L(substring_idx) = TOKEN_LINE(token); 01703 IR_COL_NUM_L(substring_idx) = TOKEN_COLUMN(token); 01704 } 01705 01706 IR_FLD_R(substring_idx) = IL_Tbl_Idx; 01707 IR_LIST_CNT_R(substring_idx) = 2; 01708 NTR_IR_LIST_TBL(list_idx); 01709 NTR_IR_LIST_TBL(list2_idx); 01710 IR_IDX_R(substring_idx) = list_idx; 01711 IL_NEXT_LIST_IDX(list_idx) = list2_idx; 01712 IL_PREV_LIST_IDX(list2_idx) = list_idx; 01713 01714 /* consume ( */ 01715 NEXT_LA_CH; 01716 01717 if (LA_CH_VALUE != COLON) { 01718 parsed_ok = parse_expr(&opnd) && parsed_ok; 01719 COPY_OPND(IL_OPND(list_idx), opnd); 01720 } 01721 01722 if (LA_CH_VALUE != COLON) { 01723 if (parse_err_flush(Find_Rparen, ":")) { 01724 NEXT_LA_CH; 01725 } 01726 parsed_ok = FALSE; 01727 goto EXIT; 01728 } 01729 else { 01730 NEXT_LA_CH; 01731 } 01732 01733 if (LA_CH_VALUE != RPAREN) { 01734 parsed_ok = parse_expr(&opnd) && parsed_ok; 01735 COPY_OPND(IL_OPND(list2_idx), opnd); 01736 } 01737 01738 if (LA_CH_VALUE != RPAREN) { 01739 01740 if (parse_err_flush(Find_Rparen, ")")) { 01741 NEXT_LA_CH; 01742 } 01743 parsed_ok = FALSE; 01744 goto EXIT; 01745 } 01746 else { 01747 NEXT_LA_CH; 01748 } 01749 goto EXIT; 01750 } 01751 } 01752 01753 if (LA_CH_VALUE != PERCENT) { 01754 01755 if (subs_idx) { 01756 OPND_FLD((*result_opnd)) = IR_Tbl_Idx; 01757 OPND_IDX((*result_opnd)) = subs_idx; 01758 } 01759 else { 01760 01761 OPND_FLD((*result_opnd)) = AT_Tbl_Idx; 01762 OPND_IDX((*result_opnd)) = attr_idx; 01763 OPND_LINE_NUM((*result_opnd)) = TOKEN_LINE(attr_name); 01764 OPND_COL_NUM((*result_opnd)) = TOKEN_COLUMN(attr_name); 01765 01766 } 01767 } 01768 } /* if (LA_CH_VALUE == LPAREN) */ 01769 01770 # ifdef COARRAY_FORTRAN 01771 if (cmd_line_flags.co_array_fortran && 01772 LA_CH_VALUE == LBRKT && 01773 AT_OBJ_CLASS(amb_attr_idx) == Data_Obj) { 01774 01775 if (ATD_PE_ARRAY_IDX(amb_attr_idx) == NULL_IDX) { 01776 /* not declared with pe dimensions */ 01777 PRINTMSG(LA_CH_LINE, 1245, Error, LA_CH_COLUMN, 01778 AT_OBJ_NAME_PTR(amb_attr_idx)); 01779 parsed_ok = FALSE; 01780 parse_err_flush(Find_Ref_End, NULL); 01781 goto EXIT; 01782 } 01783 01784 if (subs_idx == NULL_IDX) { 01785 NTR_IR_TBL(subs_idx); 01786 01787 /* LA_CH is '[' */ 01788 IR_LINE_NUM(subs_idx) = LA_CH_LINE; 01789 IR_COL_NUM(subs_idx) = LA_CH_COLUMN; 01790 01791 IR_OPR(subs_idx) = Subscript_Opr; 01792 IR_FLD_R(subs_idx) = IL_Tbl_Idx; 01793 IR_LIST_CNT_R(subs_idx) = 0; 01794 01795 if (OPND_FLD((*result_opnd)) == AT_Tbl_Idx) { 01796 COPY_OPND(IR_OPND_L(subs_idx), (*result_opnd)); 01797 01798 /* put subs_idx into result opnd for now */ 01799 OPND_FLD((*result_opnd)) = IR_Tbl_Idx; 01800 OPND_IDX((*result_opnd)) = subs_idx; 01801 } 01802 else if (OPND_FLD((*result_opnd)) == IR_Tbl_Idx && 01803 IR_OPR(OPND_IDX((*result_opnd))) == Substring_Opr) { 01804 01805 COPY_OPND(IR_OPND_L(subs_idx), IR_OPND_L(OPND_IDX((*result_opnd)))); 01806 01807 IR_FLD_L(OPND_IDX((*result_opnd))) = IR_Tbl_Idx; 01808 IR_IDX_L(OPND_IDX((*result_opnd))) = subs_idx; 01809 } 01810 # ifdef _DEBUG 01811 else { 01812 PRINTMSG(LA_CH_LINE, 626, Internal, LA_CH_COLUMN, 01813 "AT_Tbl_Idx", "parse_deref"); 01814 } 01815 # endif 01816 01817 list_idx = NULL_IDX; 01818 } 01819 else { 01820 01821 list_idx = IR_IDX_R(subs_idx); 01822 01823 while (IL_NEXT_LIST_IDX(list_idx) != NULL_IDX) { 01824 list_idx = IL_NEXT_LIST_IDX(list_idx); 01825 } 01826 } 01827 01828 do { 01829 NEXT_LA_CH; 01830 01831 if (list_idx == NULL_IDX) { 01832 NTR_IR_LIST_TBL(list_idx); 01833 IR_IDX_R(subs_idx) = list_idx; 01834 } 01835 else { 01836 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx)); 01837 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx; 01838 list_idx = IL_NEXT_LIST_IDX(list_idx); 01839 } 01840 01841 IL_PE_SUBSCRIPT(list_idx) = TRUE; 01842 01843 if (LA_CH_VALUE != COLON) { 01844 parsed_ok = parse_expr(&opnd) && parsed_ok; 01845 COPY_OPND(IL_OPND(list_idx), opnd); 01846 } 01847 01848 /* do some text stuff here */ 01849 01850 if (LA_CH_VALUE == COLON) { 01851 01852 NTR_IR_TBL(trip_idx); 01853 IR_LINE_NUM(trip_idx) = LA_CH_LINE; 01854 IR_COL_NUM(trip_idx) = LA_CH_COLUMN; 01855 01856 NEXT_LA_CH; 01857 01858 IR_OPR(trip_idx) = Triplet_Opr; 01859 IR_FLD_L(trip_idx) = IL_Tbl_Idx; 01860 IR_LIST_CNT_L(trip_idx) = 3; 01861 NTR_IR_LIST_TBL(list2_idx); 01862 IR_IDX_L(trip_idx) = list2_idx; 01863 IL_OPND(list2_idx) = IL_OPND(list_idx); 01864 IL_FLD(list_idx) = IR_Tbl_Idx; 01865 IL_IDX(list_idx) = trip_idx; 01866 NTR_IR_LIST_TBL(list3_idx); 01867 IL_NEXT_LIST_IDX(list2_idx) = list3_idx; 01868 IL_PREV_LIST_IDX(list3_idx) = list2_idx; 01869 01870 if (LA_CH_VALUE != COLON && 01871 LA_CH_VALUE != COMMA && 01872 LA_CH_VALUE != RBRKT) { 01873 parsed_ok = parse_expr(&opnd) && parsed_ok; 01874 COPY_OPND(IL_OPND(list3_idx), opnd); 01875 } 01876 01877 NTR_IR_LIST_TBL(list2_idx); 01878 IL_NEXT_LIST_IDX(list3_idx) = list2_idx; 01879 IL_PREV_LIST_IDX(list2_idx) = list3_idx; 01880 01881 if (LA_CH_VALUE == COLON) { 01882 NEXT_LA_CH; 01883 parsed_ok = parse_expr(&opnd) && parsed_ok; 01884 COPY_OPND(IL_OPND(list2_idx), opnd); 01885 } 01886 } 01887 (IR_LIST_CNT_R(subs_idx))++; 01888 } 01889 while (LA_CH_VALUE == COMMA); 01890 01891 if (LA_CH_VALUE != RBRKT) { 01892 parse_err_flush(Find_EOS, "]"); 01893 parsed_ok = FALSE; 01894 goto EXIT; 01895 } 01896 else { 01897 /* swallow ] */ 01898 NEXT_LA_CH; 01899 } 01900 } 01901 # endif 01902 01903 if (LA_CH_VALUE == PERCENT) { 01904 01905 /* first see if attr_idx is a structure */ 01906 01907 if (TYP_TYPE(ATD_TYPE_IDX(amb_attr_idx)) != Structure) { 01908 01909 if (SCP_IMPL_NONE(curr_scp_idx) && !AT_TYPED(amb_attr_idx) && 01910 !AT_DCL_ERR(amb_attr_idx)) { 01911 AT_DCL_ERR(amb_attr_idx) = TRUE; 01912 PRINTMSG(TOKEN_LINE(attr_name), 113, Error, 01913 TOKEN_COLUMN(attr_name), 01914 TOKEN_STR(attr_name)); 01915 } 01916 else { 01917 PRINTMSG(TOKEN_LINE(attr_name), 212, Error, 01918 TOKEN_COLUMN(attr_name), 01919 TOKEN_STR(attr_name), 01920 get_basic_type_str(ATD_TYPE_IDX(amb_attr_idx))); 01921 } 01922 01923 parse_err_flush(Find_Ref_End, NULL); 01924 parsed_ok = FALSE; 01925 goto EXIT; 01926 } 01927 line = LA_CH_LINE; 01928 col = LA_CH_COLUMN; 01929 NEXT_LA_CH; 01930 01931 if (MATCHED_TOKEN_CLASS(Tok_Class_Id)) { 01932 NTR_IR_TBL(ir_idx); 01933 IR_OPR(ir_idx) = Struct_Opr; 01934 IR_LINE_NUM(ir_idx) = line; 01935 IR_COL_NUM(ir_idx) = col; 01936 01937 if (subs_idx) { 01938 IR_FLD_L(ir_idx) = IR_Tbl_Idx; 01939 IR_IDX_L(ir_idx) = subs_idx; 01940 } 01941 else { 01942 IR_FLD_L(ir_idx) = AT_Tbl_Idx; 01943 IR_IDX_L(ir_idx) = attr_idx; 01944 01945 IR_LINE_NUM_L(ir_idx) = TOKEN_LINE(attr_name); 01946 IR_COL_NUM_L(ir_idx) = TOKEN_COLUMN(attr_name); 01947 } 01948 01949 OPND_FLD((*result_opnd)) = IR_Tbl_Idx; 01950 OPND_IDX((*result_opnd)) = ir_idx; 01951 01952 parsed_ok = parse_deref(result_opnd, 01953 TYP_IDX(ATD_TYPE_IDX(amb_attr_idx))); 01954 01955 } 01956 else { 01957 /* no ID after %, must be an error */ 01958 parse_err_flush(Find_Ref_End, "IDENTIFIER"); 01959 parsed_ok = FALSE; 01960 } 01961 } 01962 01963 EXIT: 01964 01965 if (parsed_ok) { 01966 01967 if (ATD_CLASS(amb_attr_idx) == Function_Result) { 01968 AT_DEFINED(ATD_FUNC_IDX(amb_attr_idx)) = TRUE; 01969 } 01970 else if (ATD_CLASS(amb_attr_idx) == Atd_Unknown) { 01971 ATD_CLASS(amb_attr_idx) = Variable; 01972 } 01973 01974 AT_DEFINED(attr_idx) = TRUE; 01975 } 01976 01977 TRACE (Func_Exit, "parse_lhs", NULL); 01978 01979 return(parsed_ok); 01980 01981 } /* parse_lhs */