|
Mismatched parentheses - error H |
Top Previous Next |
|
Parentheses must match up in expressions. An excess number of open "(" parentheses are marked with $8 while excess closed ")" parentheses are marked with $408 [i.e., cases like SUM (I,X(I); or SUM (I,X(I))); generate errors] and but other errors can enter. The example shorterr10.gms illustrates such errors under the use of the errmsg=1 option which repositions the error message explanatory text.
OBJT.. PROFIT=E= SUM(PROCESS,((PRICE(PROCESS)*yield(process) 25 -PRODCOST(PROCESS))*PRODUCTION(PROCESS)) ; **** $8 **** 8 ')' expected 26 AVAILABLE(RESOURCE).. SUM(PROCESS,RESOURUSE(RESOURCE,PROCESS) 27 *PRODUCTION(PROCESS))) =L= RESORAVAIL(RESOURCE); **** $37,408$409 **** 37 '=l=' or '=e=' or '=g=' operator expected **** 408 Too many ),] or } **** 409 Unrecognizable item - skip to find a new statement **** looking for a ';' or a key word to get started again 28 scalar x; 29 x=sum((resource,process),RESOURUSE(RESOURCE,PROCESS))); **** $408 **** 408 Too many ),] or } 30 x=sum((resource,process),(RESOURUSE(RESOURCE,PROCESS)); **** $8 **** 8 ')' expected
Two error prevention strategies are possible when dealing with parentheses.
x = sum( j, ABS ( TTS (j) ) );
can be restated as
x = sum[ j, ABS { TTS(j) } ];
Such a restatement would provide a visual basis for examining whether the parentheses were properly matched. It would also generate errors if one did not use the alternative parenthesis forms in the proper sequence. For example, the following statement would stimulate compiler errors:
x = sum[ j, ABS { TTS(j} ] );. |