📄 gram.in
字号:
| SSTAR intonlyon expr intonlyoff { expptr p; int typlen; p = $3; NO66("length specification *n"); if( ! ISICON(p) || p->constblock.const.ci<0 ) { $$ = 0; dclerr("- length must be a positive integer value", PNULL); } else if( dblflag ) { typlen = p->constblock.const.ci; if( vartype == TYDREAL && typlen == 4 ) $$ = 8; else if( vartype == TYDCOMPLEX && typlen == 8 ) $$ = 16; else $$ = typlen; } else $$ = p->constblock.const.ci; } | SSTAR intonlyon SLPAR SSTAR SRPAR intonlyoff { NO66("length specification *(*)"); $$ = -1; } ;common: SCOMMON in_dcl var { incomm( $$ = comblock(0, CNULL) , $3 ); } | SCOMMON in_dcl comblock var { $$ = $3; incomm($3, $4); } | common opt_comma comblock opt_comma var { $$ = $3; incomm($3, $5); } | common SCOMMA var { incomm($1, $3); } ;comblock: SCONCAT { $$ = comblock(0, CNULL); } | SSLASH SNAME SSLASH { $$ = comblock(toklen, token); } ;external: SEXTERNAL in_dcl name { setext($3); } | external SCOMMA name { setext($3); } ;intrinsic: SINTRINSIC in_dcl name { NO66("INTRINSIC statement"); setintr($3); } | intrinsic SCOMMA name { setintr($3); } ;equivalence: SEQUIV in_dcl equivset | equivalence SCOMMA equivset ;equivset: SLPAR equivlist SRPAR { struct Equivblock *p; if(nequiv >= maxequiv) many("equivalences", 'q'); if( !equivlisterr ) { p = & eqvclass[nequiv++]; p->eqvinit = NO; p->eqvbottom = 0; p->eqvtop = 0; p->equivs = $2; p->init = NO; p->initoffset = 0; } } ;equivlist: lhs { $$=ALLOC(Eqvchain); equivlisterr = 0; if( $1->tag == TCONST ) { equivlisterr = 1; dclerr( "- constant in equivalence", NULL ); } $$->eqvitem.eqvlhs = (struct Primblock *)$1; } | equivlist SCOMMA lhs { $$=ALLOC(Eqvchain); if( $3->tag == TCONST ) { equivlisterr = 1; dclerr( "constant in equivalence", NULL ); } $$->eqvitem.eqvlhs = (struct Primblock *) $3; $$->eqvnextp = $1; } ;savelist: saveitem | savelist SCOMMA saveitem ;saveitem: name { int k; $1->vsave = YES; k = $1->vstg; if( ! ONEOF(k, M(STGUNKNOWN)|M(STGBSS)|M(STGINIT)) || ($1->vclass == CLPARAM) ) dclerr("can only save static variables", $1); } | comblock { $1->extsave = 1; } ;paramlist: paramitem | paramlist SCOMMA paramitem ;paramitem: name SEQUALS expr { paramset( $1, $3 ); } ;var: name dims { if(ndim>0) setbound($1, ndim, dims); } ;dims: { ndim = 0; } | SLPAR dimlist SRPAR ;dimlist: { ndim = 0; } dim | dimlist SCOMMA dim ;dim: ubound { if(ndim == maxdim) err("too many dimensions"); else if(ndim < maxdim) { dims[ndim].lb = 0; dims[ndim].ub = $1; } ++ndim; } | expr SCOLON ubound { if(ndim == maxdim) err("too many dimensions"); else if(ndim < maxdim) { dims[ndim].lb = $1; dims[ndim].ub = $3; } ++ndim; } ;ubound: SSTAR { $$ = 0; } | expr ;labellist: label { nstars = 1; labarray[0] = $1; } | labellist SCOMMA label { if(nstars < MAXLABLIST) labarray[nstars++] = $3; } ;label: SICON { $$ = execlab( convci(toklen, token) ); } ;implicit: SIMPLICIT in_dcl implist { NO66("IMPLICIT statement"); } | implicit SCOMMA implist ;implist: imptype SLPAR letgroups SRPAR ;imptype: { needkwd = 1; } type { vartype = $2; } ;letgroups: letgroup | letgroups SCOMMA letgroup ;letgroup: letter { setimpl(vartype, varleng, $1, $1); } | letter SMINUS letter { setimpl(vartype, varleng, $1, $3); } ;letter: SNAME { if(toklen!=1 || token[0]<'a' || token[0]>'z') { dclerr("implicit item must be single letter", PNULL); $$ = 0; } else $$ = token[0]; } ;namelist: SNAMELIST | namelist namelistentry ;namelistentry: SSLASH name SSLASH namelistlist { if($2->vclass == CLUNKNOWN) { $2->vclass = CLNAMELIST; $2->vtype = TYINT; $2->vstg = STGINIT; $2->varxptr.namelist = $4; $2->vardesc.varno = ++lastvarno; } else dclerr("cannot be a namelist name", $2); } ;namelistlist: name { $$ = mkchain($1, CHNULL); } | namelistlist SCOMMA name { $$ = hookup($1, mkchain($3, CHNULL)); } ;in_dcl: { switch(parstate) { case OUTSIDE: newproc(); startproc(PNULL, CLMAIN); case INSIDE: parstate = INDCL; case INDCL: break; default: dclerr("declaration among executables", PNULL); } } ;data: data1 { if (overlapflag == YES) warn("overlapping initializations"); }data1: SDATA in_data datapair | data1 opt_comma datapair ;in_data: { if(parstate == OUTSIDE) { newproc(); startproc(PNULL, CLMAIN); } if(parstate < INDATA) { enddcl(); parstate = INDATA; } overlapflag = NO; } ;datapair: datalvals SSLASH datarvals SSLASH { savedata($1, $3); } ;datalvals: datalval { $$ = preplval(NULL, $1); } | datalvals SCOMMA datalval { $$ = preplval($1, $3); } ;datarvals: datarval | datarvals SCOMMA datarval { $3->next = $1; $$ = $3; } ;datalval: dataname { $$ = mkdlval($1, NULL, NULL); } | dataname datasubs { $$ = mkdlval($1, $2, NULL); } | dataname datarange { $$ = mkdlval($1, NULL, $2); } | dataname datasubs datarange { $$ = mkdlval($1, $2, $3); } | dataimplieddo ;dataname: SNAME { $$ = mkdname(toklen, token); } ;datasubs: SLPAR iconexprlist SRPAR { $$ = revvlist($2); } ;datarange: SLPAR opticonexpr SCOLON opticonexpr SRPAR { $$ = mkdrange($2, $4); } ;iconexprlist: iconexpr { $$ = prepvexpr(NULL, $1); } | iconexprlist SCOMMA iconexpr { $$ = prepvexpr($1, $3); } ;opticonexpr: { $$ = NULL; } | iconexpr { $$ = $1; } ;dataimplieddo: SLPAR dlist SCOMMA dataname SEQUALS iconexprlist SRPAR { $$ = mkdatado($2, $4, $6); } ;dlist: dataelt { $$ = preplval(NULL, $1); } | dlist SCOMMA dataelt { $$ = preplval($1, $3); } ;dataelt: dataname datasubs { $$ = mkdlval($1, $2, NULL); } | dataname datarange { $$ = mkdlval($1, NULL, $2); } | dataname datasubs datarange { $$ = mkdlval($1, $2, $3); } | dataimplieddo ;datarval: datavalue { static dvalue one = { DVALUE, NORMAL, 1 }; $$ = mkdrval(&one, $1); } | dataname SSTAR datavalue { $$ = mkdrval($1, $3); frvexpr($1); } | unsignedint SSTAR datavalue { $$ = mkdrval($1, $3); frvexpr($1); } ;datavalue: dataname { $$ = evparam($1); free((char *) $1); } | int_const { $$ = ivaltoicon($1); frvexpr($1); } | real_const | complex_const | STRUE { $$ = mklogcon(1); } | SFALSE { $$ = mklogcon(0); } | SHOLLERITH { $$ = mkstrcon(toklen, token); } | SSTRING { $$ = mkstrcon(toklen, token); } | bit_const ;int_const: unsignedint | SPLUS unsignedint { $$ = $2; } | SMINUS unsignedint { $$ = negival($2); frvexpr($2); } ;unsignedint: SICON { $$ = evicon(toklen, token); } ;real_const: unsignedreal | SPLUS unsignedreal { $$ = $2; } | SMINUS unsignedreal { consnegop($2); $$ = $2; } ;unsignedreal: SRCON { $$ = mkrealcon(TYREAL, convcd(toklen, token)); } | SDCON { $$ = mkrealcon(TYDREAL, convcd(toklen, token)); } ;bit_const: SHEXCON { $$ = mkbitcon(4, toklen, token); } | SOCTCON { $$ = mkbitcon(3, toklen, token); } | SBITCON { $$ = mkbitcon(1, toklen, token); } ;iconexpr: iconterm | SPLUS iconterm { $$ = $2; } | SMINUS iconterm { $$ = mkdexpr(OPNEG, NULL, $2); } | iconexpr SPLUS iconterm { $$ = mkdexpr(OPPLUS, $1, $3); } | iconexpr SMINUS iconterm { $$ = mkdexpr(OPMINUS, $1, $3); } ;iconterm: iconfactor | iconterm SSTAR iconfactor { $$ = mkdexpr(OPSTAR, $1, $3); } | iconterm SSLASH iconfactor { $$ = mkdexpr(OPSLASH, $1, $3); } ;iconfactor: iconprimary | iconprimary SPOWER iconfactor { $$ = mkdexpr(OPPOWER, $1, $3); } ;iconprimary: SICON { $$ = evicon(toklen, token); } | dataname | SLPAR iconexpr SRPAR { $$ = $2; } ;/** @(#)gram.expr 1.3 (ULTRIX) 1/15/86*//************************************************************************ * * * Copyright (c) 1986 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//************************************************************************** Modification History** David Metsky 14-Jan-86** 001 Replaced old version with BSD 4.3 version as part of upgrade.** Based on: gram.expr 5.1 6/7/85**************************************************************************//* * gram.expr * * Grammar for expressions, f77 compiler pass 1, 4.2 BSD. * * University of Utah CS Dept modification history: * * $Log: gram.expr,v $ * 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 * declarations. * */funarglist: { $$ = 0; } | funargs ;funargs: expr { $$ = mkchain($1, CHNULL); } | funargs SCOMMA expr { $$ = hookup($1, mkchain($3,CHNULL) ); } ;expr: uexpr | SLPAR expr SRPAR { if (parstate != INDCL) $$ = mkexpr(OPPAREN, $2, ENULL); else $$ = $2; } | complex_const ;uexpr: lhs | simple_const
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -