Mercurial > vba-clojure
diff src/sdl/expr.cpp @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/sdl/expr.cpp Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,998 @@ 1.4 + 1.5 +/* A Bison parser, made from expr.y 1.6 + by GNU Bison version 1.28 */ 1.7 + 1.8 +#define YYBISON 1 /* Identify Bison output. */ 1.9 + 1.10 +#define TOKEN_IDENTIFIER 257 1.11 +#define TOKEN_DOT 258 1.12 +#define TOKEN_STAR 259 1.13 +#define TOKEN_ARROW 260 1.14 +#define TOKEN_ADDR 261 1.15 +#define TOKEN_SIZEOF 262 1.16 +#define TOKEN_NUMBER 263 1.17 + 1.18 +#line 1 "expr.y" 1.19 + 1.20 +namespace std { 1.21 +#include <stdio.h> 1.22 +#include <memory.h> 1.23 +#include <stdlib.h> 1.24 +#include <string.h> 1.25 +} 1.26 + 1.27 +using namespace std; 1.28 + 1.29 +#include "../common/System.h" 1.30 +#include "../gba/elf.h" 1.31 +#include "exprNode.h" 1.32 + 1.33 +extern int yyerror(char *); 1.34 +extern int yylex(); 1.35 +extern char *yytext; 1.36 + 1.37 + 1.38 +//#define YYERROR_VERBOSE 1 1.39 +//#define YYDEBUG 1 1.40 + 1.41 + Node *result = NULL; 1.42 +#ifndef YYSTYPE 1.43 +#define YYSTYPE int 1.44 +#endif 1.45 +#include <stdio.h> 1.46 + 1.47 +#ifndef __cplusplus 1.48 +#ifndef __STDC__ 1.49 +#define const 1.50 +#endif 1.51 +#endif 1.52 + 1.53 + 1.54 + 1.55 +#define YYFINAL 26 1.56 +#define YYFLAG -32768 1.57 +#define YYNTBASE 14 1.58 + 1.59 +#define YYTRANSLATE(x) ((unsigned)(x) <= 263 ? yytranslate[x] : 19) 1.60 + 1.61 +static const char yytranslate[] = { 0, 1.62 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.63 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.64 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.65 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 11, 1.66 + 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.67 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.68 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.69 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.70 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.71 + 10, 2, 13, 2, 2, 2, 2, 2, 2, 2, 1.72 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.73 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.74 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.75 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.76 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.77 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.78 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.79 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.80 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.81 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.82 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.83 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.84 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.85 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.86 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.87 + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, 1.88 + 7, 8, 9 1.89 +}; 1.90 + 1.91 +#if YYDEBUG != 0 1.92 +static const short yyprhs[] = { 0, 1.93 + 0, 2, 4, 8, 12, 16, 21, 23, 26, 29, 1.94 + 34, 36 1.95 +}; 1.96 + 1.97 +static const short yyrhs[] = { 15, 1.98 + 0, 16, 0, 11, 15, 12, 0, 15, 4, 18, 1.99 + 0, 15, 6, 18, 0, 15, 10, 17, 13, 0, 1.100 + 18, 0, 5, 15, 0, 7, 15, 0, 8, 11, 1.101 + 15, 12, 0, 9, 0, 3, 0 1.102 +}; 1.103 + 1.104 +#endif 1.105 + 1.106 +#if YYDEBUG != 0 1.107 +static const short yyrline[] = { 0, 1.108 + 32, 35, 36, 37, 38, 39, 42, 43, 44, 45, 1.109 + 49, 53 1.110 +}; 1.111 +#endif 1.112 + 1.113 + 1.114 +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) 1.115 + 1.116 +static const char * const yytname[] = { "$","error","$undefined.","TOKEN_IDENTIFIER", 1.117 +"TOKEN_DOT","TOKEN_STAR","TOKEN_ARROW","TOKEN_ADDR","TOKEN_SIZEOF","TOKEN_NUMBER", 1.118 +"'['","'('","')'","']'","final","expression","simple_expression","number","ident", NULL 1.119 +}; 1.120 +#endif 1.121 + 1.122 +static const short yyr1[] = { 0, 1.123 + 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 1.124 + 17, 18 1.125 +}; 1.126 + 1.127 +static const short yyr2[] = { 0, 1.128 + 1, 1, 3, 3, 3, 4, 1, 2, 2, 4, 1.129 + 1, 1 1.130 +}; 1.131 + 1.132 +static const short yydefact[] = { 0, 1.133 + 12, 0, 0, 0, 0, 1, 2, 7, 8, 9, 1.134 + 0, 0, 0, 0, 0, 0, 3, 4, 5, 11, 1.135 + 0, 10, 6, 0, 0, 0 1.136 +}; 1.137 + 1.138 +static const short yydefgoto[] = { 24, 1.139 + 6, 7, 21, 8 1.140 +}; 1.141 + 1.142 +static const short yypact[] = { -1, 1.143 +-32768, -1, -1, -6, -1, 17,-32768,-32768, 17, 17, 1.144 + -1, 7, 5, 5, 13, 8,-32768,-32768,-32768,-32768, 1.145 + 11,-32768,-32768, 25, 26,-32768 1.146 +}; 1.147 + 1.148 +static const short yypgoto[] = {-32768, 1.149 + -2,-32768,-32768, 2 1.150 +}; 1.151 + 1.152 + 1.153 +#define YYLAST 27 1.154 + 1.155 + 1.156 +static const short yytable[] = { 9, 1.157 + 10, 1, 12, 2, 11, 3, 4, 1, 16, 5, 1.158 + 13, 13, 14, 14, 18, 19, 15, 15, 17, 22, 1.159 + 13, 20, 14, 23, 25, 26, 15 1.160 +}; 1.161 + 1.162 +static const short yycheck[] = { 2, 1.163 + 3, 3, 5, 5, 11, 7, 8, 3, 11, 11, 1.164 + 4, 4, 6, 6, 13, 14, 10, 10, 12, 12, 1.165 + 4, 9, 6, 13, 0, 0, 10 1.166 +}; 1.167 +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ 1.168 +#line 3 "/usr/lib/bison.simple" 1.169 +/* This file comes from bison-1.28. */ 1.170 + 1.171 +/* Skeleton output parser for bison, 1.172 + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. 1.173 + 1.174 + This program is free software; you can redistribute it and/or modify 1.175 + it under the terms of the GNU General Public License as published by 1.176 + the Free Software Foundation; either version 2, or (at your option) 1.177 + any later version. 1.178 + 1.179 + This program is distributed in the hope that it will be useful, 1.180 + but WITHOUT ANY WARRANTY; without even the implied warranty of 1.181 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.182 + GNU General Public License for more details. 1.183 + 1.184 + You should have received a copy of the GNU General Public License 1.185 + along with this program; if not, write to the Free Software 1.186 + Foundation, Inc., 59 Temple Place - Suite 330, 1.187 + Boston, MA 02111-1307, USA. */ 1.188 + 1.189 +/* As a special exception, when this file is copied by Bison into a 1.190 + Bison output file, you may use that output file without restriction. 1.191 + This special exception was added by the Free Software Foundation 1.192 + in version 1.24 of Bison. */ 1.193 + 1.194 +/* This is the parser code that is written into each bison parser 1.195 + when the %semantic_parser declaration is not specified in the grammar. 1.196 + It was written by Richard Stallman by simplifying the hairy parser 1.197 + used when %semantic_parser is specified. */ 1.198 + 1.199 +#ifndef YYSTACK_USE_ALLOCA 1.200 +#ifdef alloca 1.201 +#define YYSTACK_USE_ALLOCA 1.202 +#else /* alloca not defined */ 1.203 +#ifdef __GNUC__ 1.204 +#define YYSTACK_USE_ALLOCA 1.205 +#define alloca __builtin_alloca 1.206 +#else /* not GNU C. */ 1.207 +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) 1.208 +#define YYSTACK_USE_ALLOCA 1.209 +#include <alloca.h> 1.210 +#else /* not sparc */ 1.211 +/* We think this test detects Watcom and Microsoft C. */ 1.212 +/* This used to test MSDOS, but that is a bad idea 1.213 + since that symbol is in the user namespace. */ 1.214 +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) 1.215 +#if 0 /* No need for malloc.h, which pollutes the namespace; 1.216 + instead, just don't use alloca. */ 1.217 +#include <malloc.h> 1.218 +#endif 1.219 +#else /* not MSDOS, or __TURBOC__ */ 1.220 +#if defined(_AIX) 1.221 +/* I don't know what this was needed for, but it pollutes the namespace. 1.222 + So I turned it off. rms, 2 May 1997. */ 1.223 +/* #include <malloc.h> */ 1.224 + #pragma alloca 1.225 +#define YYSTACK_USE_ALLOCA 1.226 +#else /* not MSDOS, or __TURBOC__, or _AIX */ 1.227 +#if 0 1.228 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, 1.229 + and on HPUX 10. Eventually we can turn this on. */ 1.230 +#define YYSTACK_USE_ALLOCA 1.231 +#define alloca __builtin_alloca 1.232 +#endif /* __hpux */ 1.233 +#endif 1.234 +#endif /* not _AIX */ 1.235 +#endif /* not MSDOS, or __TURBOC__ */ 1.236 +#endif /* not sparc */ 1.237 +#endif /* not GNU C */ 1.238 +#endif /* alloca not defined */ 1.239 +#endif /* YYSTACK_USE_ALLOCA not defined */ 1.240 + 1.241 +#ifdef YYSTACK_USE_ALLOCA 1.242 +#define YYSTACK_ALLOC alloca 1.243 +#else 1.244 +#define YYSTACK_ALLOC malloc 1.245 +#endif 1.246 + 1.247 +/* Note: there must be only one dollar sign in this file. 1.248 + It is replaced by the list of actions, each action 1.249 + as one case of the switch. */ 1.250 + 1.251 +#define yyerrok (yyerrstatus = 0) 1.252 +#define yyclearin (yychar = YYEMPTY) 1.253 +#define YYEMPTY -2 1.254 +#define YYEOF 0 1.255 +#define YYACCEPT goto yyacceptlab 1.256 +#define YYABORT goto yyabortlab 1.257 +#define YYERROR goto yyerrlab1 1.258 +/* Like YYERROR except do call yyerror. 1.259 + This remains here temporarily to ease the 1.260 + transition to the new meaning of YYERROR, for GCC. 1.261 + Once GCC version 2 has supplanted version 1, this can go. */ 1.262 +#define YYFAIL goto yyerrlab 1.263 +#define YYRECOVERING() (!!yyerrstatus) 1.264 +#define YYBACKUP(token, value) \ 1.265 +do \ 1.266 + if (yychar == YYEMPTY && yylen == 1) \ 1.267 + { yychar = (token), yylval = (value); \ 1.268 + yychar1 = YYTRANSLATE (yychar); \ 1.269 + YYPOPSTACK; \ 1.270 + goto yybackup; \ 1.271 + } \ 1.272 + else \ 1.273 + { yyerror ("syntax error: cannot back up"); YYERROR; } \ 1.274 +while (0) 1.275 + 1.276 +#define YYTERROR 1 1.277 +#define YYERRCODE 256 1.278 + 1.279 +#ifndef YYPURE 1.280 +#define YYLEX yylex() 1.281 +#endif 1.282 + 1.283 +#ifdef YYPURE 1.284 +#ifdef YYLSP_NEEDED 1.285 +#ifdef YYLEX_PARAM 1.286 +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) 1.287 +#else 1.288 +#define YYLEX yylex(&yylval, &yylloc) 1.289 +#endif 1.290 +#else /* not YYLSP_NEEDED */ 1.291 +#ifdef YYLEX_PARAM 1.292 +#define YYLEX yylex(&yylval, YYLEX_PARAM) 1.293 +#else 1.294 +#define YYLEX yylex(&yylval) 1.295 +#endif 1.296 +#endif /* not YYLSP_NEEDED */ 1.297 +#endif 1.298 + 1.299 +/* If nonreentrant, generate the variables here */ 1.300 + 1.301 +#ifndef YYPURE 1.302 + 1.303 +int yychar; /* the lookahead symbol */ 1.304 +YYSTYPE yylval; /* the semantic value of the */ 1.305 + /* lookahead symbol */ 1.306 + 1.307 +#ifdef YYLSP_NEEDED 1.308 +YYLTYPE yylloc; /* location data for the lookahead */ 1.309 + /* symbol */ 1.310 +#endif 1.311 + 1.312 +int yynerrs; /* number of parse errors so far */ 1.313 +#endif /* not YYPURE */ 1.314 + 1.315 +#if YYDEBUG != 0 1.316 +int yydebug; /* nonzero means print parse trace */ 1.317 +/* Since this is uninitialized, it does not stop multiple parsers 1.318 + from coexisting. */ 1.319 +#endif 1.320 + 1.321 +/* YYINITDEPTH indicates the initial size of the parser's stacks */ 1.322 + 1.323 +#ifndef YYINITDEPTH 1.324 +#define YYINITDEPTH 200 1.325 +#endif 1.326 + 1.327 +/* YYMAXDEPTH is the maximum size the stacks can grow to 1.328 + (effective only if the built-in stack extension method is used). */ 1.329 + 1.330 +#if YYMAXDEPTH == 0 1.331 +#undef YYMAXDEPTH 1.332 +#endif 1.333 + 1.334 +#ifndef YYMAXDEPTH 1.335 +#define YYMAXDEPTH 10000 1.336 +#endif 1.337 + 1.338 +/* Define __yy_memcpy. Note that the size argument 1.339 + should be passed with type unsigned int, because that is what the non-GCC 1.340 + definitions require. With GCC, __builtin_memcpy takes an arg 1.341 + of type size_t, but it can handle unsigned int. */ 1.342 + 1.343 +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ 1.344 +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) 1.345 +#else /* not GNU C or C++ */ 1.346 +#ifndef __cplusplus 1.347 + 1.348 +/* This is the most reliable way to avoid incompatibilities 1.349 + in available built-in functions on various systems. */ 1.350 +static void 1.351 +__yy_memcpy (to, from, count) 1.352 + char *to; 1.353 + char *from; 1.354 + unsigned int count; 1.355 +{ 1.356 + register char *f = from; 1.357 + register char *t = to; 1.358 + register int i = count; 1.359 + 1.360 + while (i-- > 0) 1.361 + *t++ = *f++; 1.362 +} 1.363 + 1.364 +#else /* __cplusplus */ 1.365 + 1.366 +/* This is the most reliable way to avoid incompatibilities 1.367 + in available built-in functions on various systems. */ 1.368 +static void 1.369 +__yy_memcpy (char *to, char *from, unsigned int count) 1.370 +{ 1.371 + register char *t = to; 1.372 + register char *f = from; 1.373 + register int i = count; 1.374 + 1.375 + while (i-- > 0) 1.376 + *t++ = *f++; 1.377 +} 1.378 + 1.379 +#endif 1.380 +#endif 1.381 + 1.382 +#line 217 "/usr/lib/bison.simple" 1.383 + 1.384 +/* The user can define YYPARSE_PARAM as the name of an argument to be passed 1.385 + into yyparse. The argument should have type void *. 1.386 + It should actually point to an object. 1.387 + Grammar actions can access the variable by casting it 1.388 + to the proper pointer type. */ 1.389 + 1.390 +#ifdef YYPARSE_PARAM 1.391 +#ifdef __cplusplus 1.392 +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM 1.393 +#define YYPARSE_PARAM_DECL 1.394 +#else /* not __cplusplus */ 1.395 +#define YYPARSE_PARAM_ARG YYPARSE_PARAM 1.396 +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; 1.397 +#endif /* not __cplusplus */ 1.398 +#else /* not YYPARSE_PARAM */ 1.399 +#define YYPARSE_PARAM_ARG 1.400 +#define YYPARSE_PARAM_DECL 1.401 +#endif /* not YYPARSE_PARAM */ 1.402 + 1.403 +/* Prevent warning if -Wstrict-prototypes. */ 1.404 +#ifdef __GNUC__ 1.405 +#ifdef YYPARSE_PARAM 1.406 +int yyparse (void *); 1.407 +#else 1.408 +int yyparse (void); 1.409 +#endif 1.410 +#endif 1.411 + 1.412 +int 1.413 +yyparse(YYPARSE_PARAM_ARG) 1.414 + YYPARSE_PARAM_DECL 1.415 +{ 1.416 + register int yystate; 1.417 + register int yyn; 1.418 + register short *yyssp; 1.419 + register YYSTYPE *yyvsp; 1.420 + int yyerrstatus; /* number of tokens to shift before error messages enabled */ 1.421 + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ 1.422 + 1.423 + short yyssa[YYINITDEPTH]; /* the state stack */ 1.424 + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ 1.425 + 1.426 + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ 1.427 + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ 1.428 + 1.429 +#ifdef YYLSP_NEEDED 1.430 + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ 1.431 + YYLTYPE *yyls = yylsa; 1.432 + YYLTYPE *yylsp; 1.433 + 1.434 +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) 1.435 +#else 1.436 +#define YYPOPSTACK (yyvsp--, yyssp--) 1.437 +#endif 1.438 + 1.439 + int yystacksize = YYINITDEPTH; 1.440 + int yyfree_stacks = 0; 1.441 + 1.442 +#ifdef YYPURE 1.443 + int yychar; 1.444 + YYSTYPE yylval; 1.445 + int yynerrs; 1.446 +#ifdef YYLSP_NEEDED 1.447 + YYLTYPE yylloc; 1.448 +#endif 1.449 +#endif 1.450 + 1.451 + YYSTYPE yyval; /* the variable used to return */ 1.452 + /* semantic values from the action */ 1.453 + /* routines */ 1.454 + 1.455 + int yylen; 1.456 + 1.457 +#if YYDEBUG != 0 1.458 + if (yydebug) 1.459 + fprintf(stderr, "Starting parse\n"); 1.460 +#endif 1.461 + 1.462 + yystate = 0; 1.463 + yyerrstatus = 0; 1.464 + yynerrs = 0; 1.465 + yychar = YYEMPTY; /* Cause a token to be read. */ 1.466 + 1.467 + /* Initialize stack pointers. 1.468 + Waste one element of value and location stack 1.469 + so that they stay on the same level as the state stack. 1.470 + The wasted elements are never initialized. */ 1.471 + 1.472 + yyssp = yyss - 1; 1.473 + yyvsp = yyvs; 1.474 +#ifdef YYLSP_NEEDED 1.475 + yylsp = yyls; 1.476 +#endif 1.477 + 1.478 +/* Push a new state, which is found in yystate . */ 1.479 +/* In all cases, when you get here, the value and location stacks 1.480 + have just been pushed. so pushing a state here evens the stacks. */ 1.481 +yynewstate: 1.482 + 1.483 + *++yyssp = yystate; 1.484 + 1.485 + if (yyssp >= yyss + yystacksize - 1) 1.486 + { 1.487 + /* Give user a chance to reallocate the stack */ 1.488 + /* Use copies of these so that the &'s don't force the real ones into memory. */ 1.489 + YYSTYPE *yyvs1 = yyvs; 1.490 + short *yyss1 = yyss; 1.491 +#ifdef YYLSP_NEEDED 1.492 + YYLTYPE *yyls1 = yyls; 1.493 +#endif 1.494 + 1.495 + /* Get the current used size of the three stacks, in elements. */ 1.496 + int size = yyssp - yyss + 1; 1.497 + 1.498 +#ifdef yyoverflow 1.499 + /* Each stack pointer address is followed by the size of 1.500 + the data in use in that stack, in bytes. */ 1.501 +#ifdef YYLSP_NEEDED 1.502 + /* This used to be a conditional around just the two extra args, 1.503 + but that might be undefined if yyoverflow is a macro. */ 1.504 + yyoverflow("parser stack overflow", 1.505 + &yyss1, size * sizeof (*yyssp), 1.506 + &yyvs1, size * sizeof (*yyvsp), 1.507 + &yyls1, size * sizeof (*yylsp), 1.508 + &yystacksize); 1.509 +#else 1.510 + yyoverflow("parser stack overflow", 1.511 + &yyss1, size * sizeof (*yyssp), 1.512 + &yyvs1, size * sizeof (*yyvsp), 1.513 + &yystacksize); 1.514 +#endif 1.515 + 1.516 + yyss = yyss1; yyvs = yyvs1; 1.517 +#ifdef YYLSP_NEEDED 1.518 + yyls = yyls1; 1.519 +#endif 1.520 +#else /* no yyoverflow */ 1.521 + /* Extend the stack our own way. */ 1.522 + if (yystacksize >= YYMAXDEPTH) 1.523 + { 1.524 + yyerror("parser stack overflow"); 1.525 + if (yyfree_stacks) 1.526 + { 1.527 + free (yyss); 1.528 + free (yyvs); 1.529 +#ifdef YYLSP_NEEDED 1.530 + free (yyls); 1.531 +#endif 1.532 + } 1.533 + return 2; 1.534 + } 1.535 + yystacksize *= 2; 1.536 + if (yystacksize > YYMAXDEPTH) 1.537 + yystacksize = YYMAXDEPTH; 1.538 +#ifndef YYSTACK_USE_ALLOCA 1.539 + yyfree_stacks = 1; 1.540 +#endif 1.541 + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); 1.542 + __yy_memcpy ((char *)yyss, (char *)yyss1, 1.543 + size * (unsigned int) sizeof (*yyssp)); 1.544 + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); 1.545 + __yy_memcpy ((char *)yyvs, (char *)yyvs1, 1.546 + size * (unsigned int) sizeof (*yyvsp)); 1.547 +#ifdef YYLSP_NEEDED 1.548 + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); 1.549 + __yy_memcpy ((char *)yyls, (char *)yyls1, 1.550 + size * (unsigned int) sizeof (*yylsp)); 1.551 +#endif 1.552 +#endif /* no yyoverflow */ 1.553 + 1.554 + yyssp = yyss + size - 1; 1.555 + yyvsp = yyvs + size - 1; 1.556 +#ifdef YYLSP_NEEDED 1.557 + yylsp = yyls + size - 1; 1.558 +#endif 1.559 + 1.560 +#if YYDEBUG != 0 1.561 + if (yydebug) 1.562 + fprintf(stderr, "Stack size increased to %d\n", yystacksize); 1.563 +#endif 1.564 + 1.565 + if (yyssp >= yyss + yystacksize - 1) 1.566 + YYABORT; 1.567 + } 1.568 + 1.569 +#if YYDEBUG != 0 1.570 + if (yydebug) 1.571 + fprintf(stderr, "Entering state %d\n", yystate); 1.572 +#endif 1.573 + 1.574 + goto yybackup; 1.575 + yybackup: 1.576 + 1.577 +/* Do appropriate processing given the current state. */ 1.578 +/* Read a lookahead token if we need one and don't already have one. */ 1.579 +/* yyresume: */ 1.580 + 1.581 + /* First try to decide what to do without reference to lookahead token. */ 1.582 + 1.583 + yyn = yypact[yystate]; 1.584 + if (yyn == YYFLAG) 1.585 + goto yydefault; 1.586 + 1.587 + /* Not known => get a lookahead token if don't already have one. */ 1.588 + 1.589 + /* yychar is either YYEMPTY or YYEOF 1.590 + or a valid token in external form. */ 1.591 + 1.592 + if (yychar == YYEMPTY) 1.593 + { 1.594 +#if YYDEBUG != 0 1.595 + if (yydebug) 1.596 + fprintf(stderr, "Reading a token: "); 1.597 +#endif 1.598 + yychar = YYLEX; 1.599 + } 1.600 + 1.601 + /* Convert token to internal form (in yychar1) for indexing tables with */ 1.602 + 1.603 + if (yychar <= 0) /* This means end of input. */ 1.604 + { 1.605 + yychar1 = 0; 1.606 + yychar = YYEOF; /* Don't call YYLEX any more */ 1.607 + 1.608 +#if YYDEBUG != 0 1.609 + if (yydebug) 1.610 + fprintf(stderr, "Now at end of input.\n"); 1.611 +#endif 1.612 + } 1.613 + else 1.614 + { 1.615 + yychar1 = YYTRANSLATE(yychar); 1.616 + 1.617 +#if YYDEBUG != 0 1.618 + if (yydebug) 1.619 + { 1.620 + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); 1.621 + /* Give the individual parser a way to print the precise meaning 1.622 + of a token, for further debugging info. */ 1.623 +#ifdef YYPRINT 1.624 + YYPRINT (stderr, yychar, yylval); 1.625 +#endif 1.626 + fprintf (stderr, ")\n"); 1.627 + } 1.628 +#endif 1.629 + } 1.630 + 1.631 + yyn += yychar1; 1.632 + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) 1.633 + goto yydefault; 1.634 + 1.635 + yyn = yytable[yyn]; 1.636 + 1.637 + /* yyn is what to do for this token type in this state. 1.638 + Negative => reduce, -yyn is rule number. 1.639 + Positive => shift, yyn is new state. 1.640 + New state is final state => don't bother to shift, 1.641 + just return success. 1.642 + 0, or most negative number => error. */ 1.643 + 1.644 + if (yyn < 0) 1.645 + { 1.646 + if (yyn == YYFLAG) 1.647 + goto yyerrlab; 1.648 + yyn = -yyn; 1.649 + goto yyreduce; 1.650 + } 1.651 + else if (yyn == 0) 1.652 + goto yyerrlab; 1.653 + 1.654 + if (yyn == YYFINAL) 1.655 + YYACCEPT; 1.656 + 1.657 + /* Shift the lookahead token. */ 1.658 + 1.659 +#if YYDEBUG != 0 1.660 + if (yydebug) 1.661 + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); 1.662 +#endif 1.663 + 1.664 + /* Discard the token being shifted unless it is eof. */ 1.665 + if (yychar != YYEOF) 1.666 + yychar = YYEMPTY; 1.667 + 1.668 + *++yyvsp = yylval; 1.669 +#ifdef YYLSP_NEEDED 1.670 + *++yylsp = yylloc; 1.671 +#endif 1.672 + 1.673 + /* count tokens shifted since error; after three, turn off error status. */ 1.674 + if (yyerrstatus) yyerrstatus--; 1.675 + 1.676 + yystate = yyn; 1.677 + goto yynewstate; 1.678 + 1.679 +/* Do the default action for the current state. */ 1.680 +yydefault: 1.681 + 1.682 + yyn = yydefact[yystate]; 1.683 + if (yyn == 0) 1.684 + goto yyerrlab; 1.685 + 1.686 +/* Do a reduction. yyn is the number of a rule to reduce with. */ 1.687 +yyreduce: 1.688 + yylen = yyr2[yyn]; 1.689 + if (yylen > 0) 1.690 + yyval = yyvsp[1-yylen]; /* implement default value of the action */ 1.691 + 1.692 +#if YYDEBUG != 0 1.693 + if (yydebug) 1.694 + { 1.695 + int i; 1.696 + 1.697 + fprintf (stderr, "Reducing via rule %d (line %d), ", 1.698 + yyn, yyrline[yyn]); 1.699 + 1.700 + /* Print the symbols being reduced, and their result. */ 1.701 + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) 1.702 + fprintf (stderr, "%s ", yytname[yyrhs[i]]); 1.703 + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); 1.704 + } 1.705 +#endif 1.706 + 1.707 + 1.708 + switch (yyn) { 1.709 + 1.710 +case 1: 1.711 +#line 32 "expr.y" 1.712 +{ result = yyvsp[0]; ; 1.713 + break;} 1.714 +case 2: 1.715 +#line 36 "expr.y" 1.716 +{ yyval = yyvsp[0]; ; 1.717 + break;} 1.718 +case 3: 1.719 +#line 37 "expr.y" 1.720 +{ yyval = yyvsp[-1]; ; 1.721 + break;} 1.722 +case 4: 1.723 +#line 38 "expr.y" 1.724 +{ yyval = exprNodeDot(yyvsp[-2], yyvsp[0]); ; 1.725 + break;} 1.726 +case 5: 1.727 +#line 39 "expr.y" 1.728 +{ yyval = exprNodeArrow(yyvsp[-2], yyvsp[0]); ; 1.729 + break;} 1.730 +case 6: 1.731 +#line 40 "expr.y" 1.732 +{ yyval = exprNodeArray(yyvsp[-3], yyvsp[-1]); ; 1.733 + break;} 1.734 +case 7: 1.735 +#line 43 "expr.y" 1.736 +{ yyval = yyvsp[0]; ; 1.737 + break;} 1.738 +case 8: 1.739 +#line 44 "expr.y" 1.740 +{ yyval = exprNodeStar(yyvsp[0]); ; 1.741 + break;} 1.742 +case 9: 1.743 +#line 45 "expr.y" 1.744 +{ yyval = exprNodeAddr(yyvsp[0]); ; 1.745 + break;} 1.746 +case 10: 1.747 +#line 46 "expr.y" 1.748 +{ yyval = exprNodeSizeof(yyvsp[-1]); ; 1.749 + break;} 1.750 +case 11: 1.751 +#line 50 "expr.y" 1.752 +{ yyval = exprNodeNumber(); ; 1.753 + break;} 1.754 +case 12: 1.755 +#line 54 "expr.y" 1.756 +{yyval = exprNodeIdentifier(); ; 1.757 + break;} 1.758 +} 1.759 + /* the action file gets copied in in place of this dollarsign */ 1.760 +#line 543 "/usr/lib/bison.simple" 1.761 + 1.762 + yyvsp -= yylen; 1.763 + yyssp -= yylen; 1.764 +#ifdef YYLSP_NEEDED 1.765 + yylsp -= yylen; 1.766 +#endif 1.767 + 1.768 +#if YYDEBUG != 0 1.769 + if (yydebug) 1.770 + { 1.771 + short *ssp1 = yyss - 1; 1.772 + fprintf (stderr, "state stack now"); 1.773 + while (ssp1 != yyssp) 1.774 + fprintf (stderr, " %d", *++ssp1); 1.775 + fprintf (stderr, "\n"); 1.776 + } 1.777 +#endif 1.778 + 1.779 + *++yyvsp = yyval; 1.780 + 1.781 +#ifdef YYLSP_NEEDED 1.782 + yylsp++; 1.783 + if (yylen == 0) 1.784 + { 1.785 + yylsp->first_line = yylloc.first_line; 1.786 + yylsp->first_column = yylloc.first_column; 1.787 + yylsp->last_line = (yylsp-1)->last_line; 1.788 + yylsp->last_column = (yylsp-1)->last_column; 1.789 + yylsp->text = 0; 1.790 + } 1.791 + else 1.792 + { 1.793 + yylsp->last_line = (yylsp+yylen-1)->last_line; 1.794 + yylsp->last_column = (yylsp+yylen-1)->last_column; 1.795 + } 1.796 +#endif 1.797 + 1.798 + /* Now "shift" the result of the reduction. 1.799 + Determine what state that goes to, 1.800 + based on the state we popped back to 1.801 + and the rule number reduced by. */ 1.802 + 1.803 + yyn = yyr1[yyn]; 1.804 + 1.805 + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; 1.806 + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) 1.807 + yystate = yytable[yystate]; 1.808 + else 1.809 + yystate = yydefgoto[yyn - YYNTBASE]; 1.810 + 1.811 + goto yynewstate; 1.812 + 1.813 +yyerrlab: /* here on detecting error */ 1.814 + 1.815 + if (! yyerrstatus) 1.816 + /* If not already recovering from an error, report this error. */ 1.817 + { 1.818 + ++yynerrs; 1.819 + 1.820 +#ifdef YYERROR_VERBOSE 1.821 + yyn = yypact[yystate]; 1.822 + 1.823 + if (yyn > YYFLAG && yyn < YYLAST) 1.824 + { 1.825 + int size = 0; 1.826 + char *msg; 1.827 + int x, count; 1.828 + 1.829 + count = 0; 1.830 + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ 1.831 + for (x = (yyn < 0 ? -yyn : 0); 1.832 + x < (sizeof(yytname) / sizeof(char *)); x++) 1.833 + if (yycheck[x + yyn] == x) 1.834 + size += strlen(yytname[x]) + 15, count++; 1.835 + msg = (char *) malloc(size + 15); 1.836 + if (msg != 0) 1.837 + { 1.838 + strcpy(msg, "parse error"); 1.839 + 1.840 + if (count < 5) 1.841 + { 1.842 + count = 0; 1.843 + for (x = (yyn < 0 ? -yyn : 0); 1.844 + x < (sizeof(yytname) / sizeof(char *)); x++) 1.845 + if (yycheck[x + yyn] == x) 1.846 + { 1.847 + strcat(msg, count == 0 ? ", expecting `" : " or `"); 1.848 + strcat(msg, yytname[x]); 1.849 + strcat(msg, "'"); 1.850 + count++; 1.851 + } 1.852 + } 1.853 + yyerror(msg); 1.854 + free(msg); 1.855 + } 1.856 + else 1.857 + yyerror ("parse error; also virtual memory exceeded"); 1.858 + } 1.859 + else 1.860 +#endif /* YYERROR_VERBOSE */ 1.861 + yyerror("parse error"); 1.862 + } 1.863 + 1.864 + goto yyerrlab1; 1.865 +yyerrlab1: /* here on error raised explicitly by an action */ 1.866 + 1.867 + if (yyerrstatus == 3) 1.868 + { 1.869 + /* if just tried and failed to reuse lookahead token after an error, discard it. */ 1.870 + 1.871 + /* return failure if at end of input */ 1.872 + if (yychar == YYEOF) 1.873 + YYABORT; 1.874 + 1.875 +#if YYDEBUG != 0 1.876 + if (yydebug) 1.877 + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); 1.878 +#endif 1.879 + 1.880 + yychar = YYEMPTY; 1.881 + } 1.882 + 1.883 + /* Else will try to reuse lookahead token 1.884 + after shifting the error token. */ 1.885 + 1.886 + yyerrstatus = 3; /* Each real token shifted decrements this */ 1.887 + 1.888 + goto yyerrhandle; 1.889 + 1.890 +yyerrdefault: /* current state does not do anything special for the error token. */ 1.891 + 1.892 +#if 0 1.893 + /* This is wrong; only states that explicitly want error tokens 1.894 + should shift them. */ 1.895 + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ 1.896 + if (yyn) goto yydefault; 1.897 +#endif 1.898 + 1.899 +yyerrpop: /* pop the current state because it cannot handle the error token */ 1.900 + 1.901 + if (yyssp == yyss) YYABORT; 1.902 + yyvsp--; 1.903 + yystate = *--yyssp; 1.904 +#ifdef YYLSP_NEEDED 1.905 + yylsp--; 1.906 +#endif 1.907 + 1.908 +#if YYDEBUG != 0 1.909 + if (yydebug) 1.910 + { 1.911 + short *ssp1 = yyss - 1; 1.912 + fprintf (stderr, "Error: state stack now"); 1.913 + while (ssp1 != yyssp) 1.914 + fprintf (stderr, " %d", *++ssp1); 1.915 + fprintf (stderr, "\n"); 1.916 + } 1.917 +#endif 1.918 + 1.919 +yyerrhandle: 1.920 + 1.921 + yyn = yypact[yystate]; 1.922 + if (yyn == YYFLAG) 1.923 + goto yyerrdefault; 1.924 + 1.925 + yyn += YYTERROR; 1.926 + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) 1.927 + goto yyerrdefault; 1.928 + 1.929 + yyn = yytable[yyn]; 1.930 + if (yyn < 0) 1.931 + { 1.932 + if (yyn == YYFLAG) 1.933 + goto yyerrpop; 1.934 + yyn = -yyn; 1.935 + goto yyreduce; 1.936 + } 1.937 + else if (yyn == 0) 1.938 + goto yyerrpop; 1.939 + 1.940 + if (yyn == YYFINAL) 1.941 + YYACCEPT; 1.942 + 1.943 +#if YYDEBUG != 0 1.944 + if (yydebug) 1.945 + fprintf(stderr, "Shifting error token, "); 1.946 +#endif 1.947 + 1.948 + *++yyvsp = yylval; 1.949 +#ifdef YYLSP_NEEDED 1.950 + *++yylsp = yylloc; 1.951 +#endif 1.952 + 1.953 + yystate = yyn; 1.954 + goto yynewstate; 1.955 + 1.956 + yyacceptlab: 1.957 + /* YYACCEPT comes here. */ 1.958 + if (yyfree_stacks) 1.959 + { 1.960 + free (yyss); 1.961 + free (yyvs); 1.962 +#ifdef YYLSP_NEEDED 1.963 + free (yyls); 1.964 +#endif 1.965 + } 1.966 + return 0; 1.967 + 1.968 + yyabortlab: 1.969 + /* YYABORT comes here. */ 1.970 + if (yyfree_stacks) 1.971 + { 1.972 + free (yyss); 1.973 + free (yyvs); 1.974 +#ifdef YYLSP_NEEDED 1.975 + free (yyls); 1.976 +#endif 1.977 + } 1.978 + return 1; 1.979 +} 1.980 +#line 57 "expr.y" 1.981 + 1.982 + 1.983 +int yyerror(char *s) 1.984 +{ 1.985 + return 0; 1.986 +} 1.987 + 1.988 +#ifndef SDL 1.989 +extern FILE *yyin; 1.990 +int main(int argc, char **argv) 1.991 +{ 1.992 + // yydebug = 1; 1.993 + ++argv, --argc; 1.994 + if(argc > 0) 1.995 + yyin = fopen(argv[0], "r"); 1.996 + else 1.997 + yyin = stdin; 1.998 + if(!yyparse()) 1.999 + result->print(); 1.1000 +} 1.1001 +#endif