rlm@1: rlm@1: /* A Bison parser, made from expr.y rlm@1: by GNU Bison version 1.28 */ rlm@1: rlm@1: #define YYBISON 1 /* Identify Bison output. */ rlm@1: rlm@1: #define TOKEN_IDENTIFIER 257 rlm@1: #define TOKEN_DOT 258 rlm@1: #define TOKEN_STAR 259 rlm@1: #define TOKEN_ARROW 260 rlm@1: #define TOKEN_ADDR 261 rlm@1: #define TOKEN_SIZEOF 262 rlm@1: #define TOKEN_NUMBER 263 rlm@1: rlm@1: #line 1 "expr.y" rlm@1: rlm@1: namespace std { rlm@1: #include rlm@1: #include rlm@1: #include rlm@1: #include rlm@1: } rlm@1: rlm@1: using namespace std; rlm@1: rlm@1: #include "../common/System.h" rlm@1: #include "../gba/elf.h" rlm@1: #include "exprNode.h" rlm@1: rlm@1: extern int yyerror(char *); rlm@1: extern int yylex(); rlm@1: extern char *yytext; rlm@1: rlm@1: rlm@1: //#define YYERROR_VERBOSE 1 rlm@1: //#define YYDEBUG 1 rlm@1: rlm@1: Node *result = NULL; rlm@1: #ifndef YYSTYPE rlm@1: #define YYSTYPE int rlm@1: #endif rlm@1: #include rlm@1: rlm@1: #ifndef __cplusplus rlm@1: #ifndef __STDC__ rlm@1: #define const rlm@1: #endif rlm@1: #endif rlm@1: rlm@1: rlm@1: rlm@1: #define YYFINAL 26 rlm@1: #define YYFLAG -32768 rlm@1: #define YYNTBASE 14 rlm@1: rlm@1: #define YYTRANSLATE(x) ((unsigned)(x) <= 263 ? yytranslate[x] : 19) rlm@1: rlm@1: static const char yytranslate[] = { 0, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 11, rlm@1: 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 10, 2, 13, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, rlm@1: 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, rlm@1: 7, 8, 9 rlm@1: }; rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: static const short yyprhs[] = { 0, rlm@1: 0, 2, 4, 8, 12, 16, 21, 23, 26, 29, rlm@1: 34, 36 rlm@1: }; rlm@1: rlm@1: static const short yyrhs[] = { 15, rlm@1: 0, 16, 0, 11, 15, 12, 0, 15, 4, 18, rlm@1: 0, 15, 6, 18, 0, 15, 10, 17, 13, 0, rlm@1: 18, 0, 5, 15, 0, 7, 15, 0, 8, 11, rlm@1: 15, 12, 0, 9, 0, 3, 0 rlm@1: }; rlm@1: rlm@1: #endif rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: static const short yyrline[] = { 0, rlm@1: 32, 35, 36, 37, 38, 39, 42, 43, 44, 45, rlm@1: 49, 53 rlm@1: }; rlm@1: #endif rlm@1: rlm@1: rlm@1: #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) rlm@1: rlm@1: static const char * const yytname[] = { "$","error","$undefined.","TOKEN_IDENTIFIER", rlm@1: "TOKEN_DOT","TOKEN_STAR","TOKEN_ARROW","TOKEN_ADDR","TOKEN_SIZEOF","TOKEN_NUMBER", rlm@1: "'['","'('","')'","']'","final","expression","simple_expression","number","ident", NULL rlm@1: }; rlm@1: #endif rlm@1: rlm@1: static const short yyr1[] = { 0, rlm@1: 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, rlm@1: 17, 18 rlm@1: }; rlm@1: rlm@1: static const short yyr2[] = { 0, rlm@1: 1, 1, 3, 3, 3, 4, 1, 2, 2, 4, rlm@1: 1, 1 rlm@1: }; rlm@1: rlm@1: static const short yydefact[] = { 0, rlm@1: 12, 0, 0, 0, 0, 1, 2, 7, 8, 9, rlm@1: 0, 0, 0, 0, 0, 0, 3, 4, 5, 11, rlm@1: 0, 10, 6, 0, 0, 0 rlm@1: }; rlm@1: rlm@1: static const short yydefgoto[] = { 24, rlm@1: 6, 7, 21, 8 rlm@1: }; rlm@1: rlm@1: static const short yypact[] = { -1, rlm@1: -32768, -1, -1, -6, -1, 17,-32768,-32768, 17, 17, rlm@1: -1, 7, 5, 5, 13, 8,-32768,-32768,-32768,-32768, rlm@1: 11,-32768,-32768, 25, 26,-32768 rlm@1: }; rlm@1: rlm@1: static const short yypgoto[] = {-32768, rlm@1: -2,-32768,-32768, 2 rlm@1: }; rlm@1: rlm@1: rlm@1: #define YYLAST 27 rlm@1: rlm@1: rlm@1: static const short yytable[] = { 9, rlm@1: 10, 1, 12, 2, 11, 3, 4, 1, 16, 5, rlm@1: 13, 13, 14, 14, 18, 19, 15, 15, 17, 22, rlm@1: 13, 20, 14, 23, 25, 26, 15 rlm@1: }; rlm@1: rlm@1: static const short yycheck[] = { 2, rlm@1: 3, 3, 5, 5, 11, 7, 8, 3, 11, 11, rlm@1: 4, 4, 6, 6, 13, 14, 10, 10, 12, 12, rlm@1: 4, 9, 6, 13, 0, 0, 10 rlm@1: }; rlm@1: /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ rlm@1: #line 3 "/usr/lib/bison.simple" rlm@1: /* This file comes from bison-1.28. */ rlm@1: rlm@1: /* Skeleton output parser for bison, rlm@1: Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. rlm@1: rlm@1: This program is free software; you can redistribute it and/or modify rlm@1: it under the terms of the GNU General Public License as published by rlm@1: the Free Software Foundation; either version 2, or (at your option) rlm@1: any later version. rlm@1: rlm@1: This program is distributed in the hope that it will be useful, rlm@1: but WITHOUT ANY WARRANTY; without even the implied warranty of rlm@1: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the rlm@1: GNU General Public License for more details. rlm@1: rlm@1: You should have received a copy of the GNU General Public License rlm@1: along with this program; if not, write to the Free Software rlm@1: Foundation, Inc., 59 Temple Place - Suite 330, rlm@1: Boston, MA 02111-1307, USA. */ rlm@1: rlm@1: /* As a special exception, when this file is copied by Bison into a rlm@1: Bison output file, you may use that output file without restriction. rlm@1: This special exception was added by the Free Software Foundation rlm@1: in version 1.24 of Bison. */ rlm@1: rlm@1: /* This is the parser code that is written into each bison parser rlm@1: when the %semantic_parser declaration is not specified in the grammar. rlm@1: It was written by Richard Stallman by simplifying the hairy parser rlm@1: used when %semantic_parser is specified. */ rlm@1: rlm@1: #ifndef YYSTACK_USE_ALLOCA rlm@1: #ifdef alloca rlm@1: #define YYSTACK_USE_ALLOCA rlm@1: #else /* alloca not defined */ rlm@1: #ifdef __GNUC__ rlm@1: #define YYSTACK_USE_ALLOCA rlm@1: #define alloca __builtin_alloca rlm@1: #else /* not GNU C. */ rlm@1: #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) rlm@1: #define YYSTACK_USE_ALLOCA rlm@1: #include rlm@1: #else /* not sparc */ rlm@1: /* We think this test detects Watcom and Microsoft C. */ rlm@1: /* This used to test MSDOS, but that is a bad idea rlm@1: since that symbol is in the user namespace. */ rlm@1: #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) rlm@1: #if 0 /* No need for malloc.h, which pollutes the namespace; rlm@1: instead, just don't use alloca. */ rlm@1: #include rlm@1: #endif rlm@1: #else /* not MSDOS, or __TURBOC__ */ rlm@1: #if defined(_AIX) rlm@1: /* I don't know what this was needed for, but it pollutes the namespace. rlm@1: So I turned it off. rms, 2 May 1997. */ rlm@1: /* #include */ rlm@1: #pragma alloca rlm@1: #define YYSTACK_USE_ALLOCA rlm@1: #else /* not MSDOS, or __TURBOC__, or _AIX */ rlm@1: #if 0 rlm@1: #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, rlm@1: and on HPUX 10. Eventually we can turn this on. */ rlm@1: #define YYSTACK_USE_ALLOCA rlm@1: #define alloca __builtin_alloca rlm@1: #endif /* __hpux */ rlm@1: #endif rlm@1: #endif /* not _AIX */ rlm@1: #endif /* not MSDOS, or __TURBOC__ */ rlm@1: #endif /* not sparc */ rlm@1: #endif /* not GNU C */ rlm@1: #endif /* alloca not defined */ rlm@1: #endif /* YYSTACK_USE_ALLOCA not defined */ rlm@1: rlm@1: #ifdef YYSTACK_USE_ALLOCA rlm@1: #define YYSTACK_ALLOC alloca rlm@1: #else rlm@1: #define YYSTACK_ALLOC malloc rlm@1: #endif rlm@1: rlm@1: /* Note: there must be only one dollar sign in this file. rlm@1: It is replaced by the list of actions, each action rlm@1: as one case of the switch. */ rlm@1: rlm@1: #define yyerrok (yyerrstatus = 0) rlm@1: #define yyclearin (yychar = YYEMPTY) rlm@1: #define YYEMPTY -2 rlm@1: #define YYEOF 0 rlm@1: #define YYACCEPT goto yyacceptlab rlm@1: #define YYABORT goto yyabortlab rlm@1: #define YYERROR goto yyerrlab1 rlm@1: /* Like YYERROR except do call yyerror. rlm@1: This remains here temporarily to ease the rlm@1: transition to the new meaning of YYERROR, for GCC. rlm@1: Once GCC version 2 has supplanted version 1, this can go. */ rlm@1: #define YYFAIL goto yyerrlab rlm@1: #define YYRECOVERING() (!!yyerrstatus) rlm@1: #define YYBACKUP(token, value) \ rlm@1: do \ rlm@1: if (yychar == YYEMPTY && yylen == 1) \ rlm@1: { yychar = (token), yylval = (value); \ rlm@1: yychar1 = YYTRANSLATE (yychar); \ rlm@1: YYPOPSTACK; \ rlm@1: goto yybackup; \ rlm@1: } \ rlm@1: else \ rlm@1: { yyerror ("syntax error: cannot back up"); YYERROR; } \ rlm@1: while (0) rlm@1: rlm@1: #define YYTERROR 1 rlm@1: #define YYERRCODE 256 rlm@1: rlm@1: #ifndef YYPURE rlm@1: #define YYLEX yylex() rlm@1: #endif rlm@1: rlm@1: #ifdef YYPURE rlm@1: #ifdef YYLSP_NEEDED rlm@1: #ifdef YYLEX_PARAM rlm@1: #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) rlm@1: #else rlm@1: #define YYLEX yylex(&yylval, &yylloc) rlm@1: #endif rlm@1: #else /* not YYLSP_NEEDED */ rlm@1: #ifdef YYLEX_PARAM rlm@1: #define YYLEX yylex(&yylval, YYLEX_PARAM) rlm@1: #else rlm@1: #define YYLEX yylex(&yylval) rlm@1: #endif rlm@1: #endif /* not YYLSP_NEEDED */ rlm@1: #endif rlm@1: rlm@1: /* If nonreentrant, generate the variables here */ rlm@1: rlm@1: #ifndef YYPURE rlm@1: rlm@1: int yychar; /* the lookahead symbol */ rlm@1: YYSTYPE yylval; /* the semantic value of the */ rlm@1: /* lookahead symbol */ rlm@1: rlm@1: #ifdef YYLSP_NEEDED rlm@1: YYLTYPE yylloc; /* location data for the lookahead */ rlm@1: /* symbol */ rlm@1: #endif rlm@1: rlm@1: int yynerrs; /* number of parse errors so far */ rlm@1: #endif /* not YYPURE */ rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: int yydebug; /* nonzero means print parse trace */ rlm@1: /* Since this is uninitialized, it does not stop multiple parsers rlm@1: from coexisting. */ rlm@1: #endif rlm@1: rlm@1: /* YYINITDEPTH indicates the initial size of the parser's stacks */ rlm@1: rlm@1: #ifndef YYINITDEPTH rlm@1: #define YYINITDEPTH 200 rlm@1: #endif rlm@1: rlm@1: /* YYMAXDEPTH is the maximum size the stacks can grow to rlm@1: (effective only if the built-in stack extension method is used). */ rlm@1: rlm@1: #if YYMAXDEPTH == 0 rlm@1: #undef YYMAXDEPTH rlm@1: #endif rlm@1: rlm@1: #ifndef YYMAXDEPTH rlm@1: #define YYMAXDEPTH 10000 rlm@1: #endif rlm@1: rlm@1: /* Define __yy_memcpy. Note that the size argument rlm@1: should be passed with type unsigned int, because that is what the non-GCC rlm@1: definitions require. With GCC, __builtin_memcpy takes an arg rlm@1: of type size_t, but it can handle unsigned int. */ rlm@1: rlm@1: #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ rlm@1: #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) rlm@1: #else /* not GNU C or C++ */ rlm@1: #ifndef __cplusplus rlm@1: rlm@1: /* This is the most reliable way to avoid incompatibilities rlm@1: in available built-in functions on various systems. */ rlm@1: static void rlm@1: __yy_memcpy (to, from, count) rlm@1: char *to; rlm@1: char *from; rlm@1: unsigned int count; rlm@1: { rlm@1: register char *f = from; rlm@1: register char *t = to; rlm@1: register int i = count; rlm@1: rlm@1: while (i-- > 0) rlm@1: *t++ = *f++; rlm@1: } rlm@1: rlm@1: #else /* __cplusplus */ rlm@1: rlm@1: /* This is the most reliable way to avoid incompatibilities rlm@1: in available built-in functions on various systems. */ rlm@1: static void rlm@1: __yy_memcpy (char *to, char *from, unsigned int count) rlm@1: { rlm@1: register char *t = to; rlm@1: register char *f = from; rlm@1: register int i = count; rlm@1: rlm@1: while (i-- > 0) rlm@1: *t++ = *f++; rlm@1: } rlm@1: rlm@1: #endif rlm@1: #endif rlm@1: rlm@1: #line 217 "/usr/lib/bison.simple" rlm@1: rlm@1: /* The user can define YYPARSE_PARAM as the name of an argument to be passed rlm@1: into yyparse. The argument should have type void *. rlm@1: It should actually point to an object. rlm@1: Grammar actions can access the variable by casting it rlm@1: to the proper pointer type. */ rlm@1: rlm@1: #ifdef YYPARSE_PARAM rlm@1: #ifdef __cplusplus rlm@1: #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM rlm@1: #define YYPARSE_PARAM_DECL rlm@1: #else /* not __cplusplus */ rlm@1: #define YYPARSE_PARAM_ARG YYPARSE_PARAM rlm@1: #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; rlm@1: #endif /* not __cplusplus */ rlm@1: #else /* not YYPARSE_PARAM */ rlm@1: #define YYPARSE_PARAM_ARG rlm@1: #define YYPARSE_PARAM_DECL rlm@1: #endif /* not YYPARSE_PARAM */ rlm@1: rlm@1: /* Prevent warning if -Wstrict-prototypes. */ rlm@1: #ifdef __GNUC__ rlm@1: #ifdef YYPARSE_PARAM rlm@1: int yyparse (void *); rlm@1: #else rlm@1: int yyparse (void); rlm@1: #endif rlm@1: #endif rlm@1: rlm@1: int rlm@1: yyparse(YYPARSE_PARAM_ARG) rlm@1: YYPARSE_PARAM_DECL rlm@1: { rlm@1: register int yystate; rlm@1: register int yyn; rlm@1: register short *yyssp; rlm@1: register YYSTYPE *yyvsp; rlm@1: int yyerrstatus; /* number of tokens to shift before error messages enabled */ rlm@1: int yychar1 = 0; /* lookahead token as an internal (translated) token number */ rlm@1: rlm@1: short yyssa[YYINITDEPTH]; /* the state stack */ rlm@1: YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ rlm@1: rlm@1: short *yyss = yyssa; /* refer to the stacks thru separate pointers */ rlm@1: YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ rlm@1: rlm@1: #ifdef YYLSP_NEEDED rlm@1: YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ rlm@1: YYLTYPE *yyls = yylsa; rlm@1: YYLTYPE *yylsp; rlm@1: rlm@1: #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) rlm@1: #else rlm@1: #define YYPOPSTACK (yyvsp--, yyssp--) rlm@1: #endif rlm@1: rlm@1: int yystacksize = YYINITDEPTH; rlm@1: int yyfree_stacks = 0; rlm@1: rlm@1: #ifdef YYPURE rlm@1: int yychar; rlm@1: YYSTYPE yylval; rlm@1: int yynerrs; rlm@1: #ifdef YYLSP_NEEDED rlm@1: YYLTYPE yylloc; rlm@1: #endif rlm@1: #endif rlm@1: rlm@1: YYSTYPE yyval; /* the variable used to return */ rlm@1: /* semantic values from the action */ rlm@1: /* routines */ rlm@1: rlm@1: int yylen; rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: fprintf(stderr, "Starting parse\n"); rlm@1: #endif rlm@1: rlm@1: yystate = 0; rlm@1: yyerrstatus = 0; rlm@1: yynerrs = 0; rlm@1: yychar = YYEMPTY; /* Cause a token to be read. */ rlm@1: rlm@1: /* Initialize stack pointers. rlm@1: Waste one element of value and location stack rlm@1: so that they stay on the same level as the state stack. rlm@1: The wasted elements are never initialized. */ rlm@1: rlm@1: yyssp = yyss - 1; rlm@1: yyvsp = yyvs; rlm@1: #ifdef YYLSP_NEEDED rlm@1: yylsp = yyls; rlm@1: #endif rlm@1: rlm@1: /* Push a new state, which is found in yystate . */ rlm@1: /* In all cases, when you get here, the value and location stacks rlm@1: have just been pushed. so pushing a state here evens the stacks. */ rlm@1: yynewstate: rlm@1: rlm@1: *++yyssp = yystate; rlm@1: rlm@1: if (yyssp >= yyss + yystacksize - 1) rlm@1: { rlm@1: /* Give user a chance to reallocate the stack */ rlm@1: /* Use copies of these so that the &'s don't force the real ones into memory. */ rlm@1: YYSTYPE *yyvs1 = yyvs; rlm@1: short *yyss1 = yyss; rlm@1: #ifdef YYLSP_NEEDED rlm@1: YYLTYPE *yyls1 = yyls; rlm@1: #endif rlm@1: rlm@1: /* Get the current used size of the three stacks, in elements. */ rlm@1: int size = yyssp - yyss + 1; rlm@1: rlm@1: #ifdef yyoverflow rlm@1: /* Each stack pointer address is followed by the size of rlm@1: the data in use in that stack, in bytes. */ rlm@1: #ifdef YYLSP_NEEDED rlm@1: /* This used to be a conditional around just the two extra args, rlm@1: but that might be undefined if yyoverflow is a macro. */ rlm@1: yyoverflow("parser stack overflow", rlm@1: &yyss1, size * sizeof (*yyssp), rlm@1: &yyvs1, size * sizeof (*yyvsp), rlm@1: &yyls1, size * sizeof (*yylsp), rlm@1: &yystacksize); rlm@1: #else rlm@1: yyoverflow("parser stack overflow", rlm@1: &yyss1, size * sizeof (*yyssp), rlm@1: &yyvs1, size * sizeof (*yyvsp), rlm@1: &yystacksize); rlm@1: #endif rlm@1: rlm@1: yyss = yyss1; yyvs = yyvs1; rlm@1: #ifdef YYLSP_NEEDED rlm@1: yyls = yyls1; rlm@1: #endif rlm@1: #else /* no yyoverflow */ rlm@1: /* Extend the stack our own way. */ rlm@1: if (yystacksize >= YYMAXDEPTH) rlm@1: { rlm@1: yyerror("parser stack overflow"); rlm@1: if (yyfree_stacks) rlm@1: { rlm@1: free (yyss); rlm@1: free (yyvs); rlm@1: #ifdef YYLSP_NEEDED rlm@1: free (yyls); rlm@1: #endif rlm@1: } rlm@1: return 2; rlm@1: } rlm@1: yystacksize *= 2; rlm@1: if (yystacksize > YYMAXDEPTH) rlm@1: yystacksize = YYMAXDEPTH; rlm@1: #ifndef YYSTACK_USE_ALLOCA rlm@1: yyfree_stacks = 1; rlm@1: #endif rlm@1: yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); rlm@1: __yy_memcpy ((char *)yyss, (char *)yyss1, rlm@1: size * (unsigned int) sizeof (*yyssp)); rlm@1: yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); rlm@1: __yy_memcpy ((char *)yyvs, (char *)yyvs1, rlm@1: size * (unsigned int) sizeof (*yyvsp)); rlm@1: #ifdef YYLSP_NEEDED rlm@1: yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); rlm@1: __yy_memcpy ((char *)yyls, (char *)yyls1, rlm@1: size * (unsigned int) sizeof (*yylsp)); rlm@1: #endif rlm@1: #endif /* no yyoverflow */ rlm@1: rlm@1: yyssp = yyss + size - 1; rlm@1: yyvsp = yyvs + size - 1; rlm@1: #ifdef YYLSP_NEEDED rlm@1: yylsp = yyls + size - 1; rlm@1: #endif rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: fprintf(stderr, "Stack size increased to %d\n", yystacksize); rlm@1: #endif rlm@1: rlm@1: if (yyssp >= yyss + yystacksize - 1) rlm@1: YYABORT; rlm@1: } rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: fprintf(stderr, "Entering state %d\n", yystate); rlm@1: #endif rlm@1: rlm@1: goto yybackup; rlm@1: yybackup: rlm@1: rlm@1: /* Do appropriate processing given the current state. */ rlm@1: /* Read a lookahead token if we need one and don't already have one. */ rlm@1: /* yyresume: */ rlm@1: rlm@1: /* First try to decide what to do without reference to lookahead token. */ rlm@1: rlm@1: yyn = yypact[yystate]; rlm@1: if (yyn == YYFLAG) rlm@1: goto yydefault; rlm@1: rlm@1: /* Not known => get a lookahead token if don't already have one. */ rlm@1: rlm@1: /* yychar is either YYEMPTY or YYEOF rlm@1: or a valid token in external form. */ rlm@1: rlm@1: if (yychar == YYEMPTY) rlm@1: { rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: fprintf(stderr, "Reading a token: "); rlm@1: #endif rlm@1: yychar = YYLEX; rlm@1: } rlm@1: rlm@1: /* Convert token to internal form (in yychar1) for indexing tables with */ rlm@1: rlm@1: if (yychar <= 0) /* This means end of input. */ rlm@1: { rlm@1: yychar1 = 0; rlm@1: yychar = YYEOF; /* Don't call YYLEX any more */ rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: fprintf(stderr, "Now at end of input.\n"); rlm@1: #endif rlm@1: } rlm@1: else rlm@1: { rlm@1: yychar1 = YYTRANSLATE(yychar); rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: { rlm@1: fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); rlm@1: /* Give the individual parser a way to print the precise meaning rlm@1: of a token, for further debugging info. */ rlm@1: #ifdef YYPRINT rlm@1: YYPRINT (stderr, yychar, yylval); rlm@1: #endif rlm@1: fprintf (stderr, ")\n"); rlm@1: } rlm@1: #endif rlm@1: } rlm@1: rlm@1: yyn += yychar1; rlm@1: if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) rlm@1: goto yydefault; rlm@1: rlm@1: yyn = yytable[yyn]; rlm@1: rlm@1: /* yyn is what to do for this token type in this state. rlm@1: Negative => reduce, -yyn is rule number. rlm@1: Positive => shift, yyn is new state. rlm@1: New state is final state => don't bother to shift, rlm@1: just return success. rlm@1: 0, or most negative number => error. */ rlm@1: rlm@1: if (yyn < 0) rlm@1: { rlm@1: if (yyn == YYFLAG) rlm@1: goto yyerrlab; rlm@1: yyn = -yyn; rlm@1: goto yyreduce; rlm@1: } rlm@1: else if (yyn == 0) rlm@1: goto yyerrlab; rlm@1: rlm@1: if (yyn == YYFINAL) rlm@1: YYACCEPT; rlm@1: rlm@1: /* Shift the lookahead token. */ rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); rlm@1: #endif rlm@1: rlm@1: /* Discard the token being shifted unless it is eof. */ rlm@1: if (yychar != YYEOF) rlm@1: yychar = YYEMPTY; rlm@1: rlm@1: *++yyvsp = yylval; rlm@1: #ifdef YYLSP_NEEDED rlm@1: *++yylsp = yylloc; rlm@1: #endif rlm@1: rlm@1: /* count tokens shifted since error; after three, turn off error status. */ rlm@1: if (yyerrstatus) yyerrstatus--; rlm@1: rlm@1: yystate = yyn; rlm@1: goto yynewstate; rlm@1: rlm@1: /* Do the default action for the current state. */ rlm@1: yydefault: rlm@1: rlm@1: yyn = yydefact[yystate]; rlm@1: if (yyn == 0) rlm@1: goto yyerrlab; rlm@1: rlm@1: /* Do a reduction. yyn is the number of a rule to reduce with. */ rlm@1: yyreduce: rlm@1: yylen = yyr2[yyn]; rlm@1: if (yylen > 0) rlm@1: yyval = yyvsp[1-yylen]; /* implement default value of the action */ rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: { rlm@1: int i; rlm@1: rlm@1: fprintf (stderr, "Reducing via rule %d (line %d), ", rlm@1: yyn, yyrline[yyn]); rlm@1: rlm@1: /* Print the symbols being reduced, and their result. */ rlm@1: for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) rlm@1: fprintf (stderr, "%s ", yytname[yyrhs[i]]); rlm@1: fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); rlm@1: } rlm@1: #endif rlm@1: rlm@1: rlm@1: switch (yyn) { rlm@1: rlm@1: case 1: rlm@1: #line 32 "expr.y" rlm@1: { result = yyvsp[0]; ; rlm@1: break;} rlm@1: case 2: rlm@1: #line 36 "expr.y" rlm@1: { yyval = yyvsp[0]; ; rlm@1: break;} rlm@1: case 3: rlm@1: #line 37 "expr.y" rlm@1: { yyval = yyvsp[-1]; ; rlm@1: break;} rlm@1: case 4: rlm@1: #line 38 "expr.y" rlm@1: { yyval = exprNodeDot(yyvsp[-2], yyvsp[0]); ; rlm@1: break;} rlm@1: case 5: rlm@1: #line 39 "expr.y" rlm@1: { yyval = exprNodeArrow(yyvsp[-2], yyvsp[0]); ; rlm@1: break;} rlm@1: case 6: rlm@1: #line 40 "expr.y" rlm@1: { yyval = exprNodeArray(yyvsp[-3], yyvsp[-1]); ; rlm@1: break;} rlm@1: case 7: rlm@1: #line 43 "expr.y" rlm@1: { yyval = yyvsp[0]; ; rlm@1: break;} rlm@1: case 8: rlm@1: #line 44 "expr.y" rlm@1: { yyval = exprNodeStar(yyvsp[0]); ; rlm@1: break;} rlm@1: case 9: rlm@1: #line 45 "expr.y" rlm@1: { yyval = exprNodeAddr(yyvsp[0]); ; rlm@1: break;} rlm@1: case 10: rlm@1: #line 46 "expr.y" rlm@1: { yyval = exprNodeSizeof(yyvsp[-1]); ; rlm@1: break;} rlm@1: case 11: rlm@1: #line 50 "expr.y" rlm@1: { yyval = exprNodeNumber(); ; rlm@1: break;} rlm@1: case 12: rlm@1: #line 54 "expr.y" rlm@1: {yyval = exprNodeIdentifier(); ; rlm@1: break;} rlm@1: } rlm@1: /* the action file gets copied in in place of this dollarsign */ rlm@1: #line 543 "/usr/lib/bison.simple" rlm@1: rlm@1: yyvsp -= yylen; rlm@1: yyssp -= yylen; rlm@1: #ifdef YYLSP_NEEDED rlm@1: yylsp -= yylen; rlm@1: #endif rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: { rlm@1: short *ssp1 = yyss - 1; rlm@1: fprintf (stderr, "state stack now"); rlm@1: while (ssp1 != yyssp) rlm@1: fprintf (stderr, " %d", *++ssp1); rlm@1: fprintf (stderr, "\n"); rlm@1: } rlm@1: #endif rlm@1: rlm@1: *++yyvsp = yyval; rlm@1: rlm@1: #ifdef YYLSP_NEEDED rlm@1: yylsp++; rlm@1: if (yylen == 0) rlm@1: { rlm@1: yylsp->first_line = yylloc.first_line; rlm@1: yylsp->first_column = yylloc.first_column; rlm@1: yylsp->last_line = (yylsp-1)->last_line; rlm@1: yylsp->last_column = (yylsp-1)->last_column; rlm@1: yylsp->text = 0; rlm@1: } rlm@1: else rlm@1: { rlm@1: yylsp->last_line = (yylsp+yylen-1)->last_line; rlm@1: yylsp->last_column = (yylsp+yylen-1)->last_column; rlm@1: } rlm@1: #endif rlm@1: rlm@1: /* Now "shift" the result of the reduction. rlm@1: Determine what state that goes to, rlm@1: based on the state we popped back to rlm@1: and the rule number reduced by. */ rlm@1: rlm@1: yyn = yyr1[yyn]; rlm@1: rlm@1: yystate = yypgoto[yyn - YYNTBASE] + *yyssp; rlm@1: if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) rlm@1: yystate = yytable[yystate]; rlm@1: else rlm@1: yystate = yydefgoto[yyn - YYNTBASE]; rlm@1: rlm@1: goto yynewstate; rlm@1: rlm@1: yyerrlab: /* here on detecting error */ rlm@1: rlm@1: if (! yyerrstatus) rlm@1: /* If not already recovering from an error, report this error. */ rlm@1: { rlm@1: ++yynerrs; rlm@1: rlm@1: #ifdef YYERROR_VERBOSE rlm@1: yyn = yypact[yystate]; rlm@1: rlm@1: if (yyn > YYFLAG && yyn < YYLAST) rlm@1: { rlm@1: int size = 0; rlm@1: char *msg; rlm@1: int x, count; rlm@1: rlm@1: count = 0; rlm@1: /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ rlm@1: for (x = (yyn < 0 ? -yyn : 0); rlm@1: x < (sizeof(yytname) / sizeof(char *)); x++) rlm@1: if (yycheck[x + yyn] == x) rlm@1: size += strlen(yytname[x]) + 15, count++; rlm@1: msg = (char *) malloc(size + 15); rlm@1: if (msg != 0) rlm@1: { rlm@1: strcpy(msg, "parse error"); rlm@1: rlm@1: if (count < 5) rlm@1: { rlm@1: count = 0; rlm@1: for (x = (yyn < 0 ? -yyn : 0); rlm@1: x < (sizeof(yytname) / sizeof(char *)); x++) rlm@1: if (yycheck[x + yyn] == x) rlm@1: { rlm@1: strcat(msg, count == 0 ? ", expecting `" : " or `"); rlm@1: strcat(msg, yytname[x]); rlm@1: strcat(msg, "'"); rlm@1: count++; rlm@1: } rlm@1: } rlm@1: yyerror(msg); rlm@1: free(msg); rlm@1: } rlm@1: else rlm@1: yyerror ("parse error; also virtual memory exceeded"); rlm@1: } rlm@1: else rlm@1: #endif /* YYERROR_VERBOSE */ rlm@1: yyerror("parse error"); rlm@1: } rlm@1: rlm@1: goto yyerrlab1; rlm@1: yyerrlab1: /* here on error raised explicitly by an action */ rlm@1: rlm@1: if (yyerrstatus == 3) rlm@1: { rlm@1: /* if just tried and failed to reuse lookahead token after an error, discard it. */ rlm@1: rlm@1: /* return failure if at end of input */ rlm@1: if (yychar == YYEOF) rlm@1: YYABORT; rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); rlm@1: #endif rlm@1: rlm@1: yychar = YYEMPTY; rlm@1: } rlm@1: rlm@1: /* Else will try to reuse lookahead token rlm@1: after shifting the error token. */ rlm@1: rlm@1: yyerrstatus = 3; /* Each real token shifted decrements this */ rlm@1: rlm@1: goto yyerrhandle; rlm@1: rlm@1: yyerrdefault: /* current state does not do anything special for the error token. */ rlm@1: rlm@1: #if 0 rlm@1: /* This is wrong; only states that explicitly want error tokens rlm@1: should shift them. */ rlm@1: yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ rlm@1: if (yyn) goto yydefault; rlm@1: #endif rlm@1: rlm@1: yyerrpop: /* pop the current state because it cannot handle the error token */ rlm@1: rlm@1: if (yyssp == yyss) YYABORT; rlm@1: yyvsp--; rlm@1: yystate = *--yyssp; rlm@1: #ifdef YYLSP_NEEDED rlm@1: yylsp--; rlm@1: #endif rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: { rlm@1: short *ssp1 = yyss - 1; rlm@1: fprintf (stderr, "Error: state stack now"); rlm@1: while (ssp1 != yyssp) rlm@1: fprintf (stderr, " %d", *++ssp1); rlm@1: fprintf (stderr, "\n"); rlm@1: } rlm@1: #endif rlm@1: rlm@1: yyerrhandle: rlm@1: rlm@1: yyn = yypact[yystate]; rlm@1: if (yyn == YYFLAG) rlm@1: goto yyerrdefault; rlm@1: rlm@1: yyn += YYTERROR; rlm@1: if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) rlm@1: goto yyerrdefault; rlm@1: rlm@1: yyn = yytable[yyn]; rlm@1: if (yyn < 0) rlm@1: { rlm@1: if (yyn == YYFLAG) rlm@1: goto yyerrpop; rlm@1: yyn = -yyn; rlm@1: goto yyreduce; rlm@1: } rlm@1: else if (yyn == 0) rlm@1: goto yyerrpop; rlm@1: rlm@1: if (yyn == YYFINAL) rlm@1: YYACCEPT; rlm@1: rlm@1: #if YYDEBUG != 0 rlm@1: if (yydebug) rlm@1: fprintf(stderr, "Shifting error token, "); rlm@1: #endif rlm@1: rlm@1: *++yyvsp = yylval; rlm@1: #ifdef YYLSP_NEEDED rlm@1: *++yylsp = yylloc; rlm@1: #endif rlm@1: rlm@1: yystate = yyn; rlm@1: goto yynewstate; rlm@1: rlm@1: yyacceptlab: rlm@1: /* YYACCEPT comes here. */ rlm@1: if (yyfree_stacks) rlm@1: { rlm@1: free (yyss); rlm@1: free (yyvs); rlm@1: #ifdef YYLSP_NEEDED rlm@1: free (yyls); rlm@1: #endif rlm@1: } rlm@1: return 0; rlm@1: rlm@1: yyabortlab: rlm@1: /* YYABORT comes here. */ rlm@1: if (yyfree_stacks) rlm@1: { rlm@1: free (yyss); rlm@1: free (yyvs); rlm@1: #ifdef YYLSP_NEEDED rlm@1: free (yyls); rlm@1: #endif rlm@1: } rlm@1: return 1; rlm@1: } rlm@1: #line 57 "expr.y" rlm@1: rlm@1: rlm@1: int yyerror(char *s) rlm@1: { rlm@1: return 0; rlm@1: } rlm@1: rlm@1: #ifndef SDL rlm@1: extern FILE *yyin; rlm@1: int main(int argc, char **argv) rlm@1: { rlm@1: // yydebug = 1; rlm@1: ++argv, --argc; rlm@1: if(argc > 0) rlm@1: yyin = fopen(argv[0], "r"); rlm@1: else rlm@1: yyin = stdin; rlm@1: if(!yyparse()) rlm@1: result->print(); rlm@1: } rlm@1: #endif