home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
forum7.lzh
/
C
/
VC
/
gram.c
< prev
next >
Wrap
Text File
|
1988-08-29
|
14KB
|
530 lines
# line 13 "gram.y"
#include "sc.h"
# line 16 "gram.y"
typedef union {
long ival;
double fval;
struct ent *ent;
struct enode *enode;
char *sval;
struct lnode *lnode;
} YYSTYPE;
# define STRING 257
# define NUMBER 258
# define FNUMBER 259
# define WORD 260
# define S_FORMAT 261
# define S_LABEL 262
# define S_LEFTSTRING 263
# define S_RIGHTSTRING 264
# define S_GET 265
# define S_PUT 266
# define S_MERGE 267
# define S_LET 268
# define S_WRITE 269
# define S_TBL 270
# define S_PROGLET 271
# define K_EXEC 272
# define K_FIXED 273
# define K_ABS 274
# define K_ACOS 275
# define K_ASIN 276
# define K_ATAN 277
# define K_CEIL 278
# define K_COS 279
# define K_EXP 280
# define K_FLOOR 281
# define K_HYPOT 282
# define K_LN 283
# define K_LOG 284
# define K_SIN 285
# define K_SQRT 286
# define K_TAN 287
# define K_R 288
# define K_C 289
#define yyclearin yychar = -1
#define yyerrok yyerrflag = 0
extern int yychar;
extern short yyerrflag;
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 150
#endif
YYSTYPE yylval, yyval;
# define YYERRCODE 256
short yyexca[] ={
-1, 1,
0, -1,
-2, 0,
-1, 94,
60, 0,
61, 0,
62, 0,
-2, 35,
-1, 96,
60, 0,
61, 0,
62, 0,
-2, 36,
-1, 97,
60, 0,
61, 0,
62, 0,
-2, 37,
-1, 107,
60, 0,
61, 0,
62, 0,
-2, 40,
-1, 108,
60, 0,
61, 0,
62, 0,
-2, 42,
-1, 109,
60, 0,
61, 0,
62, 0,
-2, 41,
};
#define YYNPROD 63
#define YYLAST 353
short yyact[]={
49, 16, 17, 17, 16, 68, 35, 43, 12, 64,
44, 31, 45, 6, 3, 4, 5, 7, 9, 8,
2, 10, 11, 30, 21, 103, 67, 66, 65, 26,
25, 24, 49, 23, 22, 115, 101, 34, 79, 43,
33, 64, 44, 77, 45, 32, 110, 71, 69, 27,
70, 112, 72, 83, 120, 111, 81, 119, 80, 79,
98, 1, 14, 79, 49, 74, 75, 76, 73, 38,
79, 43, 71, 64, 44, 77, 45, 72, 29, 71,
69, 42, 70, 40, 72, 114, 13, 18, 19, 20,
0, 0, 95, 48, 0, 106, 49, 74, 75, 76,
73, 0, 15, 43, 79, 64, 44, 116, 45, 77,
79, 0, 105, 71, 69, 77, 70, 28, 72, 71,
69, 0, 70, 0, 72, 48, 0, 0, 0, 78,
0, 74, 75, 76, 73, 36, 79, 74, 75, 76,
73, 77, 0, 0, 79, 71, 69, 0, 70, 77,
72, 84, 0, 71, 69, 121, 70, 48, 72, 0,
0, 78, 0, 74, 75, 76, 37, 104, 0, 0,
0, 74, 75, 76, 0, 0, 0, 89, 90, 91,
92, 93, 94, 96, 97, 99, 100, 0, 102, 48,
79, 0, 0, 0, 0, 78, 118, 0, 0, 71,
69, 78, 70, 107, 72, 0, 108, 0, 82, 109,
0, 85, 86, 0, 113, 87, 88, 74, 75, 76,
79, 0, 0, 0, 117, 46, 47, 78, 0, 71,
69, 0, 70, 0, 72, 0, 0, 0, 0, 39,
41, 50, 51, 52, 53, 54, 55, 56, 57, 58,
59, 60, 61, 62, 63, 16, 17, 46, 47, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 39, 41, 50, 51, 52, 53, 54, 55, 56,
57, 58, 59, 60, 61, 62, 63, 16, 17, 46,
47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 39, 41, 50, 51, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, 62, 63, 16,
17, 46, 47, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 39, 41, 50, 51, 52,
53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
63, 16, 17 };
short yypact[]={
-248,-1000,-287,-287,-287,-287,-234,-223,-224,-226,
-227,-228,-1000, -12,-286,-284,-235,-247, -16, -21,
-24,-252,-1000,-1000,-1000,-1000,-1000, 63,-1000,-1000,
-1000,-1000,-229,-230,-231,-253, 77,-1000, 18, 16,
-1000, 63, 6, 63, 63, 63,-1000,-1000, 63, 63,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000, 63,
63, 63, 63, 63, 31, 63, -1, 63, 63, -25,
63,-232,-1000,-287, 71,-1000,-1000,-1000,-1000, 30,
30, 26, 26, 37, 187, 63, 187, 187, 63, 157,
111, 63, 5, 11, -7,-1000, 63, 187, 187, 187,
-1000, -33,-287, 103, 13,-1000, 77,-1000,-1000, -33,
-1000,-1000 };
short yypgo[]={
0, 85, 107, 166, 35, 83, 62, 102, 81, 69,
61 };
short yyr1[]={
0, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 1, 1, 4, 4, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 6, 7, 5, 5, 8, 8, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9 };
short yyr2[]={
0, 4, 4, 4, 4, 4, 2, 2, 2, 2,
2, 0, 1, 3, 1, 1, 1, 4, 6, 1,
2, 5, 3, 2, 2, 1, 1, 2, 2, 3,
3, 3, 3, 1, 5, 3, 3, 3, 3, 3,
4, 4, 4, 2, 2, 2, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1 };
short yychk[]={
-1000, -10, 268, 262, 263, 264, 261, 265, 267, 266,
269, 270, 256, -5, -6, -7, 288, 289, -5, -5,
-5, 258, 257, 257, 257, 257, 257, 61, -7, -6,
258, 258, 61, 61, 61, 258, -2, -3, -9, 272,
-5, 273, -8, 40, 43, 45, 258, 259, 126, 33,
274, 275, 276, 277, 278, 279, 280, 281, 282, 283,
284, 285, 286, 287, 42, 257, 257, 257, 258, 43,
45, 42, 47, 63, 60, 61, 62, 38, 124, 33,
40, 40, -3, 47, -2, -3, -3, -3, -3, -2,
-2, -2, -2, -2, -2, 61, -2, -2, 61, -2,
-2, 61, -2, 257, -5, 41, 58, -2, -2, -2,
41, 44, 58, -2, -1, -4, -2, 257, -5, 44,
41, -4 };
short yydef[]={
11, -2, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 12, 0, 0, 0, 0, 0, 0, 0,
0, 0, 6, 7, 8, 9, 10, 0, 45, 46,
43, 44, 0, 0, 0, 0, 1, 33, 0, 0,
19, 0, 0, 0, 47, 0, 25, 26, 0, 0,
49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
59, 60, 61, 62, 48, 2, 3, 4, 5, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 20, 0, 0, 23, 24, 27, 28, 29,
30, 31, 32, 0, -2, 0, -2, -2, 0, 38,
39, 0, 0, 0, 0, 22, 0, -2, -2, -2,
17, 0, 0, 34, 0, 14, 15, 16, 21, 0,
18, 13 };
#ifndef lint
static char yaccpar_sccsid[] = "@(#)yaccpar 4.1 (Berkeley) 2/11/83";
#endif not lint
#define YYFLAG -1000
#define YYERROR goto yyerrlab
#define YYACCEPT return(0)
#define YYABORT return(1)
/* parser for yacc output */
#ifdef YYDEBUG
int yydebug = 0; /* 1 for debugging */
#endif
YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
int yychar = -1; /* current input token number */
int yynerrs = 0; /* number of errors */
short yyerrflag = 0; /* error recovery flag */
yyparse() {
short yys[YYMAXDEPTH];
short yyj, yym;
register YYSTYPE *yypvt;
register short yystate, *yyps, yyn;
register YYSTYPE *yypv;
register short *yyxi;
yystate = 0;
yychar = -1;
yynerrs = 0;
yyerrflag = 0;
yyps= &yys[-1];
yypv= &yyv[-1];
yystack: /* put a state and value onto the stack */
#ifdef YYDEBUG
if( yydebug ) printf( "state %d, char 0%o\n", yystate, yychar );
#endif
if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
*yyps = yystate;
++yypv;
*yypv = yyval;
yynewstate:
yyn = yypact[yystate];
if( yyn<= YYFLAG ) goto yydefault; /* simple state */
if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
yychar = -1;
yyval = yylval;
yystate = yyn;
if( yyerrflag > 0 ) --yyerrflag;
goto yystack;
}
yydefault:
/* default state action */
if( (yyn=yydef[yystate]) == -2 ) {
if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
/* look through exception table */
for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
while( *(yyxi+=2) >= 0 ){
if( *yyxi == yychar ) break;
}
if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */
}
if( yyn == 0 ){ /* error */
/* error ... attempt to resume parsing */
switch( yyerrflag ){
case 0: /* brand new error */
yyerror( "syntax error" );
yyerrlab:
++yynerrs;
case 1:
case 2: /* incompletely recovered error ... try again */
yyerrflag = 3;
/* find a state where "error" is a legal shift action */
while ( yyps >= yys ) {
yyn = yypact[*yyps] + YYERRCODE;
if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
yystate = yyact[yyn]; /* simulate a shift of "error" */
goto yystack;
}
yyn = yypact[*yyps];
/* the current yyps has no shift onn "error", pop stack */
#ifdef YYDEBUG
if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
#endif
--yyps;
--yypv;
}
/* there is no state on the stack with an error shift ... abort */
yyabort:
return(1);
case 3: /* no shift yet; clobber input char */
#ifdef YYDEBUG
if( yydebug ) printf( "error recovery discards char %d\n", yychar );
#endif
if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
yychar = -1;
goto yynewstate; /* try again in the same state */
}
}
/* reduction by production yyn */
#ifdef YYDEBUG
if( yydebug ) printf("reduce %d\n",yyn);
#endif
yyps -= yyr2[yyn];
yypvt = yypv;
yypv -= yyr2[yyn];
yyval = yypv[1];
yym=yyn;
/* consult goto table to find next state */
yyn = yyr1[yyn];
yyj = yypgo[yyn] + *yyps + 1;
if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
switch(yym){
case 1:
# line 73 "gram.y"
{ let (yypvt[-2].ent, yypvt[-0].enode); } break;
case 2:
# line 75 "gram.y"
{ label (yypvt[-2].ent, yypvt[-0].sval, 0); } break;
case 3:
# line 77 "gram.y"
{ label (yypvt[-2].ent, yypvt[-0].sval, -1); } break;
case 4:
# line 79 "gram.y"
{ label (yypvt[-2].ent, yypvt[-0].sval, 1); } break;
case 5:
# line 81 "gram.y"
{ fwidth[yypvt[-2].ival] = yypvt[-1].ival;
FullUpdate++;
modflg++;
precision[yypvt[-2].ival] = yypvt[-0].ival; } break;
case 6:
# line 85 "gram.y"
{ readfile (yypvt[-0].sval,1); } break;
case 7:
# line 86 "gram.y"
{ readfile (yypvt[-0].sval,0); } break;
case 8:
# line 87 "gram.y"
{ writefile (yypvt[-0].sval); } break;
case 9:
# line 88 "gram.y"
{ printfile (yypvt[-0].sval); } break;
case 10:
# line 89 "gram.y"
{ tblprintfile (yypvt[-0].sval); } break;
case 13:
# line 93 "gram.y"
{ yyval.lnode = addlist( yypvt[-2].lnode , yypvt[-0].enode ) ; } break;
case 14:
# line 94 "gram.y"
{ yyval.lnode = newlist( yypvt[-0].enode ); } break;
case 15:
# line 97 "gram.y"
{ yyval.enode = yypvt[-0].enode; } break;
case 16:
# line 98 "gram.y"
{ yyval.enode = new ('s' , yypvt[-0].sval , 0 ); } break;
case 17:
# line 102 "gram.y"
{ yyval.enode = new (yypvt[-3].ival, yypvt[-1].enode, 0); } break;
case 18:
# line 103 "gram.y"
{ yyval.enode = new('p', yypvt[-3].sval, yypvt[-1].lnode); } break;
case 19:
# line 104 "gram.y"
{ yyval.enode = new ('v', yypvt[-0].ent); } break;
case 20:
# line 105 "gram.y"
{ yyval.enode = new ('f', 0, yypvt[-0].enode); } break;
case 21:
# line 107 "gram.y"
{ yyval.enode = new (O_REDUCE(yypvt[-4].ival), yypvt[-2].ent, yypvt[-0].ent); } break;
case 22:
# line 108 "gram.y"
{ yyval.enode = yypvt[-1].enode; } break;
case 23:
# line 109 "gram.y"
{ yyval.enode = yypvt[-0].enode; } break;
case 24:
# line 110 "gram.y"
{ yyval.enode = new ('m', 0, yypvt[-0].enode); } break;
case 25:
# line 111 "gram.y"
{ double h= (double)yypvt[-0].ival; yyval.enode = new ('k', &h, 0); } break;
case 26:
# line 112 "gram.y"
{ yyval.enode = new ('k', &yypvt[-0].fval, 0); } break;
case 27:
# line 113 "gram.y"
{ yyval.enode = new ('~', 0, yypvt[-0].enode); } break;
case 28:
# line 114 "gram.y"
{ yyval.enode = new ('~', 0, yypvt[-0].enode); } break;
case 29:
# line 117 "gram.y"
{ yyval.enode = new ('+', yypvt[-2].enode, yypvt[-0].enode); } break;
case 30:
# line 118 "gram.y"
{ yyval.enode = new ('-', yypvt[-2].enode, yypvt[-0].enode); } break;
case 31:
# line 119 "gram.y"
{ yyval.enode = new ('*', yypvt[-2].enode, yypvt[-0].enode); } break;
case 32:
# line 120 "gram.y"
{ yyval.enode = new ('/', yypvt[-2].enode, yypvt[-0].enode); } break;
case 34:
# line 122 "gram.y"
{ yyval.enode = new ('?', yypvt[-4].enode, new(':', yypvt[-2].enode, yypvt[-0].enode)); } break;
case 35:
# line 123 "gram.y"
{ yyval.enode = new ('<', yypvt[-2].enode, yypvt[-0].enode); } break;
case 36:
# line 124 "gram.y"
{ yyval.enode = new ('=', yypvt[-2].enode, yypvt[-0].enode); } break;
case 37:
# line 125 "gram.y"
{ yyval.enode = new ('>', yypvt[-2].enode, yypvt[-0].enode); } break;
case 38:
# line 126 "gram.y"
{ yyval.enode = new ('&', yypvt[-2].enode, yypvt[-0].enode); } break;
case 39:
# line 127 "gram.y"
{ yyval.enode = new ('|', yypvt[-2].enode, yypvt[-0].enode); } break;
case 40:
# line 128 "gram.y"
{ yyval.enode = new ('~', 0, new ('>', yypvt[-3].enode, yypvt[-0].enode)); } break;
case 41:
# line 129 "gram.y"
{ yyval.enode = new ('~', 0, new ('=', yypvt[-3].enode, yypvt[-0].enode)); } break;
case 42:
# line 130 "gram.y"
{ yyval.enode = new ('~', 0, new ('<', yypvt[-3].enode, yypvt[-0].enode)); } break;
case 43:
# line 133 "gram.y"
{ yyval.ival = yypvt[-0].ival; } break;
case 44:
# line 134 "gram.y"
{ yyval.ival = yypvt[-0].ival; } break;
case 45:
# line 135 "gram.y"
{ yyval.ent = lookat(yypvt[-1].ival, yypvt[-0].ival); } break;
case 46:
# line 136 "gram.y"
{ yyval.ent = lookat(yypvt[-0].ival, yypvt[-1].ival); } break;
case 47:
# line 138 "gram.y"
{ yyval.ival = '+'; } break;
case 48:
# line 139 "gram.y"
{ yyval.ival = '*'; } break;
case 49:
# line 143 "gram.y"
{ yyval.ival = K_ABS; } break;
case 50:
# line 144 "gram.y"
{ yyval.ival = K_ACOS; } break;
case 51:
# line 145 "gram.y"
{ yyval.ival = K_ASIN; } break;
case 52:
# line 146 "gram.y"
{ yyval.ival = K_ATAN; } break;
case 53:
# line 147 "gram.y"
{ yyval.ival = K_CEIL; } break;
case 54:
# line 148 "gram.y"
{ yyval.ival = K_COS; } break;
case 55:
# line 149 "gram.y"
{ yyval.ival = K_EXP; } break;
case 56:
# line 150 "gram.y"
{ yyval.ival = K_FLOOR; } break;
case 57:
# line 151 "gram.y"
{ yyval.ival = K_HYPOT; } break;
case 58:
# line 152 "gram.y"
{ yyval.ival = K_LN; } break;
case 59:
# line 153 "gram.y"
{ yyval.ival = K_LOG; } break;
case 60:
# line 154 "gram.y"
{ yyval.ival = K_SIN; } break;
case 61:
# line 155 "gram.y"
{ yyval.ival = K_SQRT; } break;
case 62:
# line 156 "gram.y"
{ yyval.ival = K_TAN; } break;
}
goto yystack; /* stack new state and value */
}