page@swan.ulowell.edu (Bob Page) (11/05/88)
Submitted-by: finkel@taurus.bitnet (Udi Finkelstein) Posting-number: Volume 2, Issue 55 Archive-name: languages/cdecl.2 # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # cdgram.c # cdlex.c # cdecl.notes # This archive created: Fri Nov 4 18:01:31 1988 cat << \SHAR_EOF > cdgram.c /* Yacc grammar for ANSI and C++ cdecl. */ /* The output of this file is included */ /* into the C file cdecl.c. */ char cdgramsccsid[] = "@(#)cdgram.y 2.2 3/30/88"; typedef union { char *dynstr; struct { char *left; char *right; char *type; } halves; } YYSTYPE; # define ARRAY 257 # define AS 258 # define CAST 259 # define COMMA 260 # define DECLARE 261 # define DOUBLECOLON 262 # define EXPLAIN 263 # define FUNCTION 264 # define HELP 265 # define INTO 266 # define OF 267 # define MEMBER 268 # define POINTER 269 # define REFERENCE 270 # define RETURNING 271 # define SET 272 # define TO 273 # define CHAR 274 # define CLASS 275 # define CONSTVOLATILE 276 # define DOUBLE 277 # define ENUM 278 # define FLOAT 279 # define INT 280 # define LONG 281 # define NAME 282 # define NUMBER 283 # define SHORT 284 # define SIGNED 285 # define STRUCT 286 # define UNION 287 # define UNSIGNED 288 # define VOID 289 # define AUTO 290 # define EXTERN 291 # define REGISTER 292 # define STATIC 293 #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, 27, 282, 81, 40, 81, 42, 81, 38, 81, -2, 87, -1, 37, 260, 31, 41, 31, -2, 81, -1, 87, 282, 82, 40, 82, 42, 82, 38, 82, -2, 80, -1, 92, 260, 31, 41, 31, -2, 81, }; # define YYNPROD 89 # define YYLAST 322 short yyact[]={ 67, 79, 28, 69, 72, 68, 66, 76, 159, 13, 77, 75, 78, 73, 74, 70, 79, 16, 17, 18, 19, 16, 17, 18, 19, 67, 129, 78, 69, 103, 68, 66, 125, 25, 76, 39, 23, 77, 75, 128, 70, 74, 118, 22, 115, 137, 117, 118, 85, 115, 86, 117, 83, 23, 152, 25, 30, 100, 23, 10, 22, 56, 25, 23, 47, 22, 60, 59, 37, 97, 22, 121, 25, 40, 41, 123, 58, 25, 20, 34, 139, 110, 25, 161, 144, 93, 145, 92, 94, 32, 24, 57, 147, 71, 126, 29, 81, 21, 42, 55, 8, 136, 108, 150, 12, 135, 33, 106, 11, 114, 31, 10, 62, 151, 132, 134, 44, 45, 48, 49, 156, 43, 35, 2, 63, 15, 53, 1, 54, 14, 50, 64, 27, 65, 52, 101, 26, 46, 87, 82, 61, 38, 0, 90, 80, 88, 0, 0, 89, 0, 95, 96, 98, 108, 91, 108, 0, 0, 108, 0, 11, 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 0, 111, 104, 102, 0, 0, 0, 105, 112, 107, 0, 122, 99, 0, 113, 0, 119, 120, 0, 0, 0, 0, 127, 0, 0, 0, 0, 0, 0, 0, 124, 131, 0, 133, 0, 0, 0, 0, 142, 0, 0, 130, 143, 0, 0, 0, 0, 0, 0, 0, 138, 146, 140, 141, 148, 0, 149, 0, 0, 0, 0, 127, 0, 0, 0, 153, 0, 0, 25, 158, 0, 0, 127, 0, 128, 155, 160, 16, 17, 18, 19, 154, 0, 0, 0, 0, 157, 0, 0, 0, 0, 0, 25, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 116, 0, 0, 0, 0, 116, 84, 0, 0, 0, 0, 0, 0, 36, 0, 0, 145, 145, 92, 9, 0, 0, 5, 0, 4, 0, 6, 0, 3, 0, 0, 0, 0, 0, 0, 7 }; short yypact[]={ -1000, 49,-1000, 101,-273,-204, -38,-226,-1000, 101, -1000,-1000,-1000,-169,-194,-1000,-1000,-1000,-1000,-1000, -187, 101, 28,-248,-196,-214,-212,-214,-214, 101, -1000,-1000,-269, 101,-194,-1000,-194,-221,-191,-1000, -206,-207,-1000,-274,-1000,-1000, 10,-214, 10,-1000, -1000,-194,-1000, 101,-1000, 44,-170,-1000,-194,-199, -194,-1000,-249,-1000,-225,-247,-1000,-1000,-1000,-1000, -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000, 10, 101, 67,-214,-181,-214, 10,-1000, 101, 9, 101,-1000,-221,-200,-194,-1000,-1000,-192,-1000,-1000, -1000,-1000,-1000,-1000, 101,-1000, -9,-1000, -67, 10, 72, 10, 74,-1000, 64, 4,-182, 9, 9,-1000, -173,-194,-1000,-259,-1000,-1000, 43,-1000,-1000,-1000, -1,-1000, 10,-1000,-1000,-226,-1000,-1000, 62, 71, 11, 11,-1000,-228,-1000,-243, 9,-1000,-1000, 101, 80, 9,-194,-174, 11,-1000, -33, 11,-1000,-1000, 42,-1000 }; short yypgo[]={ 0, 99, 141, 140, 109, 94, 96, 139, 101, 137, 93, 112, 135, 133, 90, 95, 129, 125, 131, 124, 98, 91, 127, 123, 100, 121 }; short yyr1[]={ 0, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 15, 15, 6, 6, 6, 6, 7, 7, 7, 7, 7, 5, 5, 5, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 21, 21, 21, 21, 21, 21, 21, 2, 2, 20, 25, 3, 3, 3, 3, 18, 18, 18, 10, 10, 19, 19, 19, 19, 19, 11, 11, 12, 12, 13, 13, 13, 13, 14, 14, 9, 17, 17, 17, 17, 16, 16 }; short yyr2[]={ 0, 0, 2, 2, 6, 4, 5, 3, 6, 5, 5, 8, 3, 1, 2, 1, 1, 1, 0, 1, 3, 4, 3, 3, 4, 2, 3, 1, 3, 3, 1, 0, 3, 1, 1, 3, 0, 2, 5, 6, 3, 4, 2, 2, 2, 2, 3, 3, 6, 4, 4, 8, 4, 2, 0, 1, 2, 0, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 0, 2, 1, 1, 1, 1, 1, 0 }; short yychk[]={ -1000, -22, -23, 265, 261, 259, 263, 272, -24, 256, 10, 59, -24, 282, -16, -17, 290, 291, 292, 293, 282, -21, 264, 257, -14, 276, -16, -17, 40, -15, 282, -24, 258, -21, 266, -24, 271, 40, -2, 283, 269, 270, -20, -25, -14, -14, -9, 276, -14, -14, -24, -16, -24, -21, -21, -1, 282, -21, 267, 273, 273, -3, -11, -19, -18, -13, 280, 274, 279, 277, 289, -10, 278, 287, 288, 285, 281, 284, 286, 275, -20, -6, -7, 42, 282, 38, 40, -14, -6, -20, -21, -24, 260, 41, 258, -21, -21, 268, -21, -19, 282, -12, -11, 276, -6, -24, 40, -8, 91, -14, 262, -14, -6, -24, -4, 40, 282, 42, 38, -24, -1, 271, -21, 267, -24, 41, -5, -14, 282, 93, 283, -6, 42, -6, 41, 41, -8, 41, -4, 262, -4, -4, -21, -10, 41, 260, -20, 93, -6, -15, 41, 42, 282, -5, -4, -24, 40, -4, -21, 41, -5, 41 }; short yydef[]={ 1, -2, 2, 0, 88, 81, 88, 18, 13, 0, 15, 16, 3, 0, 81, 87, 83, 84, 85, 86, 0, 0, 0, 54, 57, 81, 81, -2, 81, 0, 17, 14, 88, 0, 81, 7, 81, -2, 0, 55, 0, 0, 53, 0, 80, 57, 0, 81, 0, 57, 12, 81, 5, 0, 47, 0, 33, 34, 81, 81, 81, 56, 58, 59, 0, 73, 67, 68, 69, 70, 71, 62, 63, 64, 76, 77, 78, 79, 65, 66, 0, 0, 19, 81, 27, 81, 0, -2, 0, 36, 0, 6, -2, 0, 81, 49, 50, 0, 52, 60, 61, 72, 74, 75, 0, 10, 81, 25, 0, 0, 0, 0, 0, 9, 0, 36, 0, 36, 36, 4, 32, 81, 35, 0, 8, 23, 0, 57, 30, 45, 0, 20, 0, 22, 26, 18, 44, 37, 0, 0, 42, 43, 48, 0, 24, 81, 36, 46, 21, 0, 40, 36, 81, 28, 29, 11, 81, 41, 51, 38, 0, 39 }; #ifndef lint static char yaccpar_sccsid[] = "@(#)yaccpar 1.2 86/07/18 SMI"; /* from UCB 4.1 83/02/11 */ #endif # # 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 2: { prompt(); prev = 0; } break; case 3: { Debug((stderr, "stmt: help\n")); dohelp(); } break; case 4: { Debug((stderr, "stmt: DECLARE NAME AS opt_storage adecl\n")); Debug((stderr, "\tNAME='%s'\n", yypvt[-4].dynstr)); Debug((stderr, "\topt_storage='%s'\n", yypvt[-2].dynstr)); Debug((stderr, "\tacdecl.left='%s'\n", yypvt[-1].halves.left)); Debug((stderr, "\tacdecl.right='%s'\n", yypvt[-1].halves.right)); Debug((stderr, "\tacdecl.type='%s'\n", yypvt[-1].halves.type)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); dodeclare(yypvt[-4].dynstr, yypvt[-2].dynstr, yypvt[-1].halves.left, yypvt[-1].halves.right, yypvt[-1].halves.type); } break; case 5: { Debug((stderr, "stmt: DECLARE opt_storage adecl\n")); Debug((stderr, "\topt_storage='%s'\n", yypvt[-2].dynstr)); Debug((stderr, "\tacdecl.left='%s'\n", yypvt[-1].halves.left)); Debug((stderr, "\tacdecl.right='%s'\n", yypvt[-1].halves.right)); Debug((stderr, "\tacdecl.type='%s'\n", yypvt[-1].halves.type)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); dodeclare(NullCP, yypvt[-2].dynstr, yypvt[-1].halves.left, yypvt[-1].halves.right, yypvt[-1].halves.type); } break; case 6: { Debug((stderr, "stmt: CAST NAME AS adecl\n")); Debug((stderr, "\tNAME='%s'\n", yypvt[-3].dynstr)); Debug((stderr, "\tacdecl.left='%s'\n", yypvt[-1].halves.left)); Debug((stderr, "\tacdecl.right='%s'\n", yypvt[-1].halves.right)); Debug((stderr, "\tacdecl.type='%s'\n", yypvt[-1].halves.type)); docast(yypvt[-3].dynstr, yypvt[-1].halves.left, yypvt[-1].halves.right, yypvt[-1].halves.type); } break; case 7: { Debug((stderr, "stmt: CAST adecl\n")); Debug((stderr, "\tacdecl.left='%s'\n", yypvt[-1].halves.left)); Debug((stderr, "\tacdecl.right='%s'\n", yypvt[-1].halves.right)); Debug((stderr, "\tacdecl.type='%s'\n", yypvt[-1].halves.type)); docast(NullCP, yypvt[-1].halves.left, yypvt[-1].halves.right, yypvt[-1].halves.type); } break; case 8: { Debug((stderr, "stmt: EXPLAIN opt_storage opt_constvol_list type cdecl\n")); Debug((stderr, "\topt_storage='%s'\n", yypvt[-4].dynstr)); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-3].dynstr)); Debug((stderr, "\ttype='%s'\n", yypvt[-2].dynstr)); Debug((stderr, "\tcdecl='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); dodexplain(yypvt[-4].dynstr, yypvt[-3].dynstr, yypvt[-2].dynstr, yypvt[-1].dynstr); } break; case 9: { Debug((stderr, "stmt: EXPLAIN storage opt_constvol_list cdecl\n")); Debug((stderr, "\tstorage='%s'\n", yypvt[-3].dynstr)); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-2].dynstr)); Debug((stderr, "\tcdecl='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); dodexplain(yypvt[-3].dynstr, yypvt[-2].dynstr, NullCP, yypvt[-1].dynstr); } break; case 10: { Debug((stderr, "stmt: EXPLAIN opt_storage constvol_list cdecl\n")); Debug((stderr, "\topt_storage='%s'\n", yypvt[-3].dynstr)); Debug((stderr, "\tconstvol_list='%s'\n", yypvt[-2].dynstr)); Debug((stderr, "\tcdecl='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); dodexplain(yypvt[-3].dynstr, yypvt[-2].dynstr, NullCP, yypvt[-1].dynstr); } break; case 11: { Debug((stderr, "stmt: EXPLAIN ( opt_constvol_list type cast ) optNAME\n")); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-5].dynstr)); Debug((stderr, "\ttype='%s'\n", yypvt[-4].dynstr)); Debug((stderr, "\tcast='%s'\n", yypvt[-3].dynstr)); Debug((stderr, "\tNAME='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); docexplain(yypvt[-5].dynstr, yypvt[-4].dynstr, yypvt[-3].dynstr, yypvt[-1].dynstr); } break; case 12: { Debug((stderr, "stmt: SET optNAME\n")); Debug((stderr, "\toptNAME='%s'\n", yypvt[-1].dynstr)); doset(yypvt[-1].dynstr); } break; case 14: { yyerrok; } break; case 15: { doprompt(); } break; case 16: { noprompt(); } break; case 17: { Debug((stderr, "optNAME: NAME\n")); Debug((stderr, "\tNAME='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = yypvt[-0].dynstr; } break; case 18: { Debug((stderr, "optNAME: EMPTY\n")); yyval.dynstr = ds(unknown_name); } break; case 20: { Debug((stderr, "cdecl: * opt_constvol_list cdecl\n")); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tcdecl='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = cat(yypvt[-0].dynstr,yypvt[-1].dynstr,ds(strlen(yypvt[-1].dynstr)?" pointer to ":"pointer to "),NullCP); prev = 'p'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 21: { Debug((stderr, "cdecl: NAME DOUBLECOLON '*' cdecl\n")); Debug((stderr, "\tNAME='%s'\n", yypvt[-3].dynstr)); Debug((stderr, "\tcdecl='%s'\n", yypvt[-0].dynstr)); if (!CplusplusFlag) unsupp("pointer to member of class", NullCP); yyval.dynstr = cat(yypvt[-0].dynstr,ds("pointer to member of class "),yypvt[-3].dynstr,ds(" "),NullCP); prev = 'p'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 22: { Debug((stderr, "cdecl: & opt_constvol_list cdecl\n")); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tcdecl='%s'\n", yypvt[-0].dynstr)); if (!CplusplusFlag) unsupp("reference", NullCP); yyval.dynstr = cat(yypvt[-0].dynstr,yypvt[-1].dynstr,ds(strlen(yypvt[-1].dynstr)?" reference to ":"reference to "),NullCP); prev = 'r'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 23: { Debug((stderr, "cdecl1: cdecl1()\n")); Debug((stderr, "\tcdecl1='%s'\n", yypvt[-2].dynstr)); yyval.dynstr = cat(yypvt[-2].dynstr,ds("function returning "),NullCP); prev = 'f'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 24: { Debug((stderr, "cdecl1: cdecl1(castlist)\n")); Debug((stderr, "\tcdecl1='%s'\n", yypvt[-3].dynstr)); Debug((stderr, "\tcastlist='%s'\n", yypvt[-1].dynstr)); yyval.dynstr = cat(yypvt[-3].dynstr, ds("function ("), yypvt[-1].dynstr, ds(") returning "), NullCP); prev = 'f'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 25: { Debug((stderr, "cdecl1: cdecl1 cdims\n")); Debug((stderr, "\tcdecl1='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tcdims='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = cat(yypvt[-1].dynstr,ds("array "),yypvt[-0].dynstr,NullCP); prev = 'a'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 26: { Debug((stderr, "cdecl1: (cdecl)\n")); Debug((stderr, "\tcdecl='%s'\n", yypvt[-1].dynstr)); yyval.dynstr = yypvt[-1].dynstr; /* prev = prev; */ Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 27: { Debug((stderr, "cdecl1: NAME\n")); Debug((stderr, "\tNAME='%s'\n", yypvt[-0].dynstr)); savedname = yypvt[-0].dynstr; yyval.dynstr = ds(""); prev = 'n'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 28: { Debug((stderr, "castlist: castlist1, castlist2\n")); Debug((stderr, "\tcastlist1='%s'\n", yypvt[-2].dynstr)); Debug((stderr, "\tcastlist2='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = cat(yypvt[-2].dynstr, ds(", "), yypvt[-0].dynstr, NullCP); } break; case 29: { Debug((stderr, "castlist: opt_constvol_list type cast\n")); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-2].dynstr)); Debug((stderr, "\ttype='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tcast='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = cat(yypvt[-0].dynstr, yypvt[-2].dynstr, ds(strlen(yypvt[-2].dynstr) ? " " : ""), yypvt[-1].dynstr, NullCP); } break; case 30: { yyval.dynstr = yypvt[-0].dynstr; } break; case 31: { Debug((stderr, "adecllist: EMPTY\n")); yyval.dynstr = ds(""); } break; case 32: { Debug((stderr, "adecllist: adecllist1, adecllist2\n")); Debug((stderr, "\tadecllist1='%s'\n", yypvt[-2].dynstr)); Debug((stderr, "\tadecllist2='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = cat(yypvt[-2].dynstr, ds(", "), yypvt[-0].dynstr, NullCP); } break; case 33: { Debug((stderr, "adecllist: NAME\n")); Debug((stderr, "\tNAME='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = yypvt[-0].dynstr; } break; case 34: { Debug((stderr, "adecllist: adecl\n")); Debug((stderr, "\tadecl.left='%s'\n", yypvt[-0].halves.left)); Debug((stderr, "\tadecl.right='%s'\n", yypvt[-0].halves.right)); Debug((stderr, "\tadecl.type='%s'\n", yypvt[-0].halves.type)); yyval.dynstr = cat(yypvt[-0].halves.type, ds(" "), yypvt[-0].halves.left, yypvt[-0].halves.right, NullCP); } break; case 35: { Debug((stderr, "adecllist: NAME AS adecl\n")); Debug((stderr, "\tNAME='%s'\n", yypvt[-2].dynstr)); Debug((stderr, "\tadecl.left='%s'\n", yypvt[-0].halves.left)); Debug((stderr, "\tadecl.right='%s'\n", yypvt[-0].halves.right)); Debug((stderr, "\tadecl.type='%s'\n", yypvt[-0].halves.type)); yyval.dynstr = cat(yypvt[-0].halves.type, ds(" "), yypvt[-0].halves.left, yypvt[-2].dynstr, yypvt[-0].halves.right, NullCP); } break; case 36: { Debug((stderr, "cast: EMPTY\n")); yyval.dynstr = ds(""); /* prev = prev; */ Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 37: { Debug((stderr, "cast: ()\n")); yyval.dynstr = ds("function returning "); prev = 'f'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 38: { Debug((stderr, "cast: (cast)()\n")); Debug((stderr, "\tcast='%s'\n", yypvt[-3].dynstr)); yyval.dynstr = cat(yypvt[-3].dynstr,ds("function returning "),NullCP); prev = 'f'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 39: { Debug((stderr, "cast: (cast)(castlist)\n")); Debug((stderr, "\tcast='%s'\n", yypvt[-4].dynstr)); Debug((stderr, "\tcastlist='%s'\n", yypvt[-1].dynstr)); yyval.dynstr = cat(yypvt[-4].dynstr,ds("function ("),yypvt[-1].dynstr,ds(") returning "),NullCP); prev = 'f'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 40: { Debug((stderr, "cast: (cast)\n")); Debug((stderr, "\tcast='%s'\n", yypvt[-1].dynstr)); yyval.dynstr = yypvt[-1].dynstr; /* prev = prev; */ Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 41: { Debug((stderr, "cast: NAME::*cast\n")); Debug((stderr, "\tcast='%s'\n", yypvt[-0].dynstr)); if (!CplusplusFlag) unsupp("pointer to member of class", NullCP); yyval.dynstr = cat(yypvt[-0].dynstr,ds("pointer to member of class "),yypvt[-3].dynstr,ds(" "),NullCP); prev = 'p'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 42: { Debug((stderr, "cast: *cast\n")); Debug((stderr, "\tcast='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = cat(yypvt[-0].dynstr,ds("pointer to "),NullCP); prev = 'p'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 43: { Debug((stderr, "cast: &cast\n")); Debug((stderr, "\tcast='%s'\n", yypvt[-0].dynstr)); if (!CplusplusFlag) unsupp("reference", NullCP); yyval.dynstr = cat(yypvt[-0].dynstr,ds("reference to "),NullCP); prev = 'r'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 44: { Debug((stderr, "cast: cast cdims\n")); Debug((stderr, "\tcast='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tcdims='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = cat(yypvt[-1].dynstr,ds("array "),yypvt[-0].dynstr,NullCP); prev = 'a'; Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 45: { Debug((stderr, "cdims: []\n")); yyval.dynstr = ds("of "); } break; case 46: { Debug((stderr, "cdims: [NUMBER]\n")); Debug((stderr, "\tNUMBER='%s'\n", yypvt[-1].dynstr)); yyval.dynstr = cat(yypvt[-1].dynstr,ds(" of "),NullCP); } break; case 47: { Debug((stderr, "adecl: FUNCTION RETURNING adecl\n")); Debug((stderr, "\tadecl.left='%s'\n", yypvt[-0].halves.left)); Debug((stderr, "\tadecl.right='%s'\n", yypvt[-0].halves.right)); Debug((stderr, "\tadecl.type='%s'\n", yypvt[-0].halves.type)); if (prev == 'f') unsupp("Function returning function", "function returning pointer to function"); else if (prev=='A' || prev=='a') unsupp("Function returning array", "function returning pointer"); yyval.halves.left = yypvt[-0].halves.left; yyval.halves.right = cat(ds("()"),yypvt[-0].halves.right,NullCP); yyval.halves.type = yypvt[-0].halves.type; prev = 'f'; Debug((stderr, "\n\tadecl now =\n")); Debug((stderr, "\t\tadecl.left='%s'\n", yyval.halves.left)); Debug((stderr, "\t\tadecl.right='%s'\n", yyval.halves.right)); Debug((stderr, "\t\tadecl.type='%s'\n", yyval.halves.type)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 48: { Debug((stderr, "adecl: FUNCTION (adecllist) RETURNING adecl\n")); Debug((stderr, "\tadecllist='%s'\n", yypvt[-3].dynstr)); Debug((stderr, "\tadecl.left='%s'\n", yypvt[-0].halves.left)); Debug((stderr, "\tadecl.right='%s'\n", yypvt[-0].halves.right)); Debug((stderr, "\tadecl.type='%s'\n", yypvt[-0].halves.type)); if (prev == 'f') unsupp("Function returning function", "function returning pointer to function"); else if (prev=='A' || prev=='a') unsupp("Function returning array", "function returning pointer"); yyval.halves.left = yypvt[-0].halves.left; yyval.halves.right = cat(ds("("),yypvt[-3].dynstr,ds(")"),yypvt[-0].halves.right,NullCP); yyval.halves.type = yypvt[-0].halves.type; prev = 'f'; Debug((stderr, "\n\tadecl now =\n")); Debug((stderr, "\t\tadecl.left='%s'\n", yyval.halves.left)); Debug((stderr, "\t\tadecl.right='%s'\n", yyval.halves.right)); Debug((stderr, "\t\tadecl.type='%s'\n", yyval.halves.type)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 49: { Debug((stderr, "adecl: ARRAY adims OF adecl\n")); Debug((stderr, "\tadims='%s'\n", yypvt[-2].dynstr)); Debug((stderr, "\tadecl.left='%s'\n", yypvt[-0].halves.left)); Debug((stderr, "\tadecl.right='%s'\n", yypvt[-0].halves.right)); Debug((stderr, "\tadecl.type='%s'\n", yypvt[-0].halves.type)); if (prev == 'f') unsupp("Array of function", "array of pointer to function"); else if (prev == 'a') unsupp("Inner array of unspecified size", "array of pointer"); else if (prev == 'v') unsupp("Array of void", "pointer to void"); if (arbdims) prev = 'a'; else prev = 'A'; yyval.halves.left = yypvt[-0].halves.left; yyval.halves.right = cat(yypvt[-2].dynstr,yypvt[-0].halves.right,NullCP); yyval.halves.type = yypvt[-0].halves.type; Debug((stderr, "\n\tadecl now =\n")); Debug((stderr, "\t\tadecl.left='%s'\n", yyval.halves.left)); Debug((stderr, "\t\tadecl.right='%s'\n", yyval.halves.right)); Debug((stderr, "\t\tadecl.type='%s'\n", yyval.halves.type)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 50: { char *op = "", *cp = "", *sp = ""; Debug((stderr, "adecl: opt_constvol_list POINTER TO adecl\n")); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-3].dynstr)); Debug((stderr, "\tadecl.left='%s'\n", yypvt[-0].halves.left)); Debug((stderr, "\tadecl.right='%s'\n", yypvt[-0].halves.right)); Debug((stderr, "\tadecl.type='%s'\n", yypvt[-0].halves.type)); if (prev == 'a') unsupp("Pointer to array of unspecified dimension", "pointer to object"); if (prev=='a' || prev=='A' || prev=='f') { op = "("; cp = ")"; } if (strlen(yypvt[-3].dynstr) != 0) sp = " "; yyval.halves.left = cat(yypvt[-0].halves.left,ds(op),ds("*"), ds(sp),yypvt[-3].dynstr,ds(sp),NullCP); yyval.halves.right = cat(ds(cp),yypvt[-0].halves.right,NullCP); yyval.halves.type = yypvt[-0].halves.type; prev = 'p'; Debug((stderr, "\n\tadecl now =\n")); Debug((stderr, "\t\tadecl.left='%s'\n", yyval.halves.left)); Debug((stderr, "\t\tadecl.right='%s'\n", yyval.halves.right)); Debug((stderr, "\t\tadecl.type='%s'\n", yyval.halves.type)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 51: { char *op = "", *cp = "", *sp = ""; Debug((stderr, "adecl: opt_constvol_list POINTER TO MEMBER OF ClassStruct NAME adecl\n")); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-7].dynstr)); Debug((stderr, "\tClassStruct='%s'\n", yypvt[-2].dynstr)); Debug((stderr, "\tNAME='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tadecl.left='%s'\n", yypvt[-0].halves.left)); Debug((stderr, "\tadecl.right='%s'\n", yypvt[-0].halves.right)); Debug((stderr, "\tadecl.type='%s'\n", yypvt[-0].halves.type)); if (!CplusplusFlag) unsupp("pointer to member of class", NullCP); if (prev == 'a') unsupp("Pointer to array of unspecified dimension", "pointer to object"); if (prev=='a' || prev=='A' || prev=='f') { op = "("; cp = ")"; } if (strlen(yypvt[-7].dynstr) != 0) sp = " "; yyval.halves.left = cat(yypvt[-0].halves.left,ds(op),yypvt[-1].dynstr,ds("::*"), ds(sp),yypvt[-7].dynstr,ds(sp),NullCP); yyval.halves.right = cat(ds(cp),yypvt[-0].halves.right,NullCP); yyval.halves.type = yypvt[-0].halves.type; prev = 'p'; Debug((stderr, "\n\tadecl now =\n")); Debug((stderr, "\t\tadecl.left='%s'\n", yyval.halves.left)); Debug((stderr, "\t\tadecl.right='%s'\n", yyval.halves.right)); Debug((stderr, "\t\tadecl.type='%s'\n", yyval.halves.type)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 52: { char *op = "", *cp = "", *sp = ""; Debug((stderr, "adecl: opt_constvol_list REFERENCE TO adecl\n")); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-3].dynstr)); Debug((stderr, "\tadecl.left='%s'\n", yypvt[-0].halves.left)); Debug((stderr, "\tadecl.right='%s'\n", yypvt[-0].halves.right)); Debug((stderr, "\tadecl.type='%s'\n", yypvt[-0].halves.type)); if (!CplusplusFlag) unsupp("reference", NullCP); if (prev == 'v') unsupp("Reference to void", "pointer to void"); else if (prev == 'a') unsupp("Reference to array of unspecified dimension", "reference to object"); if (prev=='a' || prev=='A' || prev=='f') { op = "("; cp = ")"; } if (strlen(yypvt[-3].dynstr) != 0) sp = " "; yyval.halves.left = cat(yypvt[-0].halves.left,ds(op),ds("&"), ds(sp),yypvt[-3].dynstr,ds(sp),NullCP); yyval.halves.right = cat(ds(cp),yypvt[-0].halves.right,NullCP); yyval.halves.type = yypvt[-0].halves.type; prev = 'r'; Debug((stderr, "\n\tadecl now =\n")); Debug((stderr, "\t\tadecl.left='%s'\n", yyval.halves.left)); Debug((stderr, "\t\tadecl.right='%s'\n", yyval.halves.right)); Debug((stderr, "\t\tadecl.type='%s'\n", yyval.halves.type)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 53: { Debug((stderr, "adecl: opt_constvol_list type\n")); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\ttype='%s'\n", yypvt[-0].dynstr)); yyval.halves.left = ds(""); yyval.halves.right = ds(""); yyval.halves.type = cat(yypvt[-1].dynstr,ds(strlen(yypvt[-1].dynstr)?" ":""),yypvt[-0].dynstr,NullCP); if (strcmp(yypvt[-0].dynstr, "void") == 0) prev = 'v'; else if ((strncmp(yypvt[-0].dynstr, "struct", 6) == 0) || (strncmp(yypvt[-0].dynstr, "class", 5) == 0)) prev = 's'; else prev = 't'; Debug((stderr, "\n\tadecl now =\n")); Debug((stderr, "\t\tadecl.left='%s'\n", yyval.halves.left)); Debug((stderr, "\t\tadecl.right='%s'\n", yyval.halves.right)); Debug((stderr, "\t\tadecl.type='%s'\n", yyval.halves.type)); Debug((stderr, "\tprev = '%s'\n", visible(prev))); } break; case 54: { Debug((stderr, "adims: EMPTY\n")); arbdims = 1; yyval.dynstr = ds("[]"); } break; case 55: { Debug((stderr, "adims: NUMBER\n")); Debug((stderr, "\tNUMBER='%s'\n", yypvt[-0].dynstr)); arbdims = 0; yyval.dynstr = cat(ds("["),yypvt[-0].dynstr,ds("]"),NullCP); } break; case 56: { Debug((stderr, "type: tinit c_type\n")); Debug((stderr, "\ttinit=''\n")); Debug((stderr, "\tc_type='%s'\n", yypvt[-0].dynstr)); mbcheck(); yyval.dynstr = yypvt[-0].dynstr; } break; case 57: { Debug((stderr, "tinit: EMPTY\n")); modbits = 0; } break; case 58: { Debug((stderr, "c_type: mod_list\n")); Debug((stderr, "\tmod_list='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = yypvt[-0].dynstr; } break; case 59: { Debug((stderr, "c_type: tname\n")); Debug((stderr, "\ttname='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = yypvt[-0].dynstr; } break; case 60: { Debug((stderr, "c_type: mod_list tname\n")); Debug((stderr, "\tmod_list='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\ttname='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = cat(yypvt[-1].dynstr,ds(" "),yypvt[-0].dynstr,NullCP); } break; case 61: { Debug((stderr, "c_type: StrClaUniEnum NAME\n")); Debug((stderr, "\tStrClaUniEnum='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tNAME='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = cat(yypvt[-1].dynstr,ds(" "),yypvt[-0].dynstr,NullCP); } break; case 64: { yyval.dynstr = yypvt[-0].dynstr; } break; case 66: { yyval.dynstr = yypvt[-0].dynstr; } break; case 67: { Debug((stderr, "tname: INT\n")); Debug((stderr, "\tINT='%s'\n", yypvt[-0].dynstr)); modbits |= MB_INT; yyval.dynstr = yypvt[-0].dynstr; } break; case 68: { Debug((stderr, "tname: CHAR\n")); Debug((stderr, "\tCHAR='%s'\n", yypvt[-0].dynstr)); modbits |= MB_CHAR; yyval.dynstr = yypvt[-0].dynstr; } break; case 69: { Debug((stderr, "tname: FLOAT\n")); Debug((stderr, "\tFLOAT='%s'\n", yypvt[-0].dynstr)); modbits |= MB_FLOAT; yyval.dynstr = yypvt[-0].dynstr; } break; case 70: { Debug((stderr, "tname: DOUBLE\n")); Debug((stderr, "\tDOUBLE='%s'\n", yypvt[-0].dynstr)); modbits |= MB_DOUBLE; yyval.dynstr = yypvt[-0].dynstr; } break; case 71: { Debug((stderr, "tname: VOID\n")); Debug((stderr, "\tVOID='%s'\n", yypvt[-0].dynstr)); modbits |= MB_VOID; yyval.dynstr = yypvt[-0].dynstr; } break; case 72: { Debug((stderr, "mod_list: modifier mod_list1\n")); Debug((stderr, "\tmodifier='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\tmod_list1='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = cat(yypvt[-1].dynstr,ds(" "),yypvt[-0].dynstr,NullCP); } break; case 73: { Debug((stderr, "mod_list: modifier\n")); Debug((stderr, "\tmodifier='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = yypvt[-0].dynstr; } break; case 74: { Debug((stderr, "mod_list1: mod_list\n")); Debug((stderr, "\tmod_list='%s'\n", yypvt[-0].dynstr)); yyval.dynstr = yypvt[-0].dynstr; } break; case 75: { Debug((stderr, "mod_list1: CONSTVOLATILE\n")); Debug((stderr, "\tCONSTVOLATILE='%s'\n", yypvt[-0].dynstr)); if (PreANSIFlag) notsupported(" (Pre-ANSI Compiler)", yypvt[-0].dynstr, NullCP); else if (RitchieFlag) notsupported(" (Ritchie Compiler)", yypvt[-0].dynstr, NullCP); else if ((strcmp(yypvt[-0].dynstr, "noalias") == 0) && CplusplusFlag) unsupp(yypvt[-0].dynstr, NullCP); yyval.dynstr = yypvt[-0].dynstr; } break; case 76: { Debug((stderr, "modifier: UNSIGNED\n")); Debug((stderr, "\tUNSIGNED='%s'\n", yypvt[-0].dynstr)); modbits |= MB_UNSIGNED; yyval.dynstr = yypvt[-0].dynstr; } break; case 77: { Debug((stderr, "modifier: SIGNED\n")); Debug((stderr, "\tSIGNED='%s'\n", yypvt[-0].dynstr)); modbits |= MB_SIGNED; yyval.dynstr = yypvt[-0].dynstr; } break; case 78: { Debug((stderr, "modifier: LONG\n")); Debug((stderr, "\tLONG='%s'\n", yypvt[-0].dynstr)); modbits |= MB_LONG; yyval.dynstr = yypvt[-0].dynstr; } break; case 79: { Debug((stderr, "modifier: SHORT\n")); Debug((stderr, "\tSHORT='%s'\n", yypvt[-0].dynstr)); modbits |= MB_SHORT; yyval.dynstr = yypvt[-0].dynstr; } break; case 80: { Debug((stderr, "opt_constvol_list: CONSTVOLATILE opt_constvol_list\n")); Debug((stderr, "\tCONSTVOLATILE='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-0].dynstr)); if (PreANSIFlag) notsupported(" (Pre-ANSI Compiler)", yypvt[-1].dynstr, NullCP); else if (RitchieFlag) notsupported(" (Ritchie Compiler)", yypvt[-1].dynstr, NullCP); else if ((strcmp(yypvt[-1].dynstr, "noalias") == 0) && CplusplusFlag) unsupp(yypvt[-1].dynstr, NullCP); yyval.dynstr = cat(yypvt[-1].dynstr,ds(strlen(yypvt[-0].dynstr) ? " " : ""),yypvt[-0].dynstr,NullCP); } break; case 81: { Debug((stderr, "opt_constvol_list: EMPTY\n")); yyval.dynstr = ds(""); } break; case 82: { Debug((stderr, "constvol_list: CONSTVOLATILE opt_constvol_list\n")); Debug((stderr, "\tCONSTVOLATILE='%s'\n", yypvt[-1].dynstr)); Debug((stderr, "\topt_constvol_list='%s'\n", yypvt[-0].dynstr)); if (PreANSIFlag) notsupported(" (Pre-ANSI Compiler)", yypvt[-1].dynstr, NullCP); else if (RitchieFlag) notsupported(" (Ritchie Compiler)", yypvt[-1].dynstr, NullCP); else if ((strcmp(yypvt[-1].dynstr, "noalias") == 0) && CplusplusFlag) unsupp(yypvt[-1].dynstr, NullCP); yyval.dynstr = cat(yypvt[-1].dynstr,ds(strlen(yypvt[-0].dynstr) ? " " : ""),yypvt[-0].dynstr,NullCP); } break; case 86: { Debug((stderr, "storage: AUTO,EXTERN,STATIC,REGISTER (%s)\n", yypvt[-0].dynstr)); yyval.dynstr = yypvt[-0].dynstr; } break; case 87: { Debug((stderr, "opt_storage: storage=%s\n", yypvt[-0].dynstr)); yyval.dynstr = yypvt[-0].dynstr; } break; case 88: { Debug((stderr, "opt_storage: EMPTY\n")); yyval.dynstr = ds(""); } break; } goto yystack; /* stack new state and value */ } SHAR_EOF cat << \SHAR_EOF > cdlex.c # include "stdio.h" # define U(x) x # define NLSTATE yyprevious=YYNEWLINE # define BEGIN yybgin = yysvec + 1 + # define INITIAL 0 # define YYLERR yysvec # define YYSTATE (yyestate-yysvec-1) # define YYOPTIM 1 # define YYLMAX BUFSIZ # define output(c) putc(c,yyout) # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;} # define yymore() (yymorfg=1) # define ECHO fprintf(yyout, "%s",yytext) # define REJECT { nstr = yyreject(); goto yyfussy;} int yyleng; extern char yytext[]; int yymorfg; extern char *yysptr, yysbuf[]; int yytchar; FILE *yyin = {stdin}, *yyout = {stdout}; extern int yylineno; struct yysvf { struct yywork *yystoff; struct yysvf *yyother; int *yystops;}; struct yysvf *yyestate; extern struct yysvf yysvec[], *yybgin; /* Lexical analyzer description for ANSI and C++ cdecl. */ /* The output of this file is included */ /* into the C file cdecl.c. */ char cdlexsccsid[] = "@(#)cdlex.l 2.2 3/30/88"; # define YYNEWLINE 10 yylex(){ int nstr; extern int yyprevious; while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: return ARRAY; break; case 2: return AS; break; case 3: return CAST; break; case 4: return DECLARE; break; case 5: return 0; break; case 6: return EXPLAIN; break; case 7: return FUNCTION; break; case 8: return FUNCTION; break; case 9: return HELP; break; case 10: return INTO; break; case 11: return MEMBER; break; case 12: return OF; break; case 13: return POINTER; break; case 14: return POINTER; break; case 15: return 0; break; case 16: return REFERENCE; break; case 17: return REFERENCE; break; case 18: return RETURNING; break; case 19: return RETURNING; break; case 20: return SET; break; case 21: return TO; break; case 22: return ARRAY; break; case 23: return DOUBLECOLON; break; case 24: return HELP; break; case 25: return COMMA; break; case 26: { yylval.dynstr = ds(yytext); return AUTO; } break; case 27: { yylval.dynstr = ds("char"); return CHAR; } break; case 28: { yylval.dynstr = ds(yytext); return CHAR; } break; case 29: { yylval.dynstr = ds(yytext); return CLASS; } break; case 30: { yylval.dynstr = ds("const"); return CONSTVOLATILE; } break; case 31: { yylval.dynstr = ds(yytext); return CONSTVOLATILE; } break; case 32: { yylval.dynstr = ds(yytext); return DOUBLE; } break; case 33: { yylval.dynstr = ds("enum"); return ENUM; } break; case 34: { yylval.dynstr = ds(yytext); return ENUM; } break; case 35: { yylval.dynstr = ds(yytext); return EXTERN; } break; case 36: { yylval.dynstr = ds(yytext); return FLOAT; } break; case 37: { yylval.dynstr = ds("int"); return INT; } break; case 38: { yylval.dynstr = ds(yytext); return INT; } break; case 39: { yylval.dynstr = ds(yytext); return LONG; } break; case 40: { yylval.dynstr = ds(yytext); return CONSTVOLATILE; } break; case 41: { yylval.dynstr = ds(yytext); return REGISTER; } break; case 42: { yylval.dynstr = ds(yytext); return SHORT; } break; case 43: { yylval.dynstr = ds(yytext); return SIGNED; } break; case 44: { yylval.dynstr = ds(yytext); return STATIC; } break; case 45: { yylval.dynstr = ds("struct"); return STRUCT; } break; case 46: { yylval.dynstr = ds(yytext); return STRUCT; } break; case 47: { yylval.dynstr = ds(yytext); return UNION; } break; case 48: { yylval.dynstr = ds(yytext); return UNSIGNED; } break; case 49: { yylval.dynstr = ds(yytext); return VOID; } break; case 50: { yylval.dynstr = ds(yytext); return CONSTVOLATILE; } break; case 51: { yylval.dynstr = ds(yytext); return NAME; } break; case 52: { yylval.dynstr = ds(yytext); return NUMBER; } break; case 53: ; break; case 54: ; break; case 55: return *yytext; break; case 56: { (void) printf("bad character '%s'\n",visible(*yytext)); return *yytext; } break; case -1: break; default: fprintf(yyout,"bad switch yylook %d",nstr); } return(0); } /* end of yylex */ int yyvstop[] = { 0, 56, 0, 54, 56, 0, 55, 0, 53, 56, 0, 55, 56, 0, 25, 56, 0, 52, 56, 0, 56, 0, 24, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 51, 56, 0, 53, 0, 52, 0, 23, 0, 51, 0, 51, 0, 2, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 12, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 21, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 38, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 14, 51, 0, 51, 0, 17, 51, 0, 51, 0, 19, 51, 0, 20, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 26, 51, 0, 3, 51, 0, 28, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 34, 51, 0, 5, 51, 0, 51, 0, 51, 0, 51, 0, 8, 51, 0, 9, 51, 0, 51, 0, 10, 51, 0, 39, 51, 0, 51, 0, 51, 0, 51, 0, 15, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 49, 51, 0, 51, 0, 1, 51, 0, 51, 0, 29, 51, 0, 31, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 36, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 42, 51, 0, 51, 0, 51, 0, 51, 0, 47, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 32, 51, 0, 51, 0, 51, 0, 35, 51, 0, 51, 0, 51, 0, 11, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 43, 51, 0, 44, 51, 0, 46, 51, 0, 51, 0, 22, 51, 0, 51, 0, 51, 0, 51, 0, 4, 51, 0, 51, 0, 6, 51, 0, 51, 0, 37, 51, 0, 40, 51, 0, 13, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 51, 0, 30, 51, 0, 51, 0, 7, 51, 0, 51, 0, 41, 51, 0, 51, 0, 51, 0, 48, 51, 0, 50, 51, 0, 27, 51, 0, 51, 0, 16, 51, 0, 18, 51, 0, 45, 51, 0, 51, 0, 33, 51, 0, 0}; # define YYTYPE int struct yywork { YYTYPE verify, advance; } yycrank[] = { 0,0, 0,0, 1,3, 0,0, 0,0, 0,0, 0,0, 6,31, 0,0, 0,0, 1,4, 1,5, 0,0, 0,0, 0,0, 6,31, 6,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 1,6, 0,0, 0,0, 1,7, 0,0, 6,31, 0,0, 0,0, 6,31, 1,8, 0,0, 0,0, 0,0, 1,9, 6,31, 0,0, 0,0, 0,0, 6,31, 0,0, 0,0, 0,0, 0,0, 1,10, 10,33, 0,0, 0,0, 0,0, 1,11, 0,0, 1,12, 0,0, 0,0, 6,31, 0,0, 6,31, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 2,10, 9,32, 9,32, 9,32, 9,32, 9,32, 9,32, 9,32, 9,32, 9,32, 9,32, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 1,13, 0,0, 1,14, 1,15, 1,16, 1,17, 18,48, 1,18, 1,19, 31,0, 0,0, 1,20, 1,21, 1,22, 1,23, 1,24, 1,25, 1,26, 1,27, 1,28, 1,29, 1,30, 2,13, 17,46, 2,14, 2,15, 2,16, 2,17, 19,49, 2,18, 2,19, 20,50, 17,47, 2,20, 2,21, 2,22, 2,23, 2,24, 2,25, 2,26, 2,27, 2,28, 2,29, 2,30, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 13,35, 13,36, 21,51, 13,37, 22,52, 23,53, 25,56, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 24,54, 26,57, 28,62, 29,63, 12,34, 24,55, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 12,34, 14,38, 27,58, 15,42, 16,44, 27,59, 27,60, 35,66, 14,39, 30,64, 37,67, 38,68, 14,40, 15,43, 16,45, 14,41, 39,69, 27,61, 40,70, 30,65, 41,71, 42,72, 43,73, 44,74, 45,75, 46,78, 47,79, 48,80, 49,81, 50,82, 51,83, 45,76, 52,84, 54,85, 55,86, 45,77, 56,87, 57,88, 57,89, 58,91, 59,92, 60,93, 61,94, 63,96, 64,98, 65,99, 66,101, 67,102, 65,100, 68,103, 69,104, 57,90, 70,105, 63,97, 71,106, 72,107, 73,108, 74,109, 75,110, 61,95, 76,111, 77,112, 78,113, 79,114, 80,115, 81,116, 82,118, 83,119, 84,120, 85,121, 87,122, 88,123, 89,124, 90,125, 92,126, 81,117, 93,127, 94,128, 95,129, 96,130, 97,131, 98,132, 99,133, 100,134, 101,135, 104,136, 105,137, 106,138, 107,139, 108,140, 109,141, 111,142, 112,143, 113,144, 114,145, 116,146, 119,147, 120,148, 121,149, 123,150, 124,151, 125,152, 126,153, 127,154, 128,155, 129,156, 130,157, 131,158, 132,159, 134,160, 136,161, 138,162, 139,163, 140,164, 141,165, 142,166, 143,167, 145,168, 146,169, 147,170, 148,171, 149,172, 150,173, 151,174, 152,175, 154,176, 155,177, 156,178, 158,179, 159,180, 160,181, 161,182, 162,183, 163,184, 165,185, 166,186, 168,187, 169,188, 171,189, 172,190, 173,191, 174,192, 175,193, 178,194, 179,195, 181,196, 182,197, 183,198, 185,199, 187,200, 191,201, 192,202, 193,203, 194,204, 195,205, 196,206, 197,207, 199,208, 201,209, 203,210, 204,211, 208,212, 212,213, 0,0, 0,0}; struct yysvf yysvec[] = { 0, 0, 0, yycrank+-1, 0, 0, yycrank+-23, yysvec+1, 0, yycrank+0, 0, yyvstop+1, yycrank+0, 0, yyvstop+3, yycrank+0, 0, yyvstop+6, yycrank+-6, 0, yyvstop+8, yycrank+0, 0, yyvstop+11, yycrank+0, 0, yyvstop+14, yycrank+34, 0, yyvstop+17, yycrank+2, 0, yyvstop+20, yycrank+0, 0, yyvstop+22, yycrank+94, 0, yyvstop+25, yycrank+38, yysvec+12, yyvstop+28, yycrank+120, yysvec+12, yyvstop+31, yycrank+118, yysvec+12, yyvstop+34, yycrank+110, yysvec+12, yyvstop+37, yycrank+13, yysvec+12, yyvstop+40, yycrank+3, yysvec+12, yyvstop+43, yycrank+16, yysvec+12, yyvstop+46, yycrank+18, yysvec+12, yyvstop+49, yycrank+53, yysvec+12, yyvstop+52, yycrank+45, yysvec+12, yyvstop+55, yycrank+55, yysvec+12, yyvstop+58, yycrank+74, yysvec+12, yyvstop+61, yycrank+41, yysvec+12, yyvstop+64, yycrank+85, yysvec+12, yyvstop+67, yycrank+117, yysvec+12, yyvstop+70, yycrank+76, yysvec+12, yyvstop+73, yycrank+78, yysvec+12, yyvstop+76, yycrank+124, yysvec+12, yyvstop+79, yycrank+-97, yysvec+6, yyvstop+82, yycrank+0, yysvec+9, yyvstop+84, yycrank+0, 0, yyvstop+86, yycrank+0, yysvec+12, yyvstop+88, yycrank+109, yysvec+12, yyvstop+90, yycrank+0, yysvec+12, yyvstop+92, yycrank+110, yysvec+12, yyvstop+95, yycrank+112, yysvec+12, yyvstop+97, yycrank+135, yysvec+12, yyvstop+99, yycrank+137, yysvec+12, yyvstop+101, yycrank+126, yysvec+12, yyvstop+103, yycrank+138, yysvec+12, yyvstop+105, yycrank+121, yysvec+12, yyvstop+107, yycrank+122, yysvec+12, yyvstop+109, yycrank+135, yysvec+12, yyvstop+111, yycrank+130, yysvec+12, yyvstop+113, yycrank+132, yysvec+12, yyvstop+115, yycrank+135, yysvec+12, yyvstop+117, yycrank+128, yysvec+12, yyvstop+119, yycrank+135, yysvec+12, yyvstop+121, yycrank+137, yysvec+12, yyvstop+123, yycrank+151, yysvec+12, yyvstop+125, yycrank+0, yysvec+12, yyvstop+127, yycrank+144, yysvec+12, yyvstop+130, yycrank+136, yysvec+12, yyvstop+132, yycrank+147, yysvec+12, yyvstop+134, yycrank+151, yysvec+12, yyvstop+136, yycrank+139, yysvec+12, yyvstop+138, yycrank+145, yysvec+12, yyvstop+140, yycrank+154, yysvec+12, yyvstop+142, yycrank+161, yysvec+12, yyvstop+144, yycrank+0, yysvec+12, yyvstop+146, yycrank+154, yysvec+12, yyvstop+149, yycrank+161, yysvec+12, yyvstop+151, yycrank+156, yysvec+12, yyvstop+153, yycrank+165, yysvec+12, yyvstop+155, yycrank+152, yysvec+12, yyvstop+157, yycrank+149, yysvec+12, yyvstop+159, yycrank+152, yysvec+12, yyvstop+161, yycrank+153, yysvec+12, yyvstop+163, yycrank+155, yysvec+12, yyvstop+165, yycrank+163, yysvec+12, yyvstop+167, yycrank+174, yysvec+12, yyvstop+169, yycrank+164, yysvec+12, yyvstop+171, yycrank+158, yysvec+12, yyvstop+173, yycrank+168, yysvec+12, yyvstop+175, yycrank+176, yysvec+12, yyvstop+177, yycrank+181, yysvec+12, yyvstop+179, yycrank+180, yysvec+12, yyvstop+181, yycrank+168, yysvec+12, yyvstop+183, yycrank+180, yysvec+12, yyvstop+185, yycrank+179, yysvec+12, yyvstop+188, yycrank+185, yysvec+12, yyvstop+190, yycrank+176, yysvec+12, yyvstop+192, yycrank+175, yysvec+12, yyvstop+194, yycrank+0, yysvec+12, yyvstop+196, yycrank+170, yysvec+12, yyvstop+199, yycrank+186, yysvec+12, yyvstop+201, yycrank+183, yysvec+12, yyvstop+204, yycrank+172, yysvec+12, yyvstop+206, yycrank+0, yysvec+12, yyvstop+209, yycrank+176, yysvec+12, yyvstop+212, yycrank+182, yysvec+12, yyvstop+214, yycrank+177, yysvec+12, yyvstop+216, yycrank+177, yysvec+12, yyvstop+218, yycrank+184, yysvec+12, yyvstop+220, yycrank+191, yysvec+12, yyvstop+222, yycrank+181, yysvec+12, yyvstop+224, yycrank+198, yysvec+12, yyvstop+226, yycrank+202, yysvec+12, yyvstop+228, yycrank+179, yysvec+12, yyvstop+230, yycrank+0, yysvec+12, yyvstop+232, yycrank+0, yysvec+12, yyvstop+235, yycrank+204, yysvec+12, yyvstop+238, yycrank+187, yysvec+12, yyvstop+241, yycrank+187, yysvec+12, yyvstop+243, yycrank+207, yysvec+12, yyvstop+245, yycrank+197, yysvec+12, yyvstop+247, yycrank+205, yysvec+12, yyvstop+249, yycrank+0, yysvec+12, yyvstop+252, yycrank+210, yysvec+12, yyvstop+255, yycrank+194, yysvec+12, yyvstop+257, yycrank+193, yysvec+12, yyvstop+259, yycrank+194, yysvec+12, yyvstop+261, yycrank+0, yysvec+12, yyvstop+264, yycrank+208, yysvec+12, yyvstop+267, yycrank+0, yysvec+12, yyvstop+269, yycrank+0, yysvec+12, yyvstop+272, yycrank+211, yysvec+12, yyvstop+275, yycrank+208, yysvec+12, yyvstop+277, yycrank+198, yysvec+12, yyvstop+279, yycrank+0, yysvec+12, yyvstop+281, yycrank+201, yysvec+12, yyvstop+284, yycrank+201, yysvec+12, yyvstop+286, yycrank+203, yysvec+12, yyvstop+288, yycrank+202, yysvec+12, yyvstop+290, yycrank+218, yysvec+12, yyvstop+292, yycrank+215, yysvec+12, yyvstop+294, yycrank+222, yysvec+12, yyvstop+296, yycrank+212, yysvec+12, yyvstop+298, yycrank+220, yysvec+12, yyvstop+300, yycrank+213, yysvec+12, yyvstop+302, yycrank+0, yysvec+12, yyvstop+304, yycrank+209, yysvec+12, yyvstop+307, yycrank+0, yysvec+12, yyvstop+309, yycrank+227, yysvec+12, yyvstop+312, yycrank+0, yysvec+12, yyvstop+314, yycrank+230, yysvec+12, yyvstop+317, yycrank+214, yysvec+12, yyvstop+320, yycrank+228, yysvec+12, yyvstop+322, yycrank+216, yysvec+12, yyvstop+324, yycrank+226, yysvec+12, yyvstop+326, yycrank+222, yysvec+12, yyvstop+328, yycrank+0, yysvec+12, yyvstop+330, yycrank+228, yysvec+12, yyvstop+333, yycrank+233, yysvec+12, yyvstop+335, yycrank+221, yysvec+12, yyvstop+337, yycrank+239, yysvec+12, yyvstop+339, yycrank+236, yysvec+12, yyvstop+341, yycrank+237, yysvec+12, yyvstop+343, yycrank+223, yysvec+12, yyvstop+345, yycrank+230, yysvec+12, yyvstop+347, yycrank+0, yysvec+12, yyvstop+349, yycrank+241, yysvec+12, yyvstop+352, yycrank+243, yysvec+12, yyvstop+354, yycrank+227, yysvec+12, yyvstop+356, yycrank+0, yysvec+12, yyvstop+358, yycrank+234, yysvec+12, yyvstop+361, yycrank+231, yysvec+12, yyvstop+363, yycrank+241, yysvec+12, yyvstop+365, yycrank+231, yysvec+12, yyvstop+367, yycrank+238, yysvec+12, yyvstop+369, yycrank+248, yysvec+12, yyvstop+371, yycrank+0, yysvec+12, yyvstop+373, yycrank+253, yysvec+12, yyvstop+376, yycrank+241, yysvec+12, yyvstop+378, yycrank+0, yysvec+12, yyvstop+380, yycrank+241, yysvec+12, yyvstop+383, yycrank+239, yysvec+12, yyvstop+385, yycrank+0, yysvec+12, yyvstop+387, yycrank+239, yysvec+12, yyvstop+390, yycrank+241, yysvec+12, yyvstop+392, yycrank+246, yysvec+12, yyvstop+394, yycrank+256, yysvec+12, yyvstop+396, yycrank+253, yysvec+12, yyvstop+398, yycrank+0, yysvec+12, yyvstop+400, yycrank+0, yysvec+12, yyvstop+403, yycrank+242, yysvec+12, yyvstop+406, yycrank+259, yysvec+12, yyvstop+409, yycrank+0, yysvec+12, yyvstop+411, yycrank+253, yysvec+12, yyvstop+414, yycrank+261, yysvec+12, yyvstop+416, yycrank+247, yysvec+12, yyvstop+418, yycrank+0, yysvec+12, yyvstop+420, yycrank+248, yysvec+12, yyvstop+423, yycrank+0, yysvec+12, yyvstop+425, yycrank+255, yysvec+12, yyvstop+428, yycrank+0, yysvec+12, yyvstop+430, yycrank+0, yysvec+12, yyvstop+433, yycrank+0, yysvec+12, yyvstop+436, yycrank+267, yysvec+12, yyvstop+439, yycrank+253, yysvec+12, yyvstop+441, yycrank+258, yysvec+12, yyvstop+443, yycrank+255, yysvec+12, yyvstop+445, yycrank+270, yysvec+12, yyvstop+447, yycrank+270, yysvec+12, yyvstop+449, yycrank+258, yysvec+12, yyvstop+451, yycrank+0, yysvec+12, yyvstop+453, yycrank+268, yysvec+12, yyvstop+456, yycrank+0, yysvec+12, yyvstop+458, yycrank+273, yysvec+12, yyvstop+461, yycrank+0, yysvec+12, yyvstop+463, yycrank+272, yysvec+12, yyvstop+466, yycrank+275, yysvec+12, yyvstop+468, yycrank+0, yysvec+12, yyvstop+470, yycrank+0, yysvec+12, yyvstop+473, yycrank+0, yysvec+12, yyvstop+476, yycrank+266, yysvec+12, yyvstop+479, yycrank+0, yysvec+12, yyvstop+481, yycrank+0, yysvec+12, yyvstop+484, yycrank+0, yysvec+12, yyvstop+487, yycrank+268, yysvec+12, yyvstop+490, yycrank+0, yysvec+12, yyvstop+492, 0, 0, 0}; struct yywork *yytop = yycrank+378; struct yysvf *yybgin = yysvec+1; char yymatch[] = { 00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , 01 ,011 ,012 ,01 ,01 ,01 ,01 ,01 , 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , 011 ,01 ,01 ,'#' ,01 ,01 ,'&' ,01 , '&' ,'&' ,'&' ,01 ,',' ,01 ,01 ,01 , '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' , '0' ,'0' ,01 ,'&' ,01 ,01 ,01 ,'?' , 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,'&' ,01 ,'&' ,01 ,'A' , 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 , 0}; char yyextra[] = { 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0}; #ifndef lint static char ncform_sccsid[] = "@(#)ncform 1.1 86/07/08 SMI"; /* from S5R2 1.2 */ #endif int yylineno =1; # define YYU(x) x # define NLSTATE yyprevious=YYNEWLINE char yytext[YYLMAX]; struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp; char yysbuf[YYLMAX]; char *yysptr = yysbuf; int *yyfnd; extern struct yysvf *yyestate; int yyprevious = YYNEWLINE; yylook(){ register struct yysvf *yystate, **lsp; register struct yywork *yyt; struct yysvf *yyz; int yych, yyfirst; struct yywork *yyr; # ifdef LEXDEBUG int debug; # endif char *yylastch; /* start off machines */ # ifdef LEXDEBUG debug = 0; # endif yyfirst=1; if (!yymorfg) yylastch = yytext; else { yymorfg=0; yylastch = yytext+yyleng; } for(;;){ lsp = yylstate; yyestate = yystate = yybgin; if (yyprevious==YYNEWLINE) yystate++; for (;;){ # ifdef LEXDEBUG if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1); # endif yyt = yystate->yystoff; if(yyt == yycrank && !yyfirst){ /* may not be any transitions */ yyz = yystate->yyother; if(yyz == 0)break; if(yyz->yystoff == yycrank)break; } *yylastch++ = yych = input(); yyfirst=0; tryagain: # ifdef LEXDEBUG if(debug){ fprintf(yyout,"char "); allprint(yych); putchar('\n'); } # endif yyr = yyt; if ( (int)yyt > (int)yycrank){ yyt = yyr + yych; if (yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transitions */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; goto contin; } } # ifdef YYOPTIM else if((int)yyt < (int)yycrank) { /* r < yycrank */ yyt = yyr = yycrank+(yycrank-yyt); # ifdef LEXDEBUG if(debug)fprintf(yyout,"compressed state\n"); # endif yyt = yyt + yych; if(yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transitions */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; goto contin; } yyt = yyr + YYU(yymatch[yych]); # ifdef LEXDEBUG if(debug){ fprintf(yyout,"try fall back character "); allprint(YYU(yymatch[yych])); putchar('\n'); } # endif if(yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transition */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; goto contin; } } if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){ # ifdef LEXDEBUG if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1); # endif goto tryagain; } # endif else {unput(*--yylastch);break;} contin: # ifdef LEXDEBUG if(debug){ fprintf(yyout,"state %d char ",yystate-yysvec-1); allprint(yych); putchar('\n'); } # endif ; } # ifdef LEXDEBUG if(debug){ fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1); allprint(yych); putchar('\n'); } # endif while (lsp-- > yylstate){ *yylastch-- = 0; if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){ yyolsp = lsp; if(yyextra[*yyfnd]){ /* must backup */ while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){ lsp--; unput(*yylastch--); } } yyprevious = YYU(*yylastch); yylsp = lsp; yyleng = yylastch-yytext+1; yytext[yyleng] = 0; # ifdef LEXDEBUG if(debug){ fprintf(yyout,"\nmatch "); sprint(yytext); fprintf(yyout," action %d\n",*yyfnd); } # endif return(*yyfnd++); } unput(*yylastch); } if (yytext[0] == 0 /* && feof(yyin) */) { yysptr=yysbuf; return(0); } yyprevious = yytext[0] = input(); if (yyprevious>0) output(yyprevious); yylastch=yytext; # ifdef LEXDEBUG if(debug)putchar('\n'); # endif } } yyback(p, m) int *p; { if (p==0) return(0); while (*p) { if (*p++ == m) return(1); } return(0); } /* the following are only used in the lex library */ yyinput(){ return(input()); } yyoutput(c) int c; { output(c); } yyunput(c) int c; { unput(c); } SHAR_EOF cat << \SHAR_EOF > cdecl.notes Here is a newer version of CDecl that supports ANSI C and C++, just in time for those who owned Lattice's C++ ... ( I don't have it myself.. ). cdgram.y and cdlex.l were generated from SunOS 3.4 yacc and lex. I kept the original cdecl.c as cdecl.old.c because I wasn't sure I didn't spoil any of the #ifdef's or #ifndef's. The file makefile.old is the old UNIX makefile. The file cdgram.old.c is the original output from yacc. cdgram.c is the same as cdgram.old.c without the #line directives because It has caused me problems with sdb. The code was compiled under Manx C 3.6a using the portability mode ( large code, large data, 32 bit ints ). Udi Finkelstein 10 Glitzenstein st. Tel Aviv 64686 Israel Phone: 972-3-263-927 BITNET: finkel@taurus.BITNET ( Best ) UUCP: ...!uunet!ulysses!attibr!althea!finkel ( Try avoiding this ) ARPA: finkel%taurus@cunyvm.cuny.edu ( Same as BITNET ) FIDO: Udi Finkelstein ( At 2:40/117 or 2:40/135 If you can get there at all!) SHAR_EOF # End of shell archive exit 0 -- Bob Page, U of Lowell CS Dept. page@swan.ulowell.edu ulowell!page Have five nice days.