From: garp AT opustel DOT com (Keith Gary Boyce) Subject: byacc wrt wxwin port to gnu-win32 24 Oct 1996 20:06:36 -0700 Sender: daemon AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="software6.opustel.com:846194565:480:-126845:29358" Original-To: corbett AT berkeley DOT edu Original-Cc: gnu-win32 AT cygnus DOT com X-PRIORITY: 3 (Normal) X-Mailer: Chameleon 5.0, TCP/IP for Windows, NetManage Inc. Original-Sender: owner-gnu-win32 AT cygnus DOT com --software6.opustel.com:846194565:480:-126845:29358 Content-Type: TEXT/PLAIN; charset=US-ASCII I am having problems using byacc to process file parse.y included in this message. y_tab.c produced is also included. and if you look for the case statements you will find that they are not in the right place. Is there something from with byacc? ------------------------------------- Name: Garry Boyce E-mail: garp AT opustel DOT opustel DOT com (Garry Boyce) Date: 12/01/94 Time: 08:46:10 This message was sent by Chameleon ------------------------------------- --software6.opustel.com:846194565:480:-126845:29358 Content-Type: TEXT/plain; SizeOnDisk=17681; name="y_tab.c"; CHARSET=US-ASCII Content-Description: y_tab.c #if defined(__STDC__) || defined(__cplusplus) #define YYCONST const #define YYPARAMS(x) x #define YYDEFUN(name, arglist, args) name(args) #define YYAND , #define YYPTR void * #else #define YYCONST #define YYPARAMS(x) () #define YYDEFUN(name, arglist, args) name arglist args; #define YYAND ; #define YYPTR char * #endif #ifndef lint YYCONST static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley +Cygnus.28) 01/20/91"; #endif #define YYBYACC 1 #ifndef YYDONT_INCLUDE_STDIO #include #endif #ifdef __cplusplus #include /* for malloc/realloc/free */ #endif #line 2 "parser.y" #include "string.h" #include "expr.h" #ifndef __EXTERN_C__ #define __EXTERN_C__ 1 #endif #if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) && defined(__EXTERN_C__) extern "C" { #endif #endif int yylex(void); int yylook(void); int yywrap(void); int yyback(int *, int); void yyerror(char *); /* You may need to put /DLEX_SCANNER in your makefile * if you're using LEX! */ #ifdef LEX_SCANNER /* int yyoutput(int); */ void yyoutput(int); #else void yyoutput(int); #endif #if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) && defined(__EXTERN_C__) } #endif #endif #line 37 "parser.y" typedef union { char *s; /* struct pexpr *expr; */ } YYSTYPE; k; case 12: #line 94 "parser.y" {yyval.s = proio_cons(make_word("="), proio_cons(make_word(yyvsp[-2].s), proio_cons(yyvsp[0].s, NULL))); free(yyvsp[-2].s); } break; case 13: #line 97 "parser.y" {yyval.s = yyvsp[0].s; } break; case 14: #line 100 "parser.y" {yyval.s = make_word(yyvs#line 76 "y.tab.c" #define INTEGER 1 #define WORD 2 #define STRING 3 #define PERIOD 13 #define OPEN 4 #define CLOSE 5 #define COMMA 6 #define NEWLINE 7 #define ERROR 8 #define OPEN_SQUARE 9 #define CLOSE_SQUARE 10 #define EQUALS 11 #define EXP 14 #define YYERRCODE 256 static YYCONST short yylhs[] = { -1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, }; static YYCONST short yylen[] = { 2, 0, 2, 2, 2, 2, 4, 2, 3, 0, 1, 3, 3, 1, 1, 1, 1, 3, 3, 5, 1, }; static YYCONST short yydefred[] = { 1, 0, 0, 0, 0, 2, 0, 5, 3, 0, 0, 0, 15, 7, 20, 0, 0, 13, 4, 0, 0, 0, 0, 8, 0, 6, 0, 18, 0, 12, 11, 0, 19, }; static YYCONST short yydgoto[] = { 1, 5, 14, 15, 16, 17, }; static YYCONST short yysindex[] = { 0, -2, 9, 2, 1, 0, 10, 0, 0, 11, -5, 17, 0, 0, 0, 14, -1, 0, 0, 33, 38, 41, 16, 0, 11, 0, 29, 0, 40, 0, 0, 44, 0, }; static YYCONST short yyrindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 21, 24, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 31, 0, 27, 0, 24, 0, 0, 0, 0, }; static YYCONST short yygindex[] = { 0, 0, 45, -8, 0, 26, }; #define YYTABLESIZE 254 static YYCONST short yytable[] = { 3, 19, 10, 11, 12, 24, 9, 4, 20, 21, 4, 13, 10, 11, 12, 8, 30, 10, 28, 12, 4, 9, 7, 18, 23, 4, 16, 16, 22, 14, 14, 16, 17, 17, 14, 10, 9, 17, 25, 26, 10, 9, 27, 31, 9, 32, 6, 9, 29, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, }; static YYCONST short yycheck[] = { 2, 9, 1, 2, 3, 6, 4, 9, 13, 14, 9, 10, 1, 2, 3, 13, 24, 1, 2, 3, 9, 4, 13, 13, 10, 9, 5, 6, 11, 5, 6, 10, 5, 6, 10, 5, 5, 10, 5, 1, 10, 10, 1, 14, 4, 1, 1, 5, 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, }; #define YYFINAL 1 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 14 #if YYDEBUG static YYCONST char *YYCONST yyname[] = { "end-of-file","INTEGER","WORD","STRING","OPEN","CLOSE","COMMA","NEWLINE", "ERROR","OPEN_SQUARE","CLOSE_SQUARE","EQUALS",0,"PERIOD","EXP", }; static YYCONST char *YYCONST yyrule[] = { "$accept : commands", "commands :", "commands : commands command", "command : WORD PERIOD", "command : expr PERIOD", "command : error PERIOD", "expr : WORD OPEN arglist CLOSE", "expr : OPEN_SQUARE CLOSE_SQUARE", "expr : OPEN_SQUARE arglist CLOSE_SQUARE", "arglist :", "arglist : arg", "arglist : arg COMMA arglist", "arg : WORD EQUALS arg1", "arg : arg1", "arg1 : WORD", "arg1 : STRING", "arg1 : INTEGER", "arg1 : INTEGER PERIOD INTEGER", "arg1 : INTEGER EXP INTEGER", "arg1 : INTEGER PERIOD INTEGER EXP INTEGER", "arg1 : expr", }; #endif #define YYLEX yylex() #define YYEMPTY -1 #define yyclearin (yychar=(YYEMPTY)) #define yyerrok (yyerrflag=0) #ifndef YYINITDEPTH #define YYINITDEPTH 200 #endif #ifdef YYSTACKSIZE #ifndef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #endif #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 500 #define YYMAXDEPTH 500 #endif #endif #ifndef YYMAXSTACKSIZE #define YYMAXSTACKSIZE 10000 #endif int yydebug; int yynerrs; int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; static short *yyss; static YYSTYPE *yyvs; static int yystacksize; #define yyfree(x) free(x) extern int yylex(); static YYPTR YYDEFUN (yymalloc, (bytes), unsigned bytes) { YYPTR ptr = (YYPTR) malloc (bytes); if (ptr != 0) return (ptr); yyerror ("yyparse: memory exhausted"); return (0); } static YYPTR YYDEFUN (yyrealloc, (old, bytes), YYPTR old YYAND unsigned bytes) { YYPTR ptr = (YYPTR) realloc (old, bytes); if (ptr != 0) return (ptr); yyerror ("yyparse: memory exhausted"); return (0); } static int #ifdef __GNUC__ inline #endif yygrow () { int old_stacksize = yystacksize; short *new_yyss; YYSTYPE *new_yyvs; if (yystacksize == YYMAXSTACKSIZE) return (1); yystacksize += (yystacksize + 1 ) / 2; if (yystacksize > YYMAXSTACKSIZE) yystacksize = YYMAXSTACKSIZE; #if YYDEBUG if (yydebug) printf("yydebug: growing stack size from %d to %d\n", old_stacksize, yystacksize); #endif new_yyss = (short *) yyrealloc ((char *)yyss, yystacksize * sizeof (short)); if (new_yyss == 0) return (1); new_yyvs = (YYSTYPE *) yyrealloc ((char *)yyvs, yystacksize * sizeof (YYSTYPE)); if (new_yyvs == 0) { yyfree (new_yyss); return (1); } yyss = new_yyss; yyvs = new_yyvs; return (0); } #line 119 "parser.y" #include "lex_yy.c" /* void yyerror(s) char *s; { syntax_error(s); } */ /* Ansi prototype. If this doesn't work for you... uncomment the above instead. */ void yyerror(char *s) { syntax_error(s); } /* * Unfortunately, my DOS version of FLEX * requires yywrap to be #def'ed, whereas * the UNIX flex expects a proper function. */ /* Not sure if __SC__ is the appropriate thing * to test */ #ifndef __SC__ #ifdef USE_DEFINE #ifndef yywrap #define yywrap() 1 #endif #else if !defined(__alpha) && !defined(__ultrix) int yywrap() { return 1; } #endif #endif #line 339 "y.tab.c" #define YYABORT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYDEBUG #ifdef __cplusplus extern "C" char *getenv(); #else extern char *getenv(); #endif #endif int yyparse() { register int yym, yyn, yystate; register YYSTYPE *yyvsp; register short *yyssp; short *yysse; #if YYDEBUG register YYCONST char *yys; if (yys = getenv("YYDEBUG")) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } #endif yynerrs = 0; yyerrflag = 0; yychar = (-1); if (yyss == 0) { yyss = (short *) yymalloc (YYSTACKSIZE * sizeof (short)); if (yyss == 0) goto yyabort; yyvs = (YYSTYPE *) yymalloc (YYSTACKSIZE * sizeof (YYSTYPE)); if (yyvs == 0) { yyfree (yyss); goto yyabort; } yystacksize = YYSTACKSIZE; } yysse = yyss + yystacksize - 1; yyssp = yyss; yyvsp = yyvs; *yyssp = yystate = 0; goto yyloop; yypush_lex: yyval = yylval; yystate = yytable[yyn]; yypush: if (yyssp >= yysse) { int depth = yyssp - yyss; if (yygrow() != 0) goto yyoverflow; yysse = yyss + yystacksize -1; yyssp = depth + yyss; yyvsp = depth + yyvs; } *++yyssp = yystate; *++yyvsp = yyval; yyloop: if (yyn = yydefred[yystate]) goto yyreduce; yyn = yysindex[yystate]; if (yychar < 0) { if ((yychar = yylex()) < 0) yychar = 0; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("yydebug: state %d, reading %d (%s)\n", yystate, yychar, yys); } #endif } if (yyn != 0 && ((yyn += yychar), ((unsigned)yyn <= (unsigned)YYTABLESIZE)) && yycheck[yyn] == yychar) { #if YYDEBUG if (yydebug) printf("yydebug: state %d, shifting to state %d\n", yystate, yytable[yyn]); #endif if (yyerrflag > 0) --yyerrflag; yychar = (-1); goto yypush_lex; } yyn = yyrindex[yystate]; if (yyn != 0 && ((yyn += yychar), ((unsigned)yyn <= (unsigned)YYTABLESIZE)) && yycheck[yyn] == yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag) goto yyinrecovery; #ifdef lint goto yynewerror; #endif yynewerror: yyerror("syntax error"); #ifdef lint goto yyerrlab; #endif yyerrlab: ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { yyn = yysindex[*yyssp]; if (yyn != 0 && ((yyn += YYERRCODE), ((unsigned)yyn <= (unsigned)YYTABLESIZE)) && yycheck[yyn] == YYERRCODE) { #if YYDEBUG if (yydebug) printf("yydebug: state %d, error recovery shifting\ to state %d\n", *yyssp, yytable[yyn]); #endif goto yypush_lex; } else { #if YYDEBUG if (yydebug) printf("yydebug: error recovery discarding state %d\n", *yyssp); #endif if (yyssp <= yyss) goto yyabort; --yyssp; --yyvsp; } } } else { if (yychar == 0) goto yyabort; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("yydebug: state %d, error recovery discards token %d (%s)\n", yystate, yychar, yys); } #endif yychar = (-1); goto yyloop; } yyreduce: #if YYDEBUG if (yydebug) printf("yydebug: state %d, reducing by rule %d (%s)\n", yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; yyval = yyvsp[1-yym]; switch (yyn) { #line 2 "parser.y" #include "string.h" #include "expr.h" #ifndef __EXTERN_C__ #define __EXTERN_C__ 1 #endif #if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) && defined(__EXTERN_C__) extern "C" { #endif #endif int yylex(void); int yylook(void); int yywrap(void); int yyback(int *, int); void yyerror(char *); /* You may need to put /DLEX_SCANNER in your makefile * if you're using LEX! */ #ifdef LEX_SCANNER /* int yyoutput(int); */ void yyoutput(int); #else void yyoutput(int); #endif #if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) && defined(__EXTERN_C__) } #endif #endif #line 37 "parser.y" typedef union { char *s; /* struct pexpr *expr; */ } YYSTYPE; k; case 12: #line 94 "parser.y" {yyval.s = proio_cons(make_word("="), proio_cons(make_word(yyvsp[-2].s), proio_cons(yyvsp[0].s, NULL))); free(yyvsp[-2].s); } break; case 13: #line 97 "parser.y" {yyval.s = yyvsp[0].s; } break; case 14: #line 100 "parser.y" {yyval.s = make_word(yyvsp[0].s); free(yyvsp[0].s);} break; case 15: #line 102 "parser.y" {yyval.s = make_string(yyvsp[0].s); free(yyvsp[0].s);} break; case 16: #line 104 "parser.y" {yyval.s = make_integer(yyvsp[0].s); free(yyvsp[0].s);} break; case 17: #line 106 "parser.y" {yyval.s = make_real(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); } break; case 18: #line 108 "parser.y" {yyval.s = make_exp(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); } break; case 19: #line 111 "parser.y" {yyval.s = make_exp2(yyvsp[-4].s, yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-4].s); free(yyvsp[-2].s); free(yyvsp[0].s); } break; case 20: #line 115 "parser.y" {yyval.s = yyvsp[0].s;} break; #line 593 "y.tab.c" } yyssp -= yym; yyvsp -= yym; yym = yylhs[yyn]; yystate = *yyssp; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) printf("yydebug: after reduction, shifting from state 0 to\ state %d\n", YYFINAL); #endif yystate = YYFINAL; *++yyssp = YYFINAL; *++yyvsp = yyval; if (yychar < 0) { if ((yychar = yylex()) < 0) yychar = 0; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("yydebug: state %d, reading %d (%s)\n", YYFINAL, yychar, yys); } #endif } if (yychar == 0) goto yyaccept; goto yyloop; } yyn = yygindex[yym]; if (yyn != 0 && ((yyn += yystate), ((unsigned)yyn <= (unsigned)YYTABLESIZE)) && yycheck[yyn] == yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) printf("yydebug: after reduction, shifting from state %d \ to state %d\n", *yyssp, yystate); #endif goto yypush; yyoverflow: yyerror("yacc stack overflow"); yyabort: return (1); yyaccept: return (0); } --software6.opustel.com:846194565:480:-126845:29358 Content-Type: TEXT/plain; SizeOnDisk=3080; name="parser.y" Content-Description: parser.y %{ #include "string.h" #include "expr.h" #ifndef __EXTERN_C__ #define __EXTERN_C__ 1 #endif #if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) && defined(__EXTERN_C__) extern "C" { #endif #endif int yylex(void); int yylook(void); int yywrap(void); int yyback(int *, int); void yyerror(char *); /* You may need to put /DLEX_SCANNER in your makefile * if you're using LEX! */ #ifdef LEX_SCANNER /* int yyoutput(int); */ void yyoutput(int); #else void yyoutput(int); #endif #if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) && defined(__EXTERN_C__) } #endif #endif %} %union { char *s; /* struct pexpr *expr; */ } %start commands %token INTEGER 1 %token WORD 2 %token STRING 3 %token PERIOD 13 %token OPEN 4 %token CLOSE 5 %token COMMA 6 %token NEWLINE 7 %token ERROR 8 %token OPEN_SQUARE 9 %token CLOSE_SQUARE 10 %token EQUALS 11 %token EXP 14 /* %type command expr arglist arg arg1 */ %type command expr arglist arg arg1 %% commands : /* empty */ | commands command ; command : WORD PERIOD {process_command(proio_cons(make_word($1), NULL)); free($1);} | expr PERIOD {process_command($1);} | error PERIOD {syntax_error("Unrecognized command.");} ; expr : WORD OPEN arglist CLOSE {$$ = proio_cons(make_word($1), $3); free($1);} | OPEN_SQUARE CLOSE_SQUARE {$$ = proio_cons(NULL, NULL);} | OPEN_SQUARE arglist CLOSE_SQUARE {$$ = $2; } ; arglist : {$$ = NULL;} | arg {$$ = proio_cons($1, NULL);} | arg COMMA arglist {$$ = proio_cons($1, $3);} ; arg : WORD EQUALS arg1 {$$ = proio_cons(make_word("="), proio_cons(make_word($1), proio_cons($3, NULL))); free($1); } | arg1 {$$ = $1; } arg1 : WORD {$$ = make_word($1); free($1);} | STRING {$$ = make_string($1); free($1);} | INTEGER {$$ = make_integer($1); free($1);} | INTEGER PERIOD INTEGER {$$ = make_real($1, $3); free($1); free($3); } | INTEGER EXP INTEGER {$$ = make_exp($1, $3); free($1); free($3); } | INTEGER PERIOD INTEGER EXP INTEGER {$$ = make_exp2($1, $3, $5); free($1); free($3); free($5); } | expr {$$ = $1;} ; %% #include "lex_yy.c" /* void yyerror(s) char *s; { syntax_error(s); } */ /* Ansi prototype. If this doesn't work for you... uncomment the above instead. */ void yyerror(char *s) { syntax_error(s); } /* * Unfortunately, my DOS version of FLEX * requires yywrap to be #def'ed, whereas * the UNIX flex expects a proper function. */ /* Not sure if __SC__ is the appropriate thing * to test */ #ifndef __SC__ #ifdef USE_DEFINE #ifndef yywrap #define yywrap() 1 #endif #else if !defined(__alpha) && !defined(__ultrix) int yywrap() { return 1; } #endif #endif --software6.opustel.com:846194565:480:-126845:29358-- - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".