* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* @(#)gram.expr 5.2 (Berkeley) 1/7/86
* Grammar for expressions, f77 compiler pass 1, 4.2 BSD.
* University of Utah CS Dept modification history:
* Revision 5.2 85/12/21 07:26:39 donn
* Permit CHARACTER*(4) in function declarations by eliminating parentheses
* Revision 5.1 85/08/10 03:47:25 donn
* Revision 3.2 85/02/15 19:08:53 donn
* Put OPPAREN operators in trees when not optimizing as well as when
* optimizing -- this allows '(1)' to produce a writable temporary instead
* of a read-only constant when passed as an argument to a subroutine.
* Revision 3.1 84/10/13 00:42:08 donn
* Installed Jerry Berkman's version with cosmetic changes.
* Revision 1.2 84/08/04 21:27:05 donn
* Added Jerry Berkman's fix to stop complaints about parentheses in
{ $$ = mkchain($1, CHNULL); }
{ $$ = hookup($1, mkchain($3,CHNULL) ); }
$$ = mkexpr(OPPAREN, $2, ENULL);
| expr addop expr %prec SPLUS
{ $$ = mkexpr($2, $1, $3); }
{ $$ = mkexpr(OPSTAR, $1, $3); }
{ $$ = mkexpr(OPSLASH, $1, $3); }
{ $$ = mkexpr(OPPOWER, $1, $3); }
$$ = mkexpr(OPNEG, $2, ENULL);
| expr relop expr %prec SEQ
{ $$ = mkexpr($2, $1, $3); }
{ NO66(".EQV. operator");
$$ = mkexpr(OPEQV, $1,$3); }
{ NO66(".NEQV. operator");
$$ = mkexpr(OPNEQV, $1, $3); }
{ $$ = mkexpr(OPOR, $1, $3); }
{ $$ = mkexpr(OPAND, $1, $3); }
{ $$ = mkexpr(OPNOT, $2, ENULL); }
{ NO66("concatenation operator //");
$$ = mkexpr(OPCONCAT, $1, $3); }
addop: SPLUS { $$ = OPPLUS; }
| SMINUS { $$ = OPMINUS; }
relop: SEQ { $$ = OPEQ; }
{ $$ = mkprim($1, PNULL, CHNULL); }
{ NO66("substring operator :");
if( $1->vclass != CLPARAM ) {
$$ = mkprim($1, PNULL, $2);
errstr("substring of parameter %s",
varstr(VL,$1->varname) );
| name SLPAR funarglist SRPAR
{ if( $1->vclass != CLPARAM ) {
$$ = mkprim($1, mklist($3), CHNULL);
errstr("can not subscript parameter %s",
varstr(VL,$1->varname) );
| name SLPAR funarglist SRPAR substring
{ if( $1->vclass != CLPARAM ) {
NO66("substring operator :");
$$ = mkprim($1, mklist($3), $5);
errstr("can not subscript parameter %s",
varstr(VL,$1->varname) );
substring: SLPAR opt_expr SCOLON opt_expr SRPAR
{ $$ = mkchain($2, mkchain($4,CHNULL)); }
simple_const: STRUE { $$ = mklogcon(1); }
| SFALSE { $$ = mklogcon(0); }
| SHOLLERITH { $$ = mkstrcon(toklen, token); }
| SICON = { $$ = mkintcon( convci(toklen, token) ); }
| SRCON = { $$ = mkrealcon(TYREAL, convcd(toklen, token)); }
| SDCON = { $$ = mkrealcon(TYDREAL, convcd(toklen, token)); }
complex_const: SLPAR uexpr SCOMMA uexpr SRPAR
{ if (optimflag && parstate > INDCL)
$$ = mkexpr(OPPAREN, $2, ENULL);
| fexpr addop fexpr %prec SPLUS
{ $$ = mkexpr($2, $1, $3); }
{ $$ = mkexpr(OPSTAR, $1, $3); }
{ $$ = mkexpr(OPSLASH, $1, $3); }
{ $$ = mkexpr(OPPOWER, $1, $3); }
| addop fexpr %prec SSTAR
$$ = mkexpr(OPNEG, $2, ENULL);
{ NO66("concatenation operator //");
$$ = mkexpr(OPCONCAT, $1, $3); }