#ifndef lint static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #endif #define YYBYACC 1 #define YYMAJOR 1 #define YYMINOR 9 #define yyclearin (yychar=(-1)) #define yyerrok (yyerrflag=0) #define YYRECOVERING (yyerrflag!=0) #define YYPREFIX "yy" #line 2 "gram.y" /* * * IRBOX, an Ivy driver for infra-red remote controls * * Copyright 1998-1999 * Centre d'Etudes de la Navigation Aerienne * * This is the grammar for reading tables * * Authors: Stephane Chatty * * $Id$ * * Please refer to file version.h for the * copyright notice regarding this software */ extern const char* const ResWords; #include #include #include #include "irtable.h" extern int yyparse (); extern int yylex (); extern int LineNo; static char id_buf [1024]; /* Yeech */ static char id_list_buf [4096]; /* Barf */ static const char* filename = 0; static IrTable* cur_table; #line 42 "gram.y" typedef union { const char *name; int integer; } YYSTYPE; #line 56 "y.tab.c" #define Y_NAME 257 #define Y_TYPE 258 #define Y_BRAND 259 #define Y_EOL 260 #define Y_ID 261 #define Y_STRING 262 #define Y_INT 263 #define YYERRCODE 256 short yylhs[] = { -1, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, }; short yylen[] = { 2, 0, 2, 1, 1, 1, 2, 1, 3, 4, 4, 9, }; short yydefred[] = { 1, 0, 0, 0, 0, 7, 3, 4, 5, 0, 2, 0, 0, 0, 0, 6, 8, 0, 0, 0, 9, 10, 0, 0, 0, 0, 0, 11, }; short yydgoto[] = { 1, 8, 9, 10, }; short yysindex[] = { 0, -255, -248, -43, -42, 0, 0, 0, 0, -58, 0, -243, -242, -254, -245, 0, 0, -240, -249, -241, 0, 0, -239, -238, -237, -236, -232, 0, }; short yyrindex[] = { 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, }; short yygindex[] = { 0, -8, 8, 0, }; #define YYTABLESIZE 205 short yytable[] = { 14, 15, 2, 3, 4, 5, 6, 6, 7, 7, 15, 21, 6, 11, 7, 12, 13, 16, 19, 17, 20, 18, 22, 0, 23, 24, 25, 26, 27, 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, 6, 0, 7, }; short yycheck[] = { 58, 9, 257, 258, 259, 260, 261, 261, 263, 263, 18, 260, 261, 261, 263, 58, 58, 260, 263, 261, 260, 13, 263, -1, 263, 263, 263, 263, 260, -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, 261, -1, 263, }; #define YYFINAL 1 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 263 #if YYDEBUG char *yyname[] = { "end-of-file",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,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,"Y_NAME","Y_TYPE","Y_BRAND", "Y_EOL","Y_ID","Y_STRING","Y_INT", }; char *yyrule[] = { "$accept : instr_list", "instr_list :", "instr_list : instr_list instr", "id : Y_ID", "id : Y_INT", "id_list : id", "id_list : id_list id", "instr : Y_EOL", "instr : Y_NAME Y_ID Y_EOL", "instr : Y_TYPE ':' Y_ID Y_EOL", "instr : Y_BRAND ':' id_list Y_EOL", "instr : id_list ':' Y_INT Y_INT Y_INT Y_INT Y_INT Y_INT Y_EOL", }; #endif #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 500 #define YYMAXDEPTH 500 #endif #endif int yydebug; int yynerrs; int yyerrflag; int yychar; short *yyssp; YYSTYPE *yyvsp; YYSTYPE yyval; YYSTYPE yylval; short yyss[YYSTACKSIZE]; YYSTYPE yyvs[YYSTACKSIZE]; #define yystacksize YYSTACKSIZE #line 115 "gram.y" #include int _DoTee = 0; int tee (int x) { if (_DoTee) { char *s; switch (x) { case ':': s = ":"; break; case Y_EOL: s = "Y_EOL\n"; break; case Y_STRING: s = "STRING"; break; case Y_INT: s = "INT"; break; case Y_ID: s = "ID"; break; case Y_TYPE: s = "TYPE"; break; case Y_BRAND: s = "BRAND"; break; /* case Y_: s = ""; break; */ default : s = "???"; break; } printf ("%s ", s); } return x; } int yyerror (const char *s) { fprintf (stderr, "%s in %s, line %d\n", s, filename, LineNo); return (0); } int yywrap () { return 1; } IrTable* IrTableReadFile (const char* file) { extern void LexInit (); extern FILE *yyin; int result; LexInit (); filename = file; if (!(yyin = fopen (file,"r"))) { char err [1024]; fprintf (stderr, "Cannot open %s\n", file); return 0; } cur_table = IrCreateTable (); if (yyparse ()) { result = 0; } fclose (yyin); return cur_table; } #line 276 "y.tab.c" #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab int yyparse() { register int yym, yyn, yystate; #if YYDEBUG register char *yys; extern char *getenv(); if (yys = getenv("YYDEBUG")) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } #endif yynerrs = 0; yyerrflag = 0; yychar = (-1); yyssp = yyss; yyvsp = yyvs; *yyssp = yystate = 0; yyloop: if (yyn = yydefred[yystate]) goto yyreduce; 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("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif } if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif if (yyssp >= yyss + yystacksize - 1) { goto yyoverflow; } *++yyssp = yystate = yytable[yyn]; *++yyvsp = yylval; yychar = (-1); if (yyerrflag > 0) --yyerrflag; goto yyloop; } if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && yyn <= 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 (;;) { if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, error recovery shifting\ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); #endif if (yyssp >= yyss + yystacksize - 1) { goto yyoverflow; } *++yyssp = yystate = yytable[yyn]; *++yyvsp = yylval; goto yyloop; } else { #if YYDEBUG if (yydebug) printf("%sdebug: error recovery discarding state %d\n", YYPREFIX, *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("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif yychar = (-1); goto yyloop; } yyreduce: #if YYDEBUG if (yydebug) printf("%sdebug: state %d, reducing by rule %d (%s)\n", YYPREFIX, yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; yyval = yyvsp[1-yym]; switch (yyn) { case 3: #line 63 "gram.y" { strcpy (id_buf, yyvsp[0].name); free ((char*) yyvsp[0].name); /* was allocated by strdup in lex file */ yyval.name = id_buf; } break; case 4: #line 69 "gram.y" { sprintf (id_buf, "%d", yyvsp[0].integer); yyval.name = id_buf; } break; case 5: #line 77 "gram.y" { strcpy (id_list_buf, yyvsp[0].name); yyval.name = yyvsp[0].name; } break; case 6: #line 82 "gram.y" { strcat (id_list_buf, " "); strcat (id_list_buf, yyvsp[0].name); yyval.name = id_list_buf; } break; case 8: #line 93 "gram.y" { IrTableName (cur_table, yyvsp[-1].name); } break; case 9: #line 98 "gram.y" { IrTableType (cur_table, yyvsp[-1].name); } break; case 10: #line 103 "gram.y" { IrTableAddBrand (cur_table, yyvsp[-1].name); } break; case 11: #line 108 "gram.y" { IrTableAddKey (cur_table, yyvsp[-8].name, yyvsp[-6].integer, yyvsp[-5].integer, yyvsp[-4].integer, yyvsp[-3].integer, yyvsp[-2].integer, yyvsp[-1].integer); } break; #line 471 "y.tab.c" } yyssp -= yym; yystate = *yyssp; yyvsp -= yym; yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state 0 to\ state %d\n", YYPREFIX, 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("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } if (yychar == 0) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state %d \ to state %d\n", YYPREFIX, *yyssp, yystate); #endif if (yyssp >= yyss + yystacksize - 1) { goto yyoverflow; } *++yyssp = yystate; *++yyvsp = yyval; goto yyloop; yyoverflow: yyerror("yacc stack overflow"); yyabort: return (1); yyaccept: return (0); }