annotate src/sdl/expr.cpp @ 236:30ced394823a

merge.
author Robert McIntyre <rlm@mit.edu>
date Sat, 24 Mar 2012 20:06:25 -0500
parents f9f4f1b99eed
children
rev   line source
rlm@1 1
rlm@1 2 /* A Bison parser, made from expr.y
rlm@1 3 by GNU Bison version 1.28 */
rlm@1 4
rlm@1 5 #define YYBISON 1 /* Identify Bison output. */
rlm@1 6
rlm@1 7 #define TOKEN_IDENTIFIER 257
rlm@1 8 #define TOKEN_DOT 258
rlm@1 9 #define TOKEN_STAR 259
rlm@1 10 #define TOKEN_ARROW 260
rlm@1 11 #define TOKEN_ADDR 261
rlm@1 12 #define TOKEN_SIZEOF 262
rlm@1 13 #define TOKEN_NUMBER 263
rlm@1 14
rlm@1 15 #line 1 "expr.y"
rlm@1 16
rlm@1 17 namespace std {
rlm@1 18 #include <stdio.h>
rlm@1 19 #include <memory.h>
rlm@1 20 #include <stdlib.h>
rlm@1 21 #include <string.h>
rlm@1 22 }
rlm@1 23
rlm@1 24 using namespace std;
rlm@1 25
rlm@1 26 #include "../common/System.h"
rlm@1 27 #include "../gba/elf.h"
rlm@1 28 #include "exprNode.h"
rlm@1 29
rlm@1 30 extern int yyerror(char *);
rlm@1 31 extern int yylex();
rlm@1 32 extern char *yytext;
rlm@1 33
rlm@1 34
rlm@1 35 //#define YYERROR_VERBOSE 1
rlm@1 36 //#define YYDEBUG 1
rlm@1 37
rlm@1 38 Node *result = NULL;
rlm@1 39 #ifndef YYSTYPE
rlm@1 40 #define YYSTYPE int
rlm@1 41 #endif
rlm@1 42 #include <stdio.h>
rlm@1 43
rlm@1 44 #ifndef __cplusplus
rlm@1 45 #ifndef __STDC__
rlm@1 46 #define const
rlm@1 47 #endif
rlm@1 48 #endif
rlm@1 49
rlm@1 50
rlm@1 51
rlm@1 52 #define YYFINAL 26
rlm@1 53 #define YYFLAG -32768
rlm@1 54 #define YYNTBASE 14
rlm@1 55
rlm@1 56 #define YYTRANSLATE(x) ((unsigned)(x) <= 263 ? yytranslate[x] : 19)
rlm@1 57
rlm@1 58 static const char yytranslate[] = { 0,
rlm@1 59 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 60 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 61 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 62 2, 2, 2, 2, 2, 2, 2, 2, 2, 11,
rlm@1 63 12, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 64 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 65 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 66 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 67 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 68 10, 2, 13, 2, 2, 2, 2, 2, 2, 2,
rlm@1 69 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 70 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 71 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 72 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 73 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 74 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 75 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 76 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 77 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 78 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 79 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 80 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 81 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 82 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 83 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
rlm@1 84 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
rlm@1 85 7, 8, 9
rlm@1 86 };
rlm@1 87
rlm@1 88 #if YYDEBUG != 0
rlm@1 89 static const short yyprhs[] = { 0,
rlm@1 90 0, 2, 4, 8, 12, 16, 21, 23, 26, 29,
rlm@1 91 34, 36
rlm@1 92 };
rlm@1 93
rlm@1 94 static const short yyrhs[] = { 15,
rlm@1 95 0, 16, 0, 11, 15, 12, 0, 15, 4, 18,
rlm@1 96 0, 15, 6, 18, 0, 15, 10, 17, 13, 0,
rlm@1 97 18, 0, 5, 15, 0, 7, 15, 0, 8, 11,
rlm@1 98 15, 12, 0, 9, 0, 3, 0
rlm@1 99 };
rlm@1 100
rlm@1 101 #endif
rlm@1 102
rlm@1 103 #if YYDEBUG != 0
rlm@1 104 static const short yyrline[] = { 0,
rlm@1 105 32, 35, 36, 37, 38, 39, 42, 43, 44, 45,
rlm@1 106 49, 53
rlm@1 107 };
rlm@1 108 #endif
rlm@1 109
rlm@1 110
rlm@1 111 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
rlm@1 112
rlm@1 113 static const char * const yytname[] = { "$","error","$undefined.","TOKEN_IDENTIFIER",
rlm@1 114 "TOKEN_DOT","TOKEN_STAR","TOKEN_ARROW","TOKEN_ADDR","TOKEN_SIZEOF","TOKEN_NUMBER",
rlm@1 115 "'['","'('","')'","']'","final","expression","simple_expression","number","ident", NULL
rlm@1 116 };
rlm@1 117 #endif
rlm@1 118
rlm@1 119 static const short yyr1[] = { 0,
rlm@1 120 14, 15, 15, 15, 15, 15, 16, 16, 16, 16,
rlm@1 121 17, 18
rlm@1 122 };
rlm@1 123
rlm@1 124 static const short yyr2[] = { 0,
rlm@1 125 1, 1, 3, 3, 3, 4, 1, 2, 2, 4,
rlm@1 126 1, 1
rlm@1 127 };
rlm@1 128
rlm@1 129 static const short yydefact[] = { 0,
rlm@1 130 12, 0, 0, 0, 0, 1, 2, 7, 8, 9,
rlm@1 131 0, 0, 0, 0, 0, 0, 3, 4, 5, 11,
rlm@1 132 0, 10, 6, 0, 0, 0
rlm@1 133 };
rlm@1 134
rlm@1 135 static const short yydefgoto[] = { 24,
rlm@1 136 6, 7, 21, 8
rlm@1 137 };
rlm@1 138
rlm@1 139 static const short yypact[] = { -1,
rlm@1 140 -32768, -1, -1, -6, -1, 17,-32768,-32768, 17, 17,
rlm@1 141 -1, 7, 5, 5, 13, 8,-32768,-32768,-32768,-32768,
rlm@1 142 11,-32768,-32768, 25, 26,-32768
rlm@1 143 };
rlm@1 144
rlm@1 145 static const short yypgoto[] = {-32768,
rlm@1 146 -2,-32768,-32768, 2
rlm@1 147 };
rlm@1 148
rlm@1 149
rlm@1 150 #define YYLAST 27
rlm@1 151
rlm@1 152
rlm@1 153 static const short yytable[] = { 9,
rlm@1 154 10, 1, 12, 2, 11, 3, 4, 1, 16, 5,
rlm@1 155 13, 13, 14, 14, 18, 19, 15, 15, 17, 22,
rlm@1 156 13, 20, 14, 23, 25, 26, 15
rlm@1 157 };
rlm@1 158
rlm@1 159 static const short yycheck[] = { 2,
rlm@1 160 3, 3, 5, 5, 11, 7, 8, 3, 11, 11,
rlm@1 161 4, 4, 6, 6, 13, 14, 10, 10, 12, 12,
rlm@1 162 4, 9, 6, 13, 0, 0, 10
rlm@1 163 };
rlm@1 164 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
rlm@1 165 #line 3 "/usr/lib/bison.simple"
rlm@1 166 /* This file comes from bison-1.28. */
rlm@1 167
rlm@1 168 /* Skeleton output parser for bison,
rlm@1 169 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
rlm@1 170
rlm@1 171 This program is free software; you can redistribute it and/or modify
rlm@1 172 it under the terms of the GNU General Public License as published by
rlm@1 173 the Free Software Foundation; either version 2, or (at your option)
rlm@1 174 any later version.
rlm@1 175
rlm@1 176 This program is distributed in the hope that it will be useful,
rlm@1 177 but WITHOUT ANY WARRANTY; without even the implied warranty of
rlm@1 178 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
rlm@1 179 GNU General Public License for more details.
rlm@1 180
rlm@1 181 You should have received a copy of the GNU General Public License
rlm@1 182 along with this program; if not, write to the Free Software
rlm@1 183 Foundation, Inc., 59 Temple Place - Suite 330,
rlm@1 184 Boston, MA 02111-1307, USA. */
rlm@1 185
rlm@1 186 /* As a special exception, when this file is copied by Bison into a
rlm@1 187 Bison output file, you may use that output file without restriction.
rlm@1 188 This special exception was added by the Free Software Foundation
rlm@1 189 in version 1.24 of Bison. */
rlm@1 190
rlm@1 191 /* This is the parser code that is written into each bison parser
rlm@1 192 when the %semantic_parser declaration is not specified in the grammar.
rlm@1 193 It was written by Richard Stallman by simplifying the hairy parser
rlm@1 194 used when %semantic_parser is specified. */
rlm@1 195
rlm@1 196 #ifndef YYSTACK_USE_ALLOCA
rlm@1 197 #ifdef alloca
rlm@1 198 #define YYSTACK_USE_ALLOCA
rlm@1 199 #else /* alloca not defined */
rlm@1 200 #ifdef __GNUC__
rlm@1 201 #define YYSTACK_USE_ALLOCA
rlm@1 202 #define alloca __builtin_alloca
rlm@1 203 #else /* not GNU C. */
rlm@1 204 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
rlm@1 205 #define YYSTACK_USE_ALLOCA
rlm@1 206 #include <alloca.h>
rlm@1 207 #else /* not sparc */
rlm@1 208 /* We think this test detects Watcom and Microsoft C. */
rlm@1 209 /* This used to test MSDOS, but that is a bad idea
rlm@1 210 since that symbol is in the user namespace. */
rlm@1 211 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
rlm@1 212 #if 0 /* No need for malloc.h, which pollutes the namespace;
rlm@1 213 instead, just don't use alloca. */
rlm@1 214 #include <malloc.h>
rlm@1 215 #endif
rlm@1 216 #else /* not MSDOS, or __TURBOC__ */
rlm@1 217 #if defined(_AIX)
rlm@1 218 /* I don't know what this was needed for, but it pollutes the namespace.
rlm@1 219 So I turned it off. rms, 2 May 1997. */
rlm@1 220 /* #include <malloc.h> */
rlm@1 221 #pragma alloca
rlm@1 222 #define YYSTACK_USE_ALLOCA
rlm@1 223 #else /* not MSDOS, or __TURBOC__, or _AIX */
rlm@1 224 #if 0
rlm@1 225 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
rlm@1 226 and on HPUX 10. Eventually we can turn this on. */
rlm@1 227 #define YYSTACK_USE_ALLOCA
rlm@1 228 #define alloca __builtin_alloca
rlm@1 229 #endif /* __hpux */
rlm@1 230 #endif
rlm@1 231 #endif /* not _AIX */
rlm@1 232 #endif /* not MSDOS, or __TURBOC__ */
rlm@1 233 #endif /* not sparc */
rlm@1 234 #endif /* not GNU C */
rlm@1 235 #endif /* alloca not defined */
rlm@1 236 #endif /* YYSTACK_USE_ALLOCA not defined */
rlm@1 237
rlm@1 238 #ifdef YYSTACK_USE_ALLOCA
rlm@1 239 #define YYSTACK_ALLOC alloca
rlm@1 240 #else
rlm@1 241 #define YYSTACK_ALLOC malloc
rlm@1 242 #endif
rlm@1 243
rlm@1 244 /* Note: there must be only one dollar sign in this file.
rlm@1 245 It is replaced by the list of actions, each action
rlm@1 246 as one case of the switch. */
rlm@1 247
rlm@1 248 #define yyerrok (yyerrstatus = 0)
rlm@1 249 #define yyclearin (yychar = YYEMPTY)
rlm@1 250 #define YYEMPTY -2
rlm@1 251 #define YYEOF 0
rlm@1 252 #define YYACCEPT goto yyacceptlab
rlm@1 253 #define YYABORT goto yyabortlab
rlm@1 254 #define YYERROR goto yyerrlab1
rlm@1 255 /* Like YYERROR except do call yyerror.
rlm@1 256 This remains here temporarily to ease the
rlm@1 257 transition to the new meaning of YYERROR, for GCC.
rlm@1 258 Once GCC version 2 has supplanted version 1, this can go. */
rlm@1 259 #define YYFAIL goto yyerrlab
rlm@1 260 #define YYRECOVERING() (!!yyerrstatus)
rlm@1 261 #define YYBACKUP(token, value) \
rlm@1 262 do \
rlm@1 263 if (yychar == YYEMPTY && yylen == 1) \
rlm@1 264 { yychar = (token), yylval = (value); \
rlm@1 265 yychar1 = YYTRANSLATE (yychar); \
rlm@1 266 YYPOPSTACK; \
rlm@1 267 goto yybackup; \
rlm@1 268 } \
rlm@1 269 else \
rlm@1 270 { yyerror ("syntax error: cannot back up"); YYERROR; } \
rlm@1 271 while (0)
rlm@1 272
rlm@1 273 #define YYTERROR 1
rlm@1 274 #define YYERRCODE 256
rlm@1 275
rlm@1 276 #ifndef YYPURE
rlm@1 277 #define YYLEX yylex()
rlm@1 278 #endif
rlm@1 279
rlm@1 280 #ifdef YYPURE
rlm@1 281 #ifdef YYLSP_NEEDED
rlm@1 282 #ifdef YYLEX_PARAM
rlm@1 283 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
rlm@1 284 #else
rlm@1 285 #define YYLEX yylex(&yylval, &yylloc)
rlm@1 286 #endif
rlm@1 287 #else /* not YYLSP_NEEDED */
rlm@1 288 #ifdef YYLEX_PARAM
rlm@1 289 #define YYLEX yylex(&yylval, YYLEX_PARAM)
rlm@1 290 #else
rlm@1 291 #define YYLEX yylex(&yylval)
rlm@1 292 #endif
rlm@1 293 #endif /* not YYLSP_NEEDED */
rlm@1 294 #endif
rlm@1 295
rlm@1 296 /* If nonreentrant, generate the variables here */
rlm@1 297
rlm@1 298 #ifndef YYPURE
rlm@1 299
rlm@1 300 int yychar; /* the lookahead symbol */
rlm@1 301 YYSTYPE yylval; /* the semantic value of the */
rlm@1 302 /* lookahead symbol */
rlm@1 303
rlm@1 304 #ifdef YYLSP_NEEDED
rlm@1 305 YYLTYPE yylloc; /* location data for the lookahead */
rlm@1 306 /* symbol */
rlm@1 307 #endif
rlm@1 308
rlm@1 309 int yynerrs; /* number of parse errors so far */
rlm@1 310 #endif /* not YYPURE */
rlm@1 311
rlm@1 312 #if YYDEBUG != 0
rlm@1 313 int yydebug; /* nonzero means print parse trace */
rlm@1 314 /* Since this is uninitialized, it does not stop multiple parsers
rlm@1 315 from coexisting. */
rlm@1 316 #endif
rlm@1 317
rlm@1 318 /* YYINITDEPTH indicates the initial size of the parser's stacks */
rlm@1 319
rlm@1 320 #ifndef YYINITDEPTH
rlm@1 321 #define YYINITDEPTH 200
rlm@1 322 #endif
rlm@1 323
rlm@1 324 /* YYMAXDEPTH is the maximum size the stacks can grow to
rlm@1 325 (effective only if the built-in stack extension method is used). */
rlm@1 326
rlm@1 327 #if YYMAXDEPTH == 0
rlm@1 328 #undef YYMAXDEPTH
rlm@1 329 #endif
rlm@1 330
rlm@1 331 #ifndef YYMAXDEPTH
rlm@1 332 #define YYMAXDEPTH 10000
rlm@1 333 #endif
rlm@1 334
rlm@1 335 /* Define __yy_memcpy. Note that the size argument
rlm@1 336 should be passed with type unsigned int, because that is what the non-GCC
rlm@1 337 definitions require. With GCC, __builtin_memcpy takes an arg
rlm@1 338 of type size_t, but it can handle unsigned int. */
rlm@1 339
rlm@1 340 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
rlm@1 341 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
rlm@1 342 #else /* not GNU C or C++ */
rlm@1 343 #ifndef __cplusplus
rlm@1 344
rlm@1 345 /* This is the most reliable way to avoid incompatibilities
rlm@1 346 in available built-in functions on various systems. */
rlm@1 347 static void
rlm@1 348 __yy_memcpy (to, from, count)
rlm@1 349 char *to;
rlm@1 350 char *from;
rlm@1 351 unsigned int count;
rlm@1 352 {
rlm@1 353 register char *f = from;
rlm@1 354 register char *t = to;
rlm@1 355 register int i = count;
rlm@1 356
rlm@1 357 while (i-- > 0)
rlm@1 358 *t++ = *f++;
rlm@1 359 }
rlm@1 360
rlm@1 361 #else /* __cplusplus */
rlm@1 362
rlm@1 363 /* This is the most reliable way to avoid incompatibilities
rlm@1 364 in available built-in functions on various systems. */
rlm@1 365 static void
rlm@1 366 __yy_memcpy (char *to, char *from, unsigned int count)
rlm@1 367 {
rlm@1 368 register char *t = to;
rlm@1 369 register char *f = from;
rlm@1 370 register int i = count;
rlm@1 371
rlm@1 372 while (i-- > 0)
rlm@1 373 *t++ = *f++;
rlm@1 374 }
rlm@1 375
rlm@1 376 #endif
rlm@1 377 #endif
rlm@1 378
rlm@1 379 #line 217 "/usr/lib/bison.simple"
rlm@1 380
rlm@1 381 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
rlm@1 382 into yyparse. The argument should have type void *.
rlm@1 383 It should actually point to an object.
rlm@1 384 Grammar actions can access the variable by casting it
rlm@1 385 to the proper pointer type. */
rlm@1 386
rlm@1 387 #ifdef YYPARSE_PARAM
rlm@1 388 #ifdef __cplusplus
rlm@1 389 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
rlm@1 390 #define YYPARSE_PARAM_DECL
rlm@1 391 #else /* not __cplusplus */
rlm@1 392 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
rlm@1 393 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
rlm@1 394 #endif /* not __cplusplus */
rlm@1 395 #else /* not YYPARSE_PARAM */
rlm@1 396 #define YYPARSE_PARAM_ARG
rlm@1 397 #define YYPARSE_PARAM_DECL
rlm@1 398 #endif /* not YYPARSE_PARAM */
rlm@1 399
rlm@1 400 /* Prevent warning if -Wstrict-prototypes. */
rlm@1 401 #ifdef __GNUC__
rlm@1 402 #ifdef YYPARSE_PARAM
rlm@1 403 int yyparse (void *);
rlm@1 404 #else
rlm@1 405 int yyparse (void);
rlm@1 406 #endif
rlm@1 407 #endif
rlm@1 408
rlm@1 409 int
rlm@1 410 yyparse(YYPARSE_PARAM_ARG)
rlm@1 411 YYPARSE_PARAM_DECL
rlm@1 412 {
rlm@1 413 register int yystate;
rlm@1 414 register int yyn;
rlm@1 415 register short *yyssp;
rlm@1 416 register YYSTYPE *yyvsp;
rlm@1 417 int yyerrstatus; /* number of tokens to shift before error messages enabled */
rlm@1 418 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
rlm@1 419
rlm@1 420 short yyssa[YYINITDEPTH]; /* the state stack */
rlm@1 421 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
rlm@1 422
rlm@1 423 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
rlm@1 424 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
rlm@1 425
rlm@1 426 #ifdef YYLSP_NEEDED
rlm@1 427 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
rlm@1 428 YYLTYPE *yyls = yylsa;
rlm@1 429 YYLTYPE *yylsp;
rlm@1 430
rlm@1 431 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
rlm@1 432 #else
rlm@1 433 #define YYPOPSTACK (yyvsp--, yyssp--)
rlm@1 434 #endif
rlm@1 435
rlm@1 436 int yystacksize = YYINITDEPTH;
rlm@1 437 int yyfree_stacks = 0;
rlm@1 438
rlm@1 439 #ifdef YYPURE
rlm@1 440 int yychar;
rlm@1 441 YYSTYPE yylval;
rlm@1 442 int yynerrs;
rlm@1 443 #ifdef YYLSP_NEEDED
rlm@1 444 YYLTYPE yylloc;
rlm@1 445 #endif
rlm@1 446 #endif
rlm@1 447
rlm@1 448 YYSTYPE yyval; /* the variable used to return */
rlm@1 449 /* semantic values from the action */
rlm@1 450 /* routines */
rlm@1 451
rlm@1 452 int yylen;
rlm@1 453
rlm@1 454 #if YYDEBUG != 0
rlm@1 455 if (yydebug)
rlm@1 456 fprintf(stderr, "Starting parse\n");
rlm@1 457 #endif
rlm@1 458
rlm@1 459 yystate = 0;
rlm@1 460 yyerrstatus = 0;
rlm@1 461 yynerrs = 0;
rlm@1 462 yychar = YYEMPTY; /* Cause a token to be read. */
rlm@1 463
rlm@1 464 /* Initialize stack pointers.
rlm@1 465 Waste one element of value and location stack
rlm@1 466 so that they stay on the same level as the state stack.
rlm@1 467 The wasted elements are never initialized. */
rlm@1 468
rlm@1 469 yyssp = yyss - 1;
rlm@1 470 yyvsp = yyvs;
rlm@1 471 #ifdef YYLSP_NEEDED
rlm@1 472 yylsp = yyls;
rlm@1 473 #endif
rlm@1 474
rlm@1 475 /* Push a new state, which is found in yystate . */
rlm@1 476 /* In all cases, when you get here, the value and location stacks
rlm@1 477 have just been pushed. so pushing a state here evens the stacks. */
rlm@1 478 yynewstate:
rlm@1 479
rlm@1 480 *++yyssp = yystate;
rlm@1 481
rlm@1 482 if (yyssp >= yyss + yystacksize - 1)
rlm@1 483 {
rlm@1 484 /* Give user a chance to reallocate the stack */
rlm@1 485 /* Use copies of these so that the &'s don't force the real ones into memory. */
rlm@1 486 YYSTYPE *yyvs1 = yyvs;
rlm@1 487 short *yyss1 = yyss;
rlm@1 488 #ifdef YYLSP_NEEDED
rlm@1 489 YYLTYPE *yyls1 = yyls;
rlm@1 490 #endif
rlm@1 491
rlm@1 492 /* Get the current used size of the three stacks, in elements. */
rlm@1 493 int size = yyssp - yyss + 1;
rlm@1 494
rlm@1 495 #ifdef yyoverflow
rlm@1 496 /* Each stack pointer address is followed by the size of
rlm@1 497 the data in use in that stack, in bytes. */
rlm@1 498 #ifdef YYLSP_NEEDED
rlm@1 499 /* This used to be a conditional around just the two extra args,
rlm@1 500 but that might be undefined if yyoverflow is a macro. */
rlm@1 501 yyoverflow("parser stack overflow",
rlm@1 502 &yyss1, size * sizeof (*yyssp),
rlm@1 503 &yyvs1, size * sizeof (*yyvsp),
rlm@1 504 &yyls1, size * sizeof (*yylsp),
rlm@1 505 &yystacksize);
rlm@1 506 #else
rlm@1 507 yyoverflow("parser stack overflow",
rlm@1 508 &yyss1, size * sizeof (*yyssp),
rlm@1 509 &yyvs1, size * sizeof (*yyvsp),
rlm@1 510 &yystacksize);
rlm@1 511 #endif
rlm@1 512
rlm@1 513 yyss = yyss1; yyvs = yyvs1;
rlm@1 514 #ifdef YYLSP_NEEDED
rlm@1 515 yyls = yyls1;
rlm@1 516 #endif
rlm@1 517 #else /* no yyoverflow */
rlm@1 518 /* Extend the stack our own way. */
rlm@1 519 if (yystacksize >= YYMAXDEPTH)
rlm@1 520 {
rlm@1 521 yyerror("parser stack overflow");
rlm@1 522 if (yyfree_stacks)
rlm@1 523 {
rlm@1 524 free (yyss);
rlm@1 525 free (yyvs);
rlm@1 526 #ifdef YYLSP_NEEDED
rlm@1 527 free (yyls);
rlm@1 528 #endif
rlm@1 529 }
rlm@1 530 return 2;
rlm@1 531 }
rlm@1 532 yystacksize *= 2;
rlm@1 533 if (yystacksize > YYMAXDEPTH)
rlm@1 534 yystacksize = YYMAXDEPTH;
rlm@1 535 #ifndef YYSTACK_USE_ALLOCA
rlm@1 536 yyfree_stacks = 1;
rlm@1 537 #endif
rlm@1 538 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
rlm@1 539 __yy_memcpy ((char *)yyss, (char *)yyss1,
rlm@1 540 size * (unsigned int) sizeof (*yyssp));
rlm@1 541 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
rlm@1 542 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
rlm@1 543 size * (unsigned int) sizeof (*yyvsp));
rlm@1 544 #ifdef YYLSP_NEEDED
rlm@1 545 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
rlm@1 546 __yy_memcpy ((char *)yyls, (char *)yyls1,
rlm@1 547 size * (unsigned int) sizeof (*yylsp));
rlm@1 548 #endif
rlm@1 549 #endif /* no yyoverflow */
rlm@1 550
rlm@1 551 yyssp = yyss + size - 1;
rlm@1 552 yyvsp = yyvs + size - 1;
rlm@1 553 #ifdef YYLSP_NEEDED
rlm@1 554 yylsp = yyls + size - 1;
rlm@1 555 #endif
rlm@1 556
rlm@1 557 #if YYDEBUG != 0
rlm@1 558 if (yydebug)
rlm@1 559 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
rlm@1 560 #endif
rlm@1 561
rlm@1 562 if (yyssp >= yyss + yystacksize - 1)
rlm@1 563 YYABORT;
rlm@1 564 }
rlm@1 565
rlm@1 566 #if YYDEBUG != 0
rlm@1 567 if (yydebug)
rlm@1 568 fprintf(stderr, "Entering state %d\n", yystate);
rlm@1 569 #endif
rlm@1 570
rlm@1 571 goto yybackup;
rlm@1 572 yybackup:
rlm@1 573
rlm@1 574 /* Do appropriate processing given the current state. */
rlm@1 575 /* Read a lookahead token if we need one and don't already have one. */
rlm@1 576 /* yyresume: */
rlm@1 577
rlm@1 578 /* First try to decide what to do without reference to lookahead token. */
rlm@1 579
rlm@1 580 yyn = yypact[yystate];
rlm@1 581 if (yyn == YYFLAG)
rlm@1 582 goto yydefault;
rlm@1 583
rlm@1 584 /* Not known => get a lookahead token if don't already have one. */
rlm@1 585
rlm@1 586 /* yychar is either YYEMPTY or YYEOF
rlm@1 587 or a valid token in external form. */
rlm@1 588
rlm@1 589 if (yychar == YYEMPTY)
rlm@1 590 {
rlm@1 591 #if YYDEBUG != 0
rlm@1 592 if (yydebug)
rlm@1 593 fprintf(stderr, "Reading a token: ");
rlm@1 594 #endif
rlm@1 595 yychar = YYLEX;
rlm@1 596 }
rlm@1 597
rlm@1 598 /* Convert token to internal form (in yychar1) for indexing tables with */
rlm@1 599
rlm@1 600 if (yychar <= 0) /* This means end of input. */
rlm@1 601 {
rlm@1 602 yychar1 = 0;
rlm@1 603 yychar = YYEOF; /* Don't call YYLEX any more */
rlm@1 604
rlm@1 605 #if YYDEBUG != 0
rlm@1 606 if (yydebug)
rlm@1 607 fprintf(stderr, "Now at end of input.\n");
rlm@1 608 #endif
rlm@1 609 }
rlm@1 610 else
rlm@1 611 {
rlm@1 612 yychar1 = YYTRANSLATE(yychar);
rlm@1 613
rlm@1 614 #if YYDEBUG != 0
rlm@1 615 if (yydebug)
rlm@1 616 {
rlm@1 617 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
rlm@1 618 /* Give the individual parser a way to print the precise meaning
rlm@1 619 of a token, for further debugging info. */
rlm@1 620 #ifdef YYPRINT
rlm@1 621 YYPRINT (stderr, yychar, yylval);
rlm@1 622 #endif
rlm@1 623 fprintf (stderr, ")\n");
rlm@1 624 }
rlm@1 625 #endif
rlm@1 626 }
rlm@1 627
rlm@1 628 yyn += yychar1;
rlm@1 629 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
rlm@1 630 goto yydefault;
rlm@1 631
rlm@1 632 yyn = yytable[yyn];
rlm@1 633
rlm@1 634 /* yyn is what to do for this token type in this state.
rlm@1 635 Negative => reduce, -yyn is rule number.
rlm@1 636 Positive => shift, yyn is new state.
rlm@1 637 New state is final state => don't bother to shift,
rlm@1 638 just return success.
rlm@1 639 0, or most negative number => error. */
rlm@1 640
rlm@1 641 if (yyn < 0)
rlm@1 642 {
rlm@1 643 if (yyn == YYFLAG)
rlm@1 644 goto yyerrlab;
rlm@1 645 yyn = -yyn;
rlm@1 646 goto yyreduce;
rlm@1 647 }
rlm@1 648 else if (yyn == 0)
rlm@1 649 goto yyerrlab;
rlm@1 650
rlm@1 651 if (yyn == YYFINAL)
rlm@1 652 YYACCEPT;
rlm@1 653
rlm@1 654 /* Shift the lookahead token. */
rlm@1 655
rlm@1 656 #if YYDEBUG != 0
rlm@1 657 if (yydebug)
rlm@1 658 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
rlm@1 659 #endif
rlm@1 660
rlm@1 661 /* Discard the token being shifted unless it is eof. */
rlm@1 662 if (yychar != YYEOF)
rlm@1 663 yychar = YYEMPTY;
rlm@1 664
rlm@1 665 *++yyvsp = yylval;
rlm@1 666 #ifdef YYLSP_NEEDED
rlm@1 667 *++yylsp = yylloc;
rlm@1 668 #endif
rlm@1 669
rlm@1 670 /* count tokens shifted since error; after three, turn off error status. */
rlm@1 671 if (yyerrstatus) yyerrstatus--;
rlm@1 672
rlm@1 673 yystate = yyn;
rlm@1 674 goto yynewstate;
rlm@1 675
rlm@1 676 /* Do the default action for the current state. */
rlm@1 677 yydefault:
rlm@1 678
rlm@1 679 yyn = yydefact[yystate];
rlm@1 680 if (yyn == 0)
rlm@1 681 goto yyerrlab;
rlm@1 682
rlm@1 683 /* Do a reduction. yyn is the number of a rule to reduce with. */
rlm@1 684 yyreduce:
rlm@1 685 yylen = yyr2[yyn];
rlm@1 686 if (yylen > 0)
rlm@1 687 yyval = yyvsp[1-yylen]; /* implement default value of the action */
rlm@1 688
rlm@1 689 #if YYDEBUG != 0
rlm@1 690 if (yydebug)
rlm@1 691 {
rlm@1 692 int i;
rlm@1 693
rlm@1 694 fprintf (stderr, "Reducing via rule %d (line %d), ",
rlm@1 695 yyn, yyrline[yyn]);
rlm@1 696
rlm@1 697 /* Print the symbols being reduced, and their result. */
rlm@1 698 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
rlm@1 699 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
rlm@1 700 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
rlm@1 701 }
rlm@1 702 #endif
rlm@1 703
rlm@1 704
rlm@1 705 switch (yyn) {
rlm@1 706
rlm@1 707 case 1:
rlm@1 708 #line 32 "expr.y"
rlm@1 709 { result = yyvsp[0]; ;
rlm@1 710 break;}
rlm@1 711 case 2:
rlm@1 712 #line 36 "expr.y"
rlm@1 713 { yyval = yyvsp[0]; ;
rlm@1 714 break;}
rlm@1 715 case 3:
rlm@1 716 #line 37 "expr.y"
rlm@1 717 { yyval = yyvsp[-1]; ;
rlm@1 718 break;}
rlm@1 719 case 4:
rlm@1 720 #line 38 "expr.y"
rlm@1 721 { yyval = exprNodeDot(yyvsp[-2], yyvsp[0]); ;
rlm@1 722 break;}
rlm@1 723 case 5:
rlm@1 724 #line 39 "expr.y"
rlm@1 725 { yyval = exprNodeArrow(yyvsp[-2], yyvsp[0]); ;
rlm@1 726 break;}
rlm@1 727 case 6:
rlm@1 728 #line 40 "expr.y"
rlm@1 729 { yyval = exprNodeArray(yyvsp[-3], yyvsp[-1]); ;
rlm@1 730 break;}
rlm@1 731 case 7:
rlm@1 732 #line 43 "expr.y"
rlm@1 733 { yyval = yyvsp[0]; ;
rlm@1 734 break;}
rlm@1 735 case 8:
rlm@1 736 #line 44 "expr.y"
rlm@1 737 { yyval = exprNodeStar(yyvsp[0]); ;
rlm@1 738 break;}
rlm@1 739 case 9:
rlm@1 740 #line 45 "expr.y"
rlm@1 741 { yyval = exprNodeAddr(yyvsp[0]); ;
rlm@1 742 break;}
rlm@1 743 case 10:
rlm@1 744 #line 46 "expr.y"
rlm@1 745 { yyval = exprNodeSizeof(yyvsp[-1]); ;
rlm@1 746 break;}
rlm@1 747 case 11:
rlm@1 748 #line 50 "expr.y"
rlm@1 749 { yyval = exprNodeNumber(); ;
rlm@1 750 break;}
rlm@1 751 case 12:
rlm@1 752 #line 54 "expr.y"
rlm@1 753 {yyval = exprNodeIdentifier(); ;
rlm@1 754 break;}
rlm@1 755 }
rlm@1 756 /* the action file gets copied in in place of this dollarsign */
rlm@1 757 #line 543 "/usr/lib/bison.simple"
rlm@1 758
rlm@1 759 yyvsp -= yylen;
rlm@1 760 yyssp -= yylen;
rlm@1 761 #ifdef YYLSP_NEEDED
rlm@1 762 yylsp -= yylen;
rlm@1 763 #endif
rlm@1 764
rlm@1 765 #if YYDEBUG != 0
rlm@1 766 if (yydebug)
rlm@1 767 {
rlm@1 768 short *ssp1 = yyss - 1;
rlm@1 769 fprintf (stderr, "state stack now");
rlm@1 770 while (ssp1 != yyssp)
rlm@1 771 fprintf (stderr, " %d", *++ssp1);
rlm@1 772 fprintf (stderr, "\n");
rlm@1 773 }
rlm@1 774 #endif
rlm@1 775
rlm@1 776 *++yyvsp = yyval;
rlm@1 777
rlm@1 778 #ifdef YYLSP_NEEDED
rlm@1 779 yylsp++;
rlm@1 780 if (yylen == 0)
rlm@1 781 {
rlm@1 782 yylsp->first_line = yylloc.first_line;
rlm@1 783 yylsp->first_column = yylloc.first_column;
rlm@1 784 yylsp->last_line = (yylsp-1)->last_line;
rlm@1 785 yylsp->last_column = (yylsp-1)->last_column;
rlm@1 786 yylsp->text = 0;
rlm@1 787 }
rlm@1 788 else
rlm@1 789 {
rlm@1 790 yylsp->last_line = (yylsp+yylen-1)->last_line;
rlm@1 791 yylsp->last_column = (yylsp+yylen-1)->last_column;
rlm@1 792 }
rlm@1 793 #endif
rlm@1 794
rlm@1 795 /* Now "shift" the result of the reduction.
rlm@1 796 Determine what state that goes to,
rlm@1 797 based on the state we popped back to
rlm@1 798 and the rule number reduced by. */
rlm@1 799
rlm@1 800 yyn = yyr1[yyn];
rlm@1 801
rlm@1 802 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
rlm@1 803 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
rlm@1 804 yystate = yytable[yystate];
rlm@1 805 else
rlm@1 806 yystate = yydefgoto[yyn - YYNTBASE];
rlm@1 807
rlm@1 808 goto yynewstate;
rlm@1 809
rlm@1 810 yyerrlab: /* here on detecting error */
rlm@1 811
rlm@1 812 if (! yyerrstatus)
rlm@1 813 /* If not already recovering from an error, report this error. */
rlm@1 814 {
rlm@1 815 ++yynerrs;
rlm@1 816
rlm@1 817 #ifdef YYERROR_VERBOSE
rlm@1 818 yyn = yypact[yystate];
rlm@1 819
rlm@1 820 if (yyn > YYFLAG && yyn < YYLAST)
rlm@1 821 {
rlm@1 822 int size = 0;
rlm@1 823 char *msg;
rlm@1 824 int x, count;
rlm@1 825
rlm@1 826 count = 0;
rlm@1 827 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
rlm@1 828 for (x = (yyn < 0 ? -yyn : 0);
rlm@1 829 x < (sizeof(yytname) / sizeof(char *)); x++)
rlm@1 830 if (yycheck[x + yyn] == x)
rlm@1 831 size += strlen(yytname[x]) + 15, count++;
rlm@1 832 msg = (char *) malloc(size + 15);
rlm@1 833 if (msg != 0)
rlm@1 834 {
rlm@1 835 strcpy(msg, "parse error");
rlm@1 836
rlm@1 837 if (count < 5)
rlm@1 838 {
rlm@1 839 count = 0;
rlm@1 840 for (x = (yyn < 0 ? -yyn : 0);
rlm@1 841 x < (sizeof(yytname) / sizeof(char *)); x++)
rlm@1 842 if (yycheck[x + yyn] == x)
rlm@1 843 {
rlm@1 844 strcat(msg, count == 0 ? ", expecting `" : " or `");
rlm@1 845 strcat(msg, yytname[x]);
rlm@1 846 strcat(msg, "'");
rlm@1 847 count++;
rlm@1 848 }
rlm@1 849 }
rlm@1 850 yyerror(msg);
rlm@1 851 free(msg);
rlm@1 852 }
rlm@1 853 else
rlm@1 854 yyerror ("parse error; also virtual memory exceeded");
rlm@1 855 }
rlm@1 856 else
rlm@1 857 #endif /* YYERROR_VERBOSE */
rlm@1 858 yyerror("parse error");
rlm@1 859 }
rlm@1 860
rlm@1 861 goto yyerrlab1;
rlm@1 862 yyerrlab1: /* here on error raised explicitly by an action */
rlm@1 863
rlm@1 864 if (yyerrstatus == 3)
rlm@1 865 {
rlm@1 866 /* if just tried and failed to reuse lookahead token after an error, discard it. */
rlm@1 867
rlm@1 868 /* return failure if at end of input */
rlm@1 869 if (yychar == YYEOF)
rlm@1 870 YYABORT;
rlm@1 871
rlm@1 872 #if YYDEBUG != 0
rlm@1 873 if (yydebug)
rlm@1 874 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
rlm@1 875 #endif
rlm@1 876
rlm@1 877 yychar = YYEMPTY;
rlm@1 878 }
rlm@1 879
rlm@1 880 /* Else will try to reuse lookahead token
rlm@1 881 after shifting the error token. */
rlm@1 882
rlm@1 883 yyerrstatus = 3; /* Each real token shifted decrements this */
rlm@1 884
rlm@1 885 goto yyerrhandle;
rlm@1 886
rlm@1 887 yyerrdefault: /* current state does not do anything special for the error token. */
rlm@1 888
rlm@1 889 #if 0
rlm@1 890 /* This is wrong; only states that explicitly want error tokens
rlm@1 891 should shift them. */
rlm@1 892 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
rlm@1 893 if (yyn) goto yydefault;
rlm@1 894 #endif
rlm@1 895
rlm@1 896 yyerrpop: /* pop the current state because it cannot handle the error token */
rlm@1 897
rlm@1 898 if (yyssp == yyss) YYABORT;
rlm@1 899 yyvsp--;
rlm@1 900 yystate = *--yyssp;
rlm@1 901 #ifdef YYLSP_NEEDED
rlm@1 902 yylsp--;
rlm@1 903 #endif
rlm@1 904
rlm@1 905 #if YYDEBUG != 0
rlm@1 906 if (yydebug)
rlm@1 907 {
rlm@1 908 short *ssp1 = yyss - 1;
rlm@1 909 fprintf (stderr, "Error: state stack now");
rlm@1 910 while (ssp1 != yyssp)
rlm@1 911 fprintf (stderr, " %d", *++ssp1);
rlm@1 912 fprintf (stderr, "\n");
rlm@1 913 }
rlm@1 914 #endif
rlm@1 915
rlm@1 916 yyerrhandle:
rlm@1 917
rlm@1 918 yyn = yypact[yystate];
rlm@1 919 if (yyn == YYFLAG)
rlm@1 920 goto yyerrdefault;
rlm@1 921
rlm@1 922 yyn += YYTERROR;
rlm@1 923 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
rlm@1 924 goto yyerrdefault;
rlm@1 925
rlm@1 926 yyn = yytable[yyn];
rlm@1 927 if (yyn < 0)
rlm@1 928 {
rlm@1 929 if (yyn == YYFLAG)
rlm@1 930 goto yyerrpop;
rlm@1 931 yyn = -yyn;
rlm@1 932 goto yyreduce;
rlm@1 933 }
rlm@1 934 else if (yyn == 0)
rlm@1 935 goto yyerrpop;
rlm@1 936
rlm@1 937 if (yyn == YYFINAL)
rlm@1 938 YYACCEPT;
rlm@1 939
rlm@1 940 #if YYDEBUG != 0
rlm@1 941 if (yydebug)
rlm@1 942 fprintf(stderr, "Shifting error token, ");
rlm@1 943 #endif
rlm@1 944
rlm@1 945 *++yyvsp = yylval;
rlm@1 946 #ifdef YYLSP_NEEDED
rlm@1 947 *++yylsp = yylloc;
rlm@1 948 #endif
rlm@1 949
rlm@1 950 yystate = yyn;
rlm@1 951 goto yynewstate;
rlm@1 952
rlm@1 953 yyacceptlab:
rlm@1 954 /* YYACCEPT comes here. */
rlm@1 955 if (yyfree_stacks)
rlm@1 956 {
rlm@1 957 free (yyss);
rlm@1 958 free (yyvs);
rlm@1 959 #ifdef YYLSP_NEEDED
rlm@1 960 free (yyls);
rlm@1 961 #endif
rlm@1 962 }
rlm@1 963 return 0;
rlm@1 964
rlm@1 965 yyabortlab:
rlm@1 966 /* YYABORT comes here. */
rlm@1 967 if (yyfree_stacks)
rlm@1 968 {
rlm@1 969 free (yyss);
rlm@1 970 free (yyvs);
rlm@1 971 #ifdef YYLSP_NEEDED
rlm@1 972 free (yyls);
rlm@1 973 #endif
rlm@1 974 }
rlm@1 975 return 1;
rlm@1 976 }
rlm@1 977 #line 57 "expr.y"
rlm@1 978
rlm@1 979
rlm@1 980 int yyerror(char *s)
rlm@1 981 {
rlm@1 982 return 0;
rlm@1 983 }
rlm@1 984
rlm@1 985 #ifndef SDL
rlm@1 986 extern FILE *yyin;
rlm@1 987 int main(int argc, char **argv)
rlm@1 988 {
rlm@1 989 // yydebug = 1;
rlm@1 990 ++argv, --argc;
rlm@1 991 if(argc > 0)
rlm@1 992 yyin = fopen(argv[0], "r");
rlm@1 993 else
rlm@1 994 yyin = stdin;
rlm@1 995 if(!yyparse())
rlm@1 996 result->print();
rlm@1 997 }
rlm@1 998 #endif