Commit c189b2afe2fb1ba6ae887bf0ea636003e3cc2e9b
1 parent
29ce46252f
Exists in
master
switch sort of working
Showing 6 changed files with 451 additions and 189 deletions Side-by-side Diff
ast_stmt.cc
View file @
c189b2a
... | ... | @@ -318,6 +318,8 @@ |
318 | 318 | } |
319 | 319 | //stack for both |
320 | 320 | |
321 | + | |
322 | +// TODO : DEFAULT DOESN'T WORK RIGHT AND ONLY THE FIRST STATEMENT IN A BLOCK IS USED | |
321 | 323 | llvm::Value * SwitchStmt::Emit(){ |
322 | 324 | |
323 | 325 | llvm::SwitchInst * val; |
324 | 326 | |
325 | 327 | |
326 | 328 | |
... | ... | @@ -330,18 +332,29 @@ |
330 | 332 | } |
331 | 333 | //Emit of expression |
332 | 334 | llvm::Value * exprVal=expr->Emit(); |
335 | + llvm::BasicBlock* footer = llvm::BasicBlock::Create(*context, "switchFooter", func); | |
336 | + irgen.SetFooterBlock(footer); | |
333 | 337 | |
334 | 338 | //create switch instruction pass in default |
335 | - val=llvm::SwitchInst::Create(exprVal, blockArr[cases->NumElements()], cases->NumElements(), irgen.GetBasicBlock()); | |
339 | + val=llvm::SwitchInst::Create(exprVal, blockArr[cases->NumElements()-1], cases->NumElements(), irgen.GetBasicBlock()); | |
336 | 340 | |
337 | 341 | //for each case 'addCase to switch stmt', EMIT for stmt in case, create terminator instruction |
338 | 342 | for(int i=0; i<cases->NumElements();i++){ |
339 | 343 | //add addCase to switch stmt |
340 | 344 | //addcase to val method |
341 | - val->addCase (llvm::ConstantInt::get(llvm::IntegerType::get(*context, 32), i), blockArr[i]); | |
342 | - cases->Nth(i)->Emit(); | |
343 | - irgen.GetBasicBlock()->getTerminator(); | |
345 | + irgen.SetBasicBlock(blockArr[i]); | |
346 | + llvm::Value* c = cases->Nth(i)->Emit(); | |
347 | + // I think this is only necessary because the parse is buggy | |
348 | + // and interprets "case 1: foo(); break;" as 2 cases | |
349 | + if(dynamic_cast<llvm::ConstantInt*>(c)) | |
350 | + { | |
351 | + val->addCase (dynamic_cast<llvm::ConstantInt*>(c), blockArr[i]); | |
352 | + } | |
353 | + if(!blockArr[i]->getTerminator()) { | |
354 | + llvm::BranchInst::Create(footer, blockArr[i]); | |
355 | + } | |
344 | 356 | } |
357 | + irgen.SetBasicBlock(footer); | |
345 | 358 | return val; |
346 | 359 | } |
347 | 360 |
parser.y
View file @
c189b2a
... | ... | @@ -130,7 +130,7 @@ |
130 | 130 | * ----- |
131 | 131 | * All productions and actions should be placed between the start and stop |
132 | 132 | * %% markers which delimit the Rules section. |
133 | - | |
133 | + | |
134 | 134 | */ |
135 | 135 | Program : DeclList { |
136 | 136 | @1; |
137 | 137 | |
... | ... | @@ -433,12 +433,12 @@ |
433 | 433 | | EqualityExpr T_EQ RelationExpr |
434 | 434 | { |
435 | 435 | Operator *op = new Operator(yylloc, $2); |
436 | - $$ = new ArithmeticExpr($1, op, $3); | |
436 | + $$ = new EqualityExpr($1, op, $3); | |
437 | 437 | } |
438 | 438 | | EqualityExpr T_NE RelationExpr |
439 | 439 | { |
440 | 440 | Operator *op = new Operator(yylloc, $2); |
441 | - $$ = new ArithmeticExpr($1, op, $3); | |
441 | + $$ = new EqualityExpr($1, op, $3); | |
442 | 442 | } |
443 | 443 | ; |
444 | 444 | |
... | ... | @@ -446,7 +446,7 @@ |
446 | 446 | | LogicAndExpr T_And EqualityExpr |
447 | 447 | { |
448 | 448 | Operator *op = new Operator(yylloc, $2); |
449 | - $$ = new ArithmeticExpr($1, op, $3); | |
449 | + $$ = new LogicalExpr($1, op, $3); | |
450 | 450 | } |
451 | 451 | ; |
452 | 452 | |
... | ... | @@ -454,7 +454,7 @@ |
454 | 454 | | LogicOrExpr T_Or LogicAndExpr |
455 | 455 | { |
456 | 456 | Operator *op = new Operator(yylloc, $2); |
457 | - $$ = new ArithmeticExpr($1, op, $3); | |
457 | + $$ = new LogicalExpr($1, op, $3); | |
458 | 458 | } |
459 | 459 | ; |
460 | 460 |
test.sh
View file @
c189b2a
... | ... | @@ -3,10 +3,10 @@ |
3 | 3 | set -bm |
4 | 4 | trap 'if [[ $? -eq 139 ]]; then echo "segfault $testbasename!" >> $testbasename.out; fi' CHLD |
5 | 5 | |
6 | -if (! [ -d public_samples ]); then | |
7 | - echo "public_samples folder not found. Creating one for you" | |
6 | +if (! [ -d Checkpoint ]); then | |
7 | + echo "Checkpoint folder not found. Creating one for you" | |
8 | 8 | echo "Copy all .glsl .dat and .out test file inside this folder" |
9 | - mkdir public_samples | |
9 | + mkdir Checkpoint | |
10 | 10 | exit 1 |
11 | 11 | fi |
12 | 12 | |
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | |
16 | 16 | echo "Compiling Done" |
17 | 17 | |
18 | -if cd public_samples; then | |
18 | +if cd Checkpoint; then | |
19 | 19 | cp ../glc ./ |
20 | 20 | chmod +x ./gli |
21 | 21 | |
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | do |
36 | 36 | testid=$(basename $testname) |
37 | 37 | testbasename=${testid%.glsl} |
38 | + echo "testing $testbasename" | |
38 | 39 | rm -rf "$testbasename".ll |
39 | 40 | rm -rf "$testbasename".bc |
40 | 41 | ./glc <$testname > $testbasename.bc |
y.output
View file @
c189b2a
y.tab.c
View file @
c189b2a
Diff suppressed. Click to show
1 | -/* A Bison parser, made by GNU Bison 2.3. */ | |
2 | 1 | |
3 | -/* Skeleton implementation for Bison's Yacc-like parsers in C | |
2 | +/* A Bison parser, made by GNU Bison 2.4.1. */ | |
4 | 3 | |
5 | - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 | |
4 | +/* Skeleton implementation for Bison's Yacc-like parsers in C | |
5 | + | |
6 | + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 | |
6 | 7 | Free Software Foundation, Inc. |
7 | - | |
8 | - This program is free software; you can redistribute it and/or modify | |
8 | + | |
9 | + This program is free software: you can redistribute it and/or modify | |
9 | 10 | it under the terms of the GNU General Public License as published by |
10 | - the Free Software Foundation; either version 2, or (at your option) | |
11 | - any later version. | |
12 | - | |
11 | + the Free Software Foundation, either version 3 of the License, or | |
12 | + (at your option) any later version. | |
13 | + | |
13 | 14 | This program is distributed in the hope that it will be useful, |
14 | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | 17 | GNU General Public License for more details. |
17 | - | |
18 | + | |
18 | 19 | You should have received a copy of the GNU General Public License |
19 | - along with this program; if not, write to the Free Software | |
20 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
21 | - Boston, MA 02110-1301, USA. */ | |
20 | + along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
22 | 21 | |
23 | 22 | /* As a special exception, you may create a larger work that contains |
24 | 23 | part or all of the Bison parser skeleton and distribute that work |
... | ... | @@ -29,7 +28,7 @@ |
29 | 28 | special exception, which will cause the skeleton and the resulting |
30 | 29 | Bison output files to be licensed under the GNU General Public |
31 | 30 | License without this special exception. |
32 | - | |
31 | + | |
33 | 32 | This special exception was added by the Free Software Foundation in |
34 | 33 | version 2.2 of Bison. */ |
35 | 34 | |
... | ... | @@ -47,7 +46,7 @@ |
47 | 46 | #define YYBISON 1 |
48 | 47 | |
49 | 48 | /* Bison version. */ |
50 | -#define YYBISON_VERSION "2.3" | |
49 | +#define YYBISON_VERSION "2.4.1" | |
51 | 50 | |
52 | 51 | /* Skeleton name. */ |
53 | 52 | #define YYSKELETON_NAME "yacc.c" |
54 | 53 | |
... | ... | @@ -55,11 +54,59 @@ |
55 | 54 | /* Pure parsers. */ |
56 | 55 | #define YYPURE 0 |
57 | 56 | |
57 | +/* Push parsers. */ | |
58 | +#define YYPUSH 0 | |
59 | + | |
60 | +/* Pull parsers. */ | |
61 | +#define YYPULL 1 | |
62 | + | |
58 | 63 | /* Using locations. */ |
59 | 64 | #define YYLSP_NEEDED 1 |
60 | 65 | |
61 | 66 | |
62 | 67 | |
68 | +/* Copy the first part of user declarations. */ | |
69 | + | |
70 | +/* Line 189 of yacc.c */ | |
71 | +#line 11 "parser.y" | |
72 | + | |
73 | + | |
74 | +/* Just like lex, the text within this first region delimited by %{ and %} | |
75 | + * is assumed to be C/C++ code and will be copied verbatim to the y.tab.c | |
76 | + * file ahead of the definitions of the yyparse() function. Add other header | |
77 | + * file inclusions or C++ variable declarations/prototypes that are needed | |
78 | + * by your code here. | |
79 | + */ | |
80 | +#include "scanner.h" // for yylex | |
81 | +#include "parser.h" | |
82 | +#include "errors.h" | |
83 | + | |
84 | +void yyerror(const char *msg); // standard error-handling routine | |
85 | + | |
86 | + | |
87 | + | |
88 | +/* Line 189 of yacc.c */ | |
89 | +#line 90 "y.tab.c" | |
90 | + | |
91 | +/* Enabling traces. */ | |
92 | +#ifndef YYDEBUG | |
93 | +# define YYDEBUG 1 | |
94 | +#endif | |
95 | + | |
96 | +/* Enabling verbose error messages. */ | |
97 | +#ifdef YYERROR_VERBOSE | |
98 | +# undef YYERROR_VERBOSE | |
99 | +# define YYERROR_VERBOSE 1 | |
100 | +#else | |
101 | +# define YYERROR_VERBOSE 0 | |
102 | +#endif | |
103 | + | |
104 | +/* Enabling the token table. */ | |
105 | +#ifndef YYTOKEN_TABLE | |
106 | +# define YYTOKEN_TABLE 0 | |
107 | +#endif | |
108 | + | |
109 | + | |
63 | 110 | /* Tokens. */ |
64 | 111 | #ifndef YYTOKENTYPE |
65 | 112 | # define YYTOKENTYPE |
66 | 113 | |
67 | 114 | |
... | ... | @@ -217,46 +264,13 @@ |
217 | 264 | |
218 | 265 | |
219 | 266 | |
220 | -/* Copy the first part of user declarations. */ | |
221 | -#line 11 "parser.y" | |
222 | - | |
223 | - | |
224 | -/* Just like lex, the text within this first region delimited by %{ and %} | |
225 | - * is assumed to be C/C++ code and will be copied verbatim to the y.tab.c | |
226 | - * file ahead of the definitions of the yyparse() function. Add other header | |
227 | - * file inclusions or C++ variable declarations/prototypes that are needed | |
228 | - * by your code here. | |
229 | - */ | |
230 | -#include "scanner.h" // for yylex | |
231 | -#include "parser.h" | |
232 | -#include "errors.h" | |
233 | - | |
234 | -void yyerror(const char *msg); // standard error-handling routine | |
235 | - | |
236 | - | |
237 | - | |
238 | -/* Enabling traces. */ | |
239 | -#ifndef YYDEBUG | |
240 | -# define YYDEBUG 1 | |
241 | -#endif | |
242 | - | |
243 | -/* Enabling verbose error messages. */ | |
244 | -#ifdef YYERROR_VERBOSE | |
245 | -# undef YYERROR_VERBOSE | |
246 | -# define YYERROR_VERBOSE 1 | |
247 | -#else | |
248 | -# define YYERROR_VERBOSE 0 | |
249 | -#endif | |
250 | - | |
251 | -/* Enabling the token table. */ | |
252 | -#ifndef YYTOKEN_TABLE | |
253 | -# define YYTOKEN_TABLE 0 | |
254 | -#endif | |
255 | - | |
256 | 267 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
257 | 268 | typedef union YYSTYPE |
258 | -#line 41 "parser.y" | |
259 | 269 | { |
270 | + | |
271 | +/* Line 214 of yacc.c */ | |
272 | +#line 41 "parser.y" | |
273 | + | |
260 | 274 | int integerConstant; |
261 | 275 | bool boolConstant; |
262 | 276 | double floatConstant; |
263 | 277 | |
... | ... | @@ -274,13 +288,15 @@ |
274 | 288 | Operator *ops; |
275 | 289 | Identifier *funcId; |
276 | 290 | List<Expr*> *argList; |
277 | -} | |
278 | -/* Line 193 of yacc.c. */ | |
279 | -#line 280 "y.tab.c" | |
280 | - YYSTYPE; | |
291 | + | |
292 | + | |
293 | + | |
294 | +/* Line 214 of yacc.c */ | |
295 | +#line 296 "y.tab.c" | |
296 | +} YYSTYPE; | |
297 | +# define YYSTYPE_IS_TRIVIAL 1 | |
281 | 298 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
282 | 299 | # define YYSTYPE_IS_DECLARED 1 |
283 | -# define YYSTYPE_IS_TRIVIAL 1 | |
284 | 300 | #endif |
285 | 301 | |
286 | 302 | #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED |
... | ... | @@ -300,8 +316,8 @@ |
300 | 316 | /* Copy the second part of user declarations. */ |
301 | 317 | |
302 | 318 | |
303 | -/* Line 216 of yacc.c. */ | |
304 | -#line 305 "y.tab.c" | |
319 | +/* Line 264 of yacc.c */ | |
320 | +#line 321 "y.tab.c" | |
305 | 321 | |
306 | 322 | #ifdef short |
307 | 323 | # undef short |
... | ... | @@ -351,7 +367,7 @@ |
351 | 367 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
352 | 368 | |
353 | 369 | #ifndef YY_ |
354 | -# if defined YYENABLE_NLS && YYENABLE_NLS | |
370 | +# if YYENABLE_NLS | |
355 | 371 | # if ENABLE_NLS |
356 | 372 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
357 | 373 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
358 | 374 | |
359 | 375 | |
... | ... | @@ -376,14 +392,14 @@ |
376 | 392 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
377 | 393 | || defined __cplusplus || defined _MSC_VER) |
378 | 394 | static int |
379 | -YYID (int i) | |
395 | +YYID (int yyi) | |
380 | 396 | #else |
381 | 397 | static int |
382 | -YYID (i) | |
383 | - int i; | |
398 | +YYID (yyi) | |
399 | + int yyi; | |
384 | 400 | #endif |
385 | 401 | { |
386 | - return i; | |
402 | + return yyi; | |
387 | 403 | } |
388 | 404 | #endif |
389 | 405 | |
... | ... | @@ -465,9 +481,9 @@ |
465 | 481 | /* A type that is properly aligned for any stack member. */ |
466 | 482 | union yyalloc |
467 | 483 | { |
468 | - yytype_int16 yyss; | |
469 | - YYSTYPE yyvs; | |
470 | - YYLTYPE yyls; | |
484 | + yytype_int16 yyss_alloc; | |
485 | + YYSTYPE yyvs_alloc; | |
486 | + YYLTYPE yyls_alloc; | |
471 | 487 | }; |
472 | 488 | |
473 | 489 | /* The size of the maximum gap between one aligned stack and the next. */ |
474 | 490 | |
... | ... | @@ -502,12 +518,12 @@ |
502 | 518 | elements in the stack, and YYPTR gives the new location of the |
503 | 519 | stack. Advance YYPTR to a properly aligned location for the next |
504 | 520 | stack. */ |
505 | -# define YYSTACK_RELOCATE(Stack) \ | |
521 | +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ | |
506 | 522 | do \ |
507 | 523 | { \ |
508 | 524 | YYSIZE_T yynewbytes; \ |
509 | - YYCOPY (&yyptr->Stack, Stack, yysize); \ | |
510 | - Stack = &yyptr->Stack; \ | |
525 | + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ | |
526 | + Stack = &yyptr->Stack_alloc; \ | |
511 | 527 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
512 | 528 | yyptr += yynewbytes / sizeof (*yyptr); \ |
513 | 529 | } \ |
... | ... | @@ -987,7 +1003,7 @@ |
987 | 1003 | we won't break user code: when these are the locations we know. */ |
988 | 1004 | |
989 | 1005 | #ifndef YY_LOCATION_PRINT |
990 | -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL | |
1006 | +# if YYLTYPE_IS_TRIVIAL | |
991 | 1007 | # define YY_LOCATION_PRINT(File, Loc) \ |
992 | 1008 | fprintf (File, "%d.%d-%d.%d", \ |
993 | 1009 | (Loc).first_line, (Loc).first_column, \ |
994 | 1010 | |
995 | 1011 | |
... | ... | @@ -1103,17 +1119,20 @@ |
1103 | 1119 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
1104 | 1120 | || defined __cplusplus || defined _MSC_VER) |
1105 | 1121 | static void |
1106 | -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) | |
1122 | +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) | |
1107 | 1123 | #else |
1108 | 1124 | static void |
1109 | -yy_stack_print (bottom, top) | |
1110 | - yytype_int16 *bottom; | |
1111 | - yytype_int16 *top; | |
1125 | +yy_stack_print (yybottom, yytop) | |
1126 | + yytype_int16 *yybottom; | |
1127 | + yytype_int16 *yytop; | |
1112 | 1128 | #endif |
1113 | 1129 | { |
1114 | 1130 | YYFPRINTF (stderr, "Stack now"); |
1115 | - for (; bottom <= top; ++bottom) | |
1116 | - YYFPRINTF (stderr, " %d", *bottom); | |
1131 | + for (; yybottom <= yytop; yybottom++) | |
1132 | + { | |
1133 | + int yybot = *yybottom; | |
1134 | + YYFPRINTF (stderr, " %d", yybot); | |
1135 | + } | |
1117 | 1136 | YYFPRINTF (stderr, "\n"); |
1118 | 1137 | } |
1119 | 1138 | |
1120 | 1139 | |
... | ... | @@ -1148,11 +1167,11 @@ |
1148 | 1167 | /* The symbols being reduced. */ |
1149 | 1168 | for (yyi = 0; yyi < yynrhs; yyi++) |
1150 | 1169 | { |
1151 | - fprintf (stderr, " $%d = ", yyi + 1); | |
1170 | + YYFPRINTF (stderr, " $%d = ", yyi + 1); | |
1152 | 1171 | yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], |
1153 | 1172 | &(yyvsp[(yyi + 1) - (yynrhs)]) |
1154 | 1173 | , &(yylsp[(yyi + 1) - (yynrhs)]) ); |
1155 | - fprintf (stderr, "\n"); | |
1174 | + YYFPRINTF (stderr, "\n"); | |
1156 | 1175 | } |
1157 | 1176 | } |
1158 | 1177 | |
1159 | 1178 | |
... | ... | @@ -1434,10 +1453,8 @@ |
1434 | 1453 | break; |
1435 | 1454 | } |
1436 | 1455 | } |
1437 | - | |
1438 | 1456 | |
1439 | 1457 | /* Prevent warnings from -Wmissing-prototypes. */ |
1440 | - | |
1441 | 1458 | #ifdef YYPARSE_PARAM |
1442 | 1459 | #if defined __STDC__ || defined __cplusplus |
1443 | 1460 | int yyparse (void *YYPARSE_PARAM); |
1444 | 1461 | |
1445 | 1462 | |
1446 | 1463 | |
1447 | 1464 | |
... | ... | @@ -1453,23 +1470,23 @@ |
1453 | 1470 | #endif /* ! YYPARSE_PARAM */ |
1454 | 1471 | |
1455 | 1472 | |
1456 | - | |
1457 | -/* The look-ahead symbol. */ | |
1473 | +/* The lookahead symbol. */ | |
1458 | 1474 | int yychar; |
1459 | 1475 | |
1460 | -/* The semantic value of the look-ahead symbol. */ | |
1476 | +/* The semantic value of the lookahead symbol. */ | |
1461 | 1477 | YYSTYPE yylval; |
1462 | 1478 | |
1479 | +/* Location data for the lookahead symbol. */ | |
1480 | +YYLTYPE yylloc; | |
1481 | + | |
1463 | 1482 | /* Number of syntax errors so far. */ |
1464 | 1483 | int yynerrs; |
1465 | -/* Location data for the look-ahead symbol. */ | |
1466 | -YYLTYPE yylloc; | |
1467 | 1484 | |
1468 | 1485 | |
1469 | 1486 | |
1470 | -/*----------. | |
1471 | -| yyparse. | | |
1472 | -`----------*/ | |
1487 | +/*-------------------------. | |
1488 | +| yyparse or yypush_parse. | | |
1489 | +`-------------------------*/ | |
1473 | 1490 | |
1474 | 1491 | #ifdef YYPARSE_PARAM |
1475 | 1492 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
1476 | 1493 | |
1477 | 1494 | |
1478 | 1495 | |
1479 | 1496 | |
1480 | 1497 | |
1481 | 1498 | |
1482 | 1499 | |
1483 | 1500 | |
1484 | 1501 | |
1485 | 1502 | |
1486 | 1503 | |
1487 | 1504 | |
1488 | 1505 | |
1489 | 1506 | |
... | ... | @@ -1493,78 +1510,87 @@ |
1493 | 1510 | #endif |
1494 | 1511 | #endif |
1495 | 1512 | { |
1496 | - | |
1497 | - int yystate; | |
1498 | - int yyn; | |
1499 | - int yyresult; | |
1500 | - /* Number of tokens to shift before error messages enabled. */ | |
1501 | - int yyerrstatus; | |
1502 | - /* Look-ahead token as an internal (translated) token number. */ | |
1503 | - int yytoken = 0; | |
1504 | -#if YYERROR_VERBOSE | |
1505 | - /* Buffer for error messages, and its allocated size. */ | |
1506 | - char yymsgbuf[128]; | |
1507 | - char *yymsg = yymsgbuf; | |
1508 | - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; | |
1509 | -#endif | |
1510 | 1513 | |
1511 | - /* Three stacks and their tools: | |
1512 | - `yyss': related to states, | |
1513 | - `yyvs': related to semantic values, | |
1514 | - `yyls': related to locations. | |
1515 | 1514 | |
1516 | - Refer to the stacks thru separate pointers, to allow yyoverflow | |
1517 | - to reallocate them elsewhere. */ | |
1515 | + int yystate; | |
1516 | + /* Number of tokens to shift before error messages enabled. */ | |
1517 | + int yyerrstatus; | |
1518 | 1518 | |
1519 | - /* The state stack. */ | |
1520 | - yytype_int16 yyssa[YYINITDEPTH]; | |
1521 | - yytype_int16 *yyss = yyssa; | |
1522 | - yytype_int16 *yyssp; | |
1519 | + /* The stacks and their tools: | |
1520 | + `yyss': related to states. | |
1521 | + `yyvs': related to semantic values. | |
1522 | + `yyls': related to locations. | |
1523 | 1523 | |
1524 | - /* The semantic value stack. */ | |
1525 | - YYSTYPE yyvsa[YYINITDEPTH]; | |
1526 | - YYSTYPE *yyvs = yyvsa; | |
1527 | - YYSTYPE *yyvsp; | |
1524 | + Refer to the stacks thru separate pointers, to allow yyoverflow | |
1525 | + to reallocate them elsewhere. */ | |
1528 | 1526 | |
1529 | - /* The location stack. */ | |
1530 | - YYLTYPE yylsa[YYINITDEPTH]; | |
1531 | - YYLTYPE *yyls = yylsa; | |
1532 | - YYLTYPE *yylsp; | |
1533 | - /* The locations where the error started and ended. */ | |
1534 | - YYLTYPE yyerror_range[2]; | |
1527 | + /* The state stack. */ | |
1528 | + yytype_int16 yyssa[YYINITDEPTH]; | |
1529 | + yytype_int16 *yyss; | |
1530 | + yytype_int16 *yyssp; | |
1535 | 1531 | |
1536 | -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) | |
1532 | + /* The semantic value stack. */ | |
1533 | + YYSTYPE yyvsa[YYINITDEPTH]; | |
1534 | + YYSTYPE *yyvs; | |
1535 | + YYSTYPE *yyvsp; | |
1537 | 1536 | |
1538 | - YYSIZE_T yystacksize = YYINITDEPTH; | |
1537 | + /* The location stack. */ | |
1538 | + YYLTYPE yylsa[YYINITDEPTH]; | |
1539 | + YYLTYPE *yyls; | |
1540 | + YYLTYPE *yylsp; | |
1539 | 1541 | |
1542 | + /* The locations where the error started and ended. */ | |
1543 | + YYLTYPE yyerror_range[2]; | |
1544 | + | |
1545 | + YYSIZE_T yystacksize; | |
1546 | + | |
1547 | + int yyn; | |
1548 | + int yyresult; | |
1549 | + /* Lookahead token as an internal (translated) token number. */ | |
1550 | + int yytoken; | |
1540 | 1551 | /* The variables used to return semantic value and location from the |
1541 | 1552 | action routines. */ |
1542 | 1553 | YYSTYPE yyval; |
1543 | 1554 | YYLTYPE yyloc; |
1544 | 1555 | |
1556 | +#if YYERROR_VERBOSE | |
1557 | + /* Buffer for error messages, and its allocated size. */ | |
1558 | + char yymsgbuf[128]; | |
1559 | + char *yymsg = yymsgbuf; | |
1560 | + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; | |
1561 | +#endif | |
1562 | + | |
1563 | +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) | |
1564 | + | |
1545 | 1565 | /* The number of symbols on the RHS of the reduced rule. |
1546 | 1566 | Keep to zero when no symbol should be popped. */ |
1547 | 1567 | int yylen = 0; |
1548 | 1568 | |
1569 | + yytoken = 0; | |
1570 | + yyss = yyssa; | |
1571 | + yyvs = yyvsa; | |
1572 | + yyls = yylsa; | |
1573 | + yystacksize = YYINITDEPTH; | |
1574 | + | |
1549 | 1575 | YYDPRINTF ((stderr, "Starting parse\n")); |
1550 | 1576 | |
1551 | 1577 | yystate = 0; |
1552 | 1578 | yyerrstatus = 0; |
1553 | 1579 | yynerrs = 0; |
1554 | - yychar = YYEMPTY; /* Cause a token to be read. */ | |
1580 | + yychar = YYEMPTY; /* Cause a token to be read. */ | |
1555 | 1581 | |
1556 | 1582 | /* Initialize stack pointers. |
1557 | 1583 | Waste one element of value and location stack |
1558 | 1584 | so that they stay on the same level as the state stack. |
1559 | 1585 | The wasted elements are never initialized. */ |
1560 | - | |
1561 | 1586 | yyssp = yyss; |
1562 | 1587 | yyvsp = yyvs; |
1563 | 1588 | yylsp = yyls; |
1564 | -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL | |
1589 | + | |
1590 | +#if YYLTYPE_IS_TRIVIAL | |
1565 | 1591 | /* Initialize the default location before parsing starts. */ |
1566 | 1592 | yylloc.first_line = yylloc.last_line = 1; |
1567 | - yylloc.first_column = yylloc.last_column = 0; | |
1593 | + yylloc.first_column = yylloc.last_column = 1; | |
1568 | 1594 | #endif |
1569 | 1595 | |
1570 | 1596 | goto yysetstate; |
... | ... | @@ -1603,6 +1629,7 @@ |
1603 | 1629 | &yyvs1, yysize * sizeof (*yyvsp), |
1604 | 1630 | &yyls1, yysize * sizeof (*yylsp), |
1605 | 1631 | &yystacksize); |
1632 | + | |
1606 | 1633 | yyls = yyls1; |
1607 | 1634 | yyss = yyss1; |
1608 | 1635 | yyvs = yyvs1; |
... | ... | @@ -1624,9 +1651,9 @@ |
1624 | 1651 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
1625 | 1652 | if (! yyptr) |
1626 | 1653 | goto yyexhaustedlab; |
1627 | - YYSTACK_RELOCATE (yyss); | |
1628 | - YYSTACK_RELOCATE (yyvs); | |
1629 | - YYSTACK_RELOCATE (yyls); | |
1654 | + YYSTACK_RELOCATE (yyss_alloc, yyss); | |
1655 | + YYSTACK_RELOCATE (yyvs_alloc, yyvs); | |
1656 | + YYSTACK_RELOCATE (yyls_alloc, yyls); | |
1630 | 1657 | # undef YYSTACK_RELOCATE |
1631 | 1658 | if (yyss1 != yyssa) |
1632 | 1659 | YYSTACK_FREE (yyss1); |
... | ... | @@ -1647,6 +1674,9 @@ |
1647 | 1674 | |
1648 | 1675 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
1649 | 1676 | |
1677 | + if (yystate == YYFINAL) | |
1678 | + YYACCEPT; | |
1679 | + | |
1650 | 1680 | goto yybackup; |
1651 | 1681 | |
1652 | 1682 | /*-----------. |
1653 | 1683 | |
1654 | 1684 | |
1655 | 1685 | |
... | ... | @@ -1655,16 +1685,16 @@ |
1655 | 1685 | yybackup: |
1656 | 1686 | |
1657 | 1687 | /* Do appropriate processing given the current state. Read a |
1658 | - look-ahead token if we need one and don't already have one. */ | |
1688 | + lookahead token if we need one and don't already have one. */ | |
1659 | 1689 | |
1660 | - /* First try to decide what to do without reference to look-ahead token. */ | |
1690 | + /* First try to decide what to do without reference to lookahead token. */ | |
1661 | 1691 | yyn = yypact[yystate]; |
1662 | 1692 | if (yyn == YYPACT_NINF) |
1663 | 1693 | goto yydefault; |
1664 | 1694 | |
1665 | - /* Not known => get a look-ahead token if don't already have one. */ | |
1695 | + /* Not known => get a lookahead token if don't already have one. */ | |
1666 | 1696 | |
1667 | - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ | |
1697 | + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | |
1668 | 1698 | if (yychar == YYEMPTY) |
1669 | 1699 | { |
1670 | 1700 | YYDPRINTF ((stderr, "Reading a token: ")); |
1671 | 1701 | |
1672 | 1702 | |
... | ... | @@ -1696,20 +1726,16 @@ |
1696 | 1726 | goto yyreduce; |
1697 | 1727 | } |
1698 | 1728 | |
1699 | - if (yyn == YYFINAL) | |
1700 | - YYACCEPT; | |
1701 | - | |
1702 | 1729 | /* Count tokens shifted since error; after three, turn off error |
1703 | 1730 | status. */ |
1704 | 1731 | if (yyerrstatus) |
1705 | 1732 | yyerrstatus--; |
1706 | 1733 | |
1707 | - /* Shift the look-ahead token. */ | |
1734 | + /* Shift the lookahead token. */ | |
1708 | 1735 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
1709 | 1736 | |
1710 | - /* Discard the shifted token unless it is eof. */ | |
1711 | - if (yychar != YYEOF) | |
1712 | - yychar = YYEMPTY; | |
1737 | + /* Discard the shifted token. */ | |
1738 | + yychar = YYEMPTY; | |
1713 | 1739 | |
1714 | 1740 | yystate = yyn; |
1715 | 1741 | *++yyvsp = yylval; |
... | ... | @@ -1750,6 +1776,8 @@ |
1750 | 1776 | switch (yyn) |
1751 | 1777 | { |
1752 | 1778 | case 2: |
1779 | + | |
1780 | +/* Line 1455 of yacc.c */ | |
1753 | 1781 | #line 135 "parser.y" |
1754 | 1782 | { |
1755 | 1783 | (yylsp[(1) - (1)]); |
1756 | 1784 | |
1757 | 1785 | |
1758 | 1786 | |
1759 | 1787 | |
1760 | 1788 | |
1761 | 1789 | |
... | ... | @@ -1768,36 +1796,50 @@ |
1768 | 1796 | break; |
1769 | 1797 | |
1770 | 1798 | case 3: |
1799 | + | |
1800 | +/* Line 1455 of yacc.c */ | |
1771 | 1801 | #line 151 "parser.y" |
1772 | 1802 | { ((yyval.declList)=(yyvsp[(1) - (2)].declList))->Append((yyvsp[(2) - (2)].decl)); } |
1773 | 1803 | break; |
1774 | 1804 | |
1775 | 1805 | case 4: |
1806 | + | |
1807 | +/* Line 1455 of yacc.c */ | |
1776 | 1808 | #line 152 "parser.y" |
1777 | 1809 | { ((yyval.declList) = new List<Decl*>)->Append((yyvsp[(1) - (1)].decl)); } |
1778 | 1810 | break; |
1779 | 1811 | |
1780 | 1812 | case 5: |
1813 | + | |
1814 | +/* Line 1455 of yacc.c */ | |
1781 | 1815 | #line 163 "parser.y" |
1782 | 1816 | { (yyval.decl) = (yyvsp[(1) - (1)].decl); } |
1783 | 1817 | break; |
1784 | 1818 | |
1785 | 1819 | case 6: |
1820 | + | |
1821 | +/* Line 1455 of yacc.c */ | |
1786 | 1822 | #line 164 "parser.y" |
1787 | 1823 | { (yyvsp[(1) - (2)].funcDecl)->SetFunctionBody((yyvsp[(2) - (2)].stmt)); (yyval.decl) = (yyvsp[(1) - (2)].funcDecl); } |
1788 | 1824 | break; |
1789 | 1825 | |
1790 | 1826 | case 7: |
1827 | + | |
1828 | +/* Line 1455 of yacc.c */ | |
1791 | 1829 | #line 175 "parser.y" |
1792 | 1830 | { (yyval.decl) = (yyvsp[(1) - (2)].funcDecl); } |
1793 | 1831 | break; |
1794 | 1832 | |
1795 | 1833 | case 8: |
1834 | + | |
1835 | +/* Line 1455 of yacc.c */ | |
1796 | 1836 | #line 176 "parser.y" |
1797 | 1837 | { (yyval.decl) = (yyvsp[(1) - (2)].varDecl); } |
1798 | 1838 | break; |
1799 | 1839 | |
1800 | 1840 | case 9: |
1841 | + | |
1842 | +/* Line 1455 of yacc.c */ | |
1801 | 1843 | #line 180 "parser.y" |
1802 | 1844 | { |
1803 | 1845 | Identifier *id = new Identifier(yylloc, (const char *)(yyvsp[(2) - (4)].identifier)); |
... | ... | @@ -1807,6 +1849,8 @@ |
1807 | 1849 | break; |
1808 | 1850 | |
1809 | 1851 | case 10: |
1852 | + | |
1853 | +/* Line 1455 of yacc.c */ | |
1810 | 1854 | #line 186 "parser.y" |
1811 | 1855 | { |
1812 | 1856 | Identifier *id = new Identifier(yylloc, (const char *)(yyvsp[(2) - (5)].identifier)); |
1813 | 1857 | |
1814 | 1858 | |
... | ... | @@ -1815,16 +1859,22 @@ |
1815 | 1859 | break; |
1816 | 1860 | |
1817 | 1861 | case 11: |
1862 | + | |
1863 | +/* Line 1455 of yacc.c */ | |
1818 | 1864 | #line 192 "parser.y" |
1819 | 1865 | { ((yyval.varDeclList) = new List<VarDecl *>)->Append((yyvsp[(1) - (1)].varDecl)); } |
1820 | 1866 | break; |
1821 | 1867 | |
1822 | 1868 | case 12: |
1869 | + | |
1870 | +/* Line 1455 of yacc.c */ | |
1823 | 1871 | #line 193 "parser.y" |
1824 | 1872 | { ((yyval.varDeclList) = (yyvsp[(1) - (3)].varDeclList))->Append((yyvsp[(3) - (3)].varDecl)); } |
1825 | 1873 | break; |
1826 | 1874 | |
1827 | 1875 | case 13: |
1876 | + | |
1877 | +/* Line 1455 of yacc.c */ | |
1828 | 1878 | #line 197 "parser.y" |
1829 | 1879 | { |
1830 | 1880 | Identifier *id = new Identifier(yylloc, (const char *)(yyvsp[(2) - (2)].identifier)); |
... | ... | @@ -1833,6 +1883,8 @@ |
1833 | 1883 | break; |
1834 | 1884 | |
1835 | 1885 | case 14: |
1886 | + | |
1887 | +/* Line 1455 of yacc.c */ | |
1836 | 1888 | #line 202 "parser.y" |
1837 | 1889 | { |
1838 | 1890 | Identifier *id = new Identifier(yylloc, (const char *)(yyvsp[(3) - (3)].identifier)); |
... | ... | @@ -1841,6 +1893,8 @@ |
1841 | 1893 | break; |
1842 | 1894 | |
1843 | 1895 | case 15: |
1896 | + | |
1897 | +/* Line 1455 of yacc.c */ | |
1844 | 1898 | #line 207 "parser.y" |
1845 | 1899 | { |
1846 | 1900 | // incomplete: drop the initializer here |
... | ... | @@ -1850,6 +1904,8 @@ |
1850 | 1904 | break; |
1851 | 1905 | |
1852 | 1906 | case 16: |
1907 | + | |
1908 | +/* Line 1455 of yacc.c */ | |
1853 | 1909 | #line 213 "parser.y" |
1854 | 1910 | { |
1855 | 1911 | Identifier *id = new Identifier(yylloc, (const char *)(yyvsp[(3) - (5)].identifier)); |
... | ... | @@ -1858,6 +1914,8 @@ |
1858 | 1914 | break; |
1859 | 1915 | |
1860 | 1916 | case 17: |
1917 | + | |
1918 | +/* Line 1455 of yacc.c */ | |
1861 | 1919 | #line 218 "parser.y" |
1862 | 1920 | { |
1863 | 1921 | Identifier *id = new Identifier((yylsp[(2) - (5)]), (const char *)(yyvsp[(2) - (5)].identifier)); |
... | ... | @@ -1866,6 +1924,8 @@ |
1866 | 1924 | break; |
1867 | 1925 | |
1868 | 1926 | case 18: |
1927 | + | |
1928 | +/* Line 1455 of yacc.c */ | |
1869 | 1929 | #line 223 "parser.y" |
1870 | 1930 | { |
1871 | 1931 | Identifier *id = new Identifier((yylsp[(3) - (6)]), (yyvsp[(3) - (6)].identifier)); |
1872 | 1932 | |
1873 | 1933 | |
1874 | 1934 | |
1875 | 1935 | |
1876 | 1936 | |
1877 | 1937 | |
1878 | 1938 | |
1879 | 1939 | |
1880 | 1940 | |
1881 | 1941 | |
1882 | 1942 | |
1883 | 1943 | |
1884 | 1944 | |
1885 | 1945 | |
1886 | 1946 | |
1887 | 1947 | |
1888 | 1948 | |
1889 | 1949 | |
1890 | 1950 | |
1891 | 1951 | |
1892 | 1952 | |
1893 | 1953 | |
... | ... | @@ -1874,116 +1934,162 @@ |
1874 | 1934 | break; |
1875 | 1935 | |
1876 | 1936 | case 19: |
1937 | + | |
1938 | +/* Line 1455 of yacc.c */ | |
1877 | 1939 | #line 230 "parser.y" |
1878 | 1940 | { (yyval.expression) = (yyvsp[(1) - (1)].expression); } |
1879 | 1941 | break; |
1880 | 1942 | |
1881 | 1943 | case 20: |
1944 | + | |
1945 | +/* Line 1455 of yacc.c */ | |
1882 | 1946 | #line 233 "parser.y" |
1883 | 1947 | {(yyval.typeQualifier) = TypeQualifier::inTypeQualifier;} |
1884 | 1948 | break; |
1885 | 1949 | |
1886 | 1950 | case 21: |
1951 | + | |
1952 | +/* Line 1455 of yacc.c */ | |
1887 | 1953 | #line 234 "parser.y" |
1888 | 1954 | {(yyval.typeQualifier) = TypeQualifier::outTypeQualifier;} |
1889 | 1955 | break; |
1890 | 1956 | |
1891 | 1957 | case 22: |
1958 | + | |
1959 | +/* Line 1455 of yacc.c */ | |
1892 | 1960 | #line 235 "parser.y" |
1893 | 1961 | {(yyval.typeQualifier) = TypeQualifier::constTypeQualifier;} |
1894 | 1962 | break; |
1895 | 1963 | |
1896 | 1964 | case 23: |
1965 | + | |
1966 | +/* Line 1455 of yacc.c */ | |
1897 | 1967 | #line 236 "parser.y" |
1898 | 1968 | {(yyval.typeQualifier) = TypeQualifier::uniformTypeQualifier;} |
1899 | 1969 | break; |
1900 | 1970 | |
1901 | 1971 | case 24: |
1972 | + | |
1973 | +/* Line 1455 of yacc.c */ | |
1902 | 1974 | #line 239 "parser.y" |
1903 | 1975 | { (yyval.typeDecl) = Type::intType; } |
1904 | 1976 | break; |
1905 | 1977 | |
1906 | 1978 | case 25: |
1979 | + | |
1980 | +/* Line 1455 of yacc.c */ | |
1907 | 1981 | #line 240 "parser.y" |
1908 | 1982 | { (yyval.typeDecl) = Type::voidType; } |
1909 | 1983 | break; |
1910 | 1984 | |
1911 | 1985 | case 26: |
1986 | + | |
1987 | +/* Line 1455 of yacc.c */ | |
1912 | 1988 | #line 241 "parser.y" |
1913 | 1989 | { (yyval.typeDecl) = Type::floatType; } |
1914 | 1990 | break; |
1915 | 1991 | |
1916 | 1992 | case 27: |
1993 | + | |
1994 | +/* Line 1455 of yacc.c */ | |
1917 | 1995 | #line 242 "parser.y" |
1918 | 1996 | { (yyval.typeDecl) = Type::boolType; } |
1919 | 1997 | break; |
1920 | 1998 | |
1921 | 1999 | case 28: |
2000 | + | |
2001 | +/* Line 1455 of yacc.c */ | |
1922 | 2002 | #line 243 "parser.y" |
1923 | 2003 | { (yyval.typeDecl) = Type::vec2Type; } |
1924 | 2004 | break; |
1925 | 2005 | |
1926 | 2006 | case 29: |
2007 | + | |
2008 | +/* Line 1455 of yacc.c */ | |
1927 | 2009 | #line 244 "parser.y" |
1928 | 2010 | { (yyval.typeDecl) = Type::vec3Type; } |
1929 | 2011 | break; |
1930 | 2012 | |
1931 | 2013 | case 30: |
2014 | + | |
2015 | +/* Line 1455 of yacc.c */ | |
1932 | 2016 | #line 245 "parser.y" |
1933 | 2017 | { (yyval.typeDecl) = Type::vec4Type; } |
1934 | 2018 | break; |
1935 | 2019 | |
1936 | 2020 | case 31: |
2021 | + | |
2022 | +/* Line 1455 of yacc.c */ | |
1937 | 2023 | #line 246 "parser.y" |
1938 | 2024 | { (yyval.typeDecl) = Type::mat2Type; } |
1939 | 2025 | break; |
1940 | 2026 | |
1941 | 2027 | case 32: |
2028 | + | |
2029 | +/* Line 1455 of yacc.c */ | |
1942 | 2030 | #line 247 "parser.y" |
1943 | 2031 | { (yyval.typeDecl) = Type::mat3Type; } |
1944 | 2032 | break; |
1945 | 2033 | |
1946 | 2034 | case 33: |
2035 | + | |
2036 | +/* Line 1455 of yacc.c */ | |
1947 | 2037 | #line 248 "parser.y" |
1948 | 2038 | { (yyval.typeDecl) = Type::mat4Type; } |
1949 | 2039 | break; |
1950 | 2040 | |
1951 | 2041 | case 34: |
2042 | + | |
2043 | +/* Line 1455 of yacc.c */ | |
1952 | 2044 | #line 251 "parser.y" |
1953 | 2045 | { (yyval.stmt) = new StmtBlock(new List<VarDecl*>, new List<Stmt *>); } |
1954 | 2046 | break; |
1955 | 2047 | |
1956 | 2048 | case 35: |
2049 | + | |
2050 | +/* Line 1455 of yacc.c */ | |
1957 | 2051 | #line 252 "parser.y" |
1958 | 2052 | { (yyval.stmt) = new StmtBlock(new List<VarDecl*>, (yyvsp[(2) - (3)].stmtList)); } |
1959 | 2053 | break; |
1960 | 2054 | |
1961 | 2055 | case 36: |
2056 | + | |
2057 | +/* Line 1455 of yacc.c */ | |
1962 | 2058 | #line 255 "parser.y" |
1963 | 2059 | { ((yyval.stmtList) = new List<Stmt*>)->Append((yyvsp[(1) - (1)].stmt)); } |
1964 | 2060 | break; |
1965 | 2061 | |
1966 | 2062 | case 37: |
2063 | + | |
2064 | +/* Line 1455 of yacc.c */ | |
1967 | 2065 | #line 256 "parser.y" |
1968 | 2066 | { ((yyval.stmtList) = (yyvsp[(1) - (2)].stmtList))->Append((yyvsp[(2) - (2)].stmt)); } |
1969 | 2067 | break; |
1970 | 2068 | |
1971 | 2069 | case 38: |
2070 | + | |
2071 | +/* Line 1455 of yacc.c */ | |
1972 | 2072 | #line 259 "parser.y" |
1973 | 2073 | { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); } |
1974 | 2074 | break; |
1975 | 2075 | |
1976 | 2076 | case 39: |
2077 | + | |
2078 | +/* Line 1455 of yacc.c */ | |
1977 | 2079 | #line 260 "parser.y" |
1978 | 2080 | { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); } |
1979 | 2081 | break; |
1980 | 2082 | |
1981 | 2083 | case 40: |
2084 | + | |
2085 | +/* Line 1455 of yacc.c */ | |
1982 | 2086 | #line 263 "parser.y" |
1983 | 2087 | { (yyval.stmt) = new EmptyExpr(); } |
1984 | 2088 | break; |
1985 | 2089 | |
1986 | 2090 | case 41: |
2091 | + | |
2092 | +/* Line 1455 of yacc.c */ | |
1987 | 2093 | #line 265 "parser.y" |
1988 | 2094 | { |
1989 | 2095 | (yyval.stmt) = new DeclStmt((yyvsp[(1) - (2)].varDecl)); |
1990 | 2096 | |
1991 | 2097 | |
1992 | 2098 | |
1993 | 2099 | |
1994 | 2100 | |
1995 | 2101 | |
1996 | 2102 | |
... | ... | @@ -1991,41 +2097,57 @@ |
1991 | 2097 | break; |
1992 | 2098 | |
1993 | 2099 | case 42: |
2100 | + | |
2101 | +/* Line 1455 of yacc.c */ | |
1994 | 2102 | #line 268 "parser.y" |
1995 | 2103 | { (yyval.stmt) = (yyvsp[(1) - (2)].expression); } |
1996 | 2104 | break; |
1997 | 2105 | |
1998 | 2106 | case 43: |
2107 | + | |
2108 | +/* Line 1455 of yacc.c */ | |
1999 | 2109 | #line 269 "parser.y" |
2000 | 2110 | { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); } |
2001 | 2111 | break; |
2002 | 2112 | |
2003 | 2113 | case 44: |
2114 | + | |
2115 | +/* Line 1455 of yacc.c */ | |
2004 | 2116 | #line 270 "parser.y" |
2005 | 2117 | { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); } |
2006 | 2118 | break; |
2007 | 2119 | |
2008 | 2120 | case 45: |
2121 | + | |
2122 | +/* Line 1455 of yacc.c */ | |
2009 | 2123 | #line 271 "parser.y" |
2010 | 2124 | { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); } |
2011 | 2125 | break; |
2012 | 2126 | |
2013 | 2127 | case 46: |
2128 | + | |
2129 | +/* Line 1455 of yacc.c */ | |
2014 | 2130 | #line 272 "parser.y" |
2015 | 2131 | { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); } |
2016 | 2132 | break; |
2017 | 2133 | |
2018 | 2134 | case 47: |
2135 | + | |
2136 | +/* Line 1455 of yacc.c */ | |
2019 | 2137 | #line 273 "parser.y" |
2020 | 2138 | { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); } |
2021 | 2139 | break; |
2022 | 2140 | |
2023 | 2141 | case 48: |
2142 | + | |
2143 | +/* Line 1455 of yacc.c */ | |
2024 | 2144 | #line 274 "parser.y" |
2025 | 2145 | { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); } |
2026 | 2146 | break; |
2027 | 2147 | |
2028 | 2148 | case 49: |
2149 | + | |
2150 | +/* Line 1455 of yacc.c */ | |
2029 | 2151 | #line 278 "parser.y" |
2030 | 2152 | { |
2031 | 2153 | (yyval.stmt) = new IfStmt((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].stmt), (yyvsp[(7) - (7)].stmt)); |
... | ... | @@ -2033,6 +2155,8 @@ |
2033 | 2155 | break; |
2034 | 2156 | |
2035 | 2157 | case 50: |
2158 | + | |
2159 | +/* Line 1455 of yacc.c */ | |
2036 | 2160 | #line 282 "parser.y" |
2037 | 2161 | { |
2038 | 2162 | (yyval.stmt) = new IfStmt((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].stmt), NULL); |
... | ... | @@ -2040,6 +2164,8 @@ |
2040 | 2164 | break; |
2041 | 2165 | |
2042 | 2166 | case 51: |
2167 | + | |
2168 | +/* Line 1455 of yacc.c */ | |
2043 | 2169 | #line 288 "parser.y" |
2044 | 2170 | { |
2045 | 2171 | (yyval.stmt) = new SwitchStmt((yyvsp[(3) - (7)].expression), (yyvsp[(6) - (7)].stmtList), NULL); |
2046 | 2172 | |
2047 | 2173 | |
2048 | 2174 | |
2049 | 2175 | |
2050 | 2176 | |
2051 | 2177 | |
2052 | 2178 | |
... | ... | @@ -2047,41 +2173,57 @@ |
2047 | 2173 | break; |
2048 | 2174 | |
2049 | 2175 | case 52: |
2176 | + | |
2177 | +/* Line 1455 of yacc.c */ | |
2050 | 2178 | #line 292 "parser.y" |
2051 | 2179 | { (yyval.stmt) = new Case((yyvsp[(2) - (4)].expression), (yyvsp[(4) - (4)].stmt)); } |
2052 | 2180 | break; |
2053 | 2181 | |
2054 | 2182 | case 53: |
2183 | + | |
2184 | +/* Line 1455 of yacc.c */ | |
2055 | 2185 | #line 293 "parser.y" |
2056 | 2186 | { (yyval.stmt) = new Default((yyvsp[(3) - (3)].stmt)); } |
2057 | 2187 | break; |
2058 | 2188 | |
2059 | 2189 | case 54: |
2190 | + | |
2191 | +/* Line 1455 of yacc.c */ | |
2060 | 2192 | #line 296 "parser.y" |
2061 | 2193 | { (yyval.stmt) = new BreakStmt(yylloc); } |
2062 | 2194 | break; |
2063 | 2195 | |
2064 | 2196 | case 55: |
2197 | + | |
2198 | +/* Line 1455 of yacc.c */ | |
2065 | 2199 | #line 297 "parser.y" |
2066 | 2200 | { (yyval.stmt) = new ContinueStmt(yylloc); } |
2067 | 2201 | break; |
2068 | 2202 | |
2069 | 2203 | case 56: |
2204 | + | |
2205 | +/* Line 1455 of yacc.c */ | |
2070 | 2206 | #line 298 "parser.y" |
2071 | 2207 | { (yyval.stmt) = new ReturnStmt(yylloc); } |
2072 | 2208 | break; |
2073 | 2209 | |
2074 | 2210 | case 57: |
2211 | + | |
2212 | +/* Line 1455 of yacc.c */ | |
2075 | 2213 | #line 299 "parser.y" |
2076 | 2214 | { (yyval.stmt) = new ReturnStmt(yyloc, (yyvsp[(2) - (3)].expression)); } |
2077 | 2215 | break; |
2078 | 2216 | |
2079 | 2217 | case 58: |
2218 | + | |
2219 | +/* Line 1455 of yacc.c */ | |
2080 | 2220 | #line 302 "parser.y" |
2081 | 2221 | { (yyval.stmt) = new WhileStmt((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].stmt)); } |
2082 | 2222 | break; |
2083 | 2223 | |
2084 | 2224 | case 59: |
2225 | + | |
2226 | +/* Line 1455 of yacc.c */ | |
2085 | 2227 | #line 306 "parser.y" |
2086 | 2228 | { |
2087 | 2229 | (yyval.stmt) = new ForStmt((yyvsp[(3) - (9)].expression), (yyvsp[(5) - (9)].expression), (yyvsp[(7) - (9)].expression), (yyvsp[(9) - (9)].stmt)); |
... | ... | @@ -2089,6 +2231,8 @@ |
2089 | 2231 | break; |
2090 | 2232 | |
2091 | 2233 | case 60: |
2234 | + | |
2235 | +/* Line 1455 of yacc.c */ | |
2092 | 2236 | #line 311 "parser.y" |
2093 | 2237 | { Identifier *id = new Identifier(yylloc, (const char*)(yyvsp[(1) - (1)].identifier)); |
2094 | 2238 | (yyval.expression) = new VarExpr(yyloc, id); |
2095 | 2239 | |
2096 | 2240 | |
2097 | 2241 | |
2098 | 2242 | |
2099 | 2243 | |
2100 | 2244 | |
2101 | 2245 | |
2102 | 2246 | |
2103 | 2247 | |
2104 | 2248 | |
2105 | 2249 | |
2106 | 2250 | |
2107 | 2251 | |
2108 | 2252 | |
2109 | 2253 | |
... | ... | @@ -2096,82 +2240,114 @@ |
2096 | 2240 | break; |
2097 | 2241 | |
2098 | 2242 | case 61: |
2243 | + | |
2244 | +/* Line 1455 of yacc.c */ | |
2099 | 2245 | #line 314 "parser.y" |
2100 | 2246 | { (yyval.expression) = new IntConstant(yylloc, (yyvsp[(1) - (1)].integerConstant)); } |
2101 | 2247 | break; |
2102 | 2248 | |
2103 | 2249 | case 62: |
2250 | + | |
2251 | +/* Line 1455 of yacc.c */ | |
2104 | 2252 | #line 315 "parser.y" |
2105 | 2253 | { (yyval.expression) = new FloatConstant(yylloc, (yyvsp[(1) - (1)].floatConstant)); } |
2106 | 2254 | break; |
2107 | 2255 | |
2108 | 2256 | case 63: |
2257 | + | |
2258 | +/* Line 1455 of yacc.c */ | |
2109 | 2259 | #line 316 "parser.y" |
2110 | 2260 | { (yyval.expression) = new BoolConstant(yylloc, (yyvsp[(1) - (1)].boolConstant)); } |
2111 | 2261 | break; |
2112 | 2262 | |
2113 | 2263 | case 64: |
2264 | + | |
2265 | +/* Line 1455 of yacc.c */ | |
2114 | 2266 | #line 317 "parser.y" |
2115 | 2267 | { (yyval.expression) = (yyvsp[(2) - (3)].expression);} |
2116 | 2268 | break; |
2117 | 2269 | |
2118 | 2270 | case 65: |
2271 | + | |
2272 | +/* Line 1455 of yacc.c */ | |
2119 | 2273 | #line 320 "parser.y" |
2120 | 2274 | { (yyval.expression) = (yyvsp[(1) - (2)].expression); } |
2121 | 2275 | break; |
2122 | 2276 | |
2123 | 2277 | case 66: |
2278 | + | |
2279 | +/* Line 1455 of yacc.c */ | |
2124 | 2280 | #line 321 "parser.y" |
2125 | 2281 | { (yyval.expression) = (yyvsp[(1) - (2)].expression); } |
2126 | 2282 | break; |
2127 | 2283 | |
2128 | 2284 | case 67: |
2285 | + | |
2286 | +/* Line 1455 of yacc.c */ | |
2129 | 2287 | #line 324 "parser.y" |
2130 | 2288 | { (yyval.expression) = new Call((yylsp[(1) - (3)]), NULL, (yyvsp[(1) - (3)].funcId), new List<Expr*>); } |
2131 | 2289 | break; |
2132 | 2290 | |
2133 | 2291 | case 68: |
2292 | + | |
2293 | +/* Line 1455 of yacc.c */ | |
2134 | 2294 | #line 325 "parser.y" |
2135 | 2295 | { (yyval.expression) = new Call((yylsp[(1) - (2)]), NULL, (yyvsp[(1) - (2)].funcId), new List<Expr*>); } |
2136 | 2296 | break; |
2137 | 2297 | |
2138 | 2298 | case 69: |
2299 | + | |
2300 | +/* Line 1455 of yacc.c */ | |
2139 | 2301 | #line 328 "parser.y" |
2140 | 2302 | { (yyval.expression) = new Call((yylsp[(1) - (3)]), NULL, (yyvsp[(1) - (3)].funcId), (yyvsp[(3) - (3)].argList));} |
2141 | 2303 | break; |
2142 | 2304 | |
2143 | 2305 | case 70: |
2306 | + | |
2307 | +/* Line 1455 of yacc.c */ | |
2144 | 2308 | #line 331 "parser.y" |
2145 | 2309 | { ((yyval.argList) = new List<Expr*>)->Append((yyvsp[(1) - (1)].expression));} |
2146 | 2310 | break; |
2147 | 2311 | |
2148 | 2312 | case 71: |
2313 | + | |
2314 | +/* Line 1455 of yacc.c */ | |
2149 | 2315 | #line 332 "parser.y" |
2150 | 2316 | { ((yyval.argList) = (yyvsp[(1) - (3)].argList))->Append((yyvsp[(3) - (3)].expression));} |
2151 | 2317 | break; |
2152 | 2318 | |
2153 | 2319 | case 72: |
2320 | + | |
2321 | +/* Line 1455 of yacc.c */ | |
2154 | 2322 | #line 335 "parser.y" |
2155 | 2323 | { (yyval.funcId) = new Identifier((yylsp[(1) - (1)]), (yyvsp[(1) - (1)].identifier)); } |
2156 | 2324 | break; |
2157 | 2325 | |
2158 | 2326 | case 73: |
2327 | + | |
2328 | +/* Line 1455 of yacc.c */ | |
2159 | 2329 | #line 338 "parser.y" |
2160 | 2330 | { (yyval.expression) = (yyvsp[(1) - (1)].expression); } |
2161 | 2331 | break; |
2162 | 2332 | |
2163 | 2333 | case 74: |
2334 | + | |
2335 | +/* Line 1455 of yacc.c */ | |
2164 | 2336 | #line 339 "parser.y" |
2165 | 2337 | { (yyval.expression) = new ArrayAccess((yylsp[(1) - (4)]), (yyvsp[(1) - (4)].expression), (yyvsp[(3) - (4)].expression)); } |
2166 | 2338 | break; |
2167 | 2339 | |
2168 | 2340 | case 75: |
2341 | + | |
2342 | +/* Line 1455 of yacc.c */ | |
2169 | 2343 | #line 341 "parser.y" |
2170 | 2344 | { |
2171 | 2345 | } |
2172 | 2346 | break; |
2173 | 2347 | |
2174 | 2348 | case 76: |
2349 | + | |
2350 | +/* Line 1455 of yacc.c */ | |
2175 | 2351 | #line 344 "parser.y" |
2176 | 2352 | { |
2177 | 2353 | Operator *op = new Operator(yylloc, (const char *)(yyvsp[(2) - (2)].identifier)); |
... | ... | @@ -2180,6 +2356,8 @@ |
2180 | 2356 | break; |
2181 | 2357 | |
2182 | 2358 | case 77: |
2359 | + | |
2360 | +/* Line 1455 of yacc.c */ | |
2183 | 2361 | #line 349 "parser.y" |
2184 | 2362 | { |
2185 | 2363 | Operator *op = new Operator(yylloc, (const char *)(yyvsp[(2) - (2)].identifier)); |
... | ... | @@ -2188,6 +2366,8 @@ |
2188 | 2366 | break; |
2189 | 2367 | |
2190 | 2368 | case 78: |
2369 | + | |
2370 | +/* Line 1455 of yacc.c */ | |
2191 | 2371 | #line 354 "parser.y" |
2192 | 2372 | { |
2193 | 2373 | Identifier *id = new Identifier(yylloc, (const char *)(yyvsp[(3) - (3)].identifier)); |
2194 | 2374 | |
... | ... | @@ -2196,11 +2376,15 @@ |
2196 | 2376 | break; |
2197 | 2377 | |
2198 | 2378 | case 79: |
2379 | + | |
2380 | +/* Line 1455 of yacc.c */ | |
2199 | 2381 | #line 360 "parser.y" |
2200 | 2382 | { (yyval.expression) = (yyvsp[(1) - (1)].expression); } |
2201 | 2383 | break; |
2202 | 2384 | |
2203 | 2385 | case 80: |
2386 | + | |
2387 | +/* Line 1455 of yacc.c */ | |
2204 | 2388 | #line 362 "parser.y" |
2205 | 2389 | { |
2206 | 2390 | Operator *op = new Operator(yylloc, (yyvsp[(1) - (2)].identifier)); |
... | ... | @@ -2209,6 +2393,8 @@ |
2209 | 2393 | break; |
2210 | 2394 | |
2211 | 2395 | case 81: |
2396 | + | |
2397 | +/* Line 1455 of yacc.c */ | |
2212 | 2398 | #line 367 "parser.y" |
2213 | 2399 | { |
2214 | 2400 | Operator *op = new Operator(yylloc, (yyvsp[(1) - (2)].identifier)); |
... | ... | @@ -2217,6 +2403,8 @@ |
2217 | 2403 | break; |
2218 | 2404 | |
2219 | 2405 | case 82: |
2406 | + | |
2407 | +/* Line 1455 of yacc.c */ | |
2220 | 2408 | #line 372 "parser.y" |
2221 | 2409 | { |
2222 | 2410 | Operator *op = new Operator(yylloc, (yyvsp[(1) - (2)].identifier)); |
... | ... | @@ -2225,6 +2413,8 @@ |
2225 | 2413 | break; |
2226 | 2414 | |
2227 | 2415 | case 83: |
2416 | + | |
2417 | +/* Line 1455 of yacc.c */ | |
2228 | 2418 | #line 377 "parser.y" |
2229 | 2419 | { |
2230 | 2420 | Operator *op = new Operator(yylloc, (yyvsp[(1) - (2)].identifier)); |
2231 | 2421 | |
... | ... | @@ -2233,11 +2423,15 @@ |
2233 | 2423 | break; |
2234 | 2424 | |
2235 | 2425 | case 84: |
2426 | + | |
2427 | +/* Line 1455 of yacc.c */ | |
2236 | 2428 | #line 383 "parser.y" |
2237 | 2429 | { (yyval.expression) = (yyvsp[(1) - (1)].expression); } |
2238 | 2430 | break; |
2239 | 2431 | |
2240 | 2432 | case 85: |
2433 | + | |
2434 | +/* Line 1455 of yacc.c */ | |
2241 | 2435 | #line 385 "parser.y" |
2242 | 2436 | { |
2243 | 2437 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
... | ... | @@ -2246,6 +2440,8 @@ |
2246 | 2440 | break; |
2247 | 2441 | |
2248 | 2442 | case 86: |
2443 | + | |
2444 | +/* Line 1455 of yacc.c */ | |
2249 | 2445 | #line 390 "parser.y" |
2250 | 2446 | { |
2251 | 2447 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
2252 | 2448 | |
... | ... | @@ -2254,11 +2450,15 @@ |
2254 | 2450 | break; |
2255 | 2451 | |
2256 | 2452 | case 87: |
2453 | + | |
2454 | +/* Line 1455 of yacc.c */ | |
2257 | 2455 | #line 396 "parser.y" |
2258 | 2456 | { (yyval.expression) = (yyvsp[(1) - (1)].expression); } |
2259 | 2457 | break; |
2260 | 2458 | |
2261 | 2459 | case 88: |
2460 | + | |
2461 | +/* Line 1455 of yacc.c */ | |
2262 | 2462 | #line 398 "parser.y" |
2263 | 2463 | { |
2264 | 2464 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
... | ... | @@ -2267,6 +2467,8 @@ |
2267 | 2467 | break; |
2268 | 2468 | |
2269 | 2469 | case 89: |
2470 | + | |
2471 | +/* Line 1455 of yacc.c */ | |
2270 | 2472 | #line 403 "parser.y" |
2271 | 2473 | { |
2272 | 2474 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
2273 | 2475 | |
... | ... | @@ -2275,11 +2477,15 @@ |
2275 | 2477 | break; |
2276 | 2478 | |
2277 | 2479 | case 90: |
2480 | + | |
2481 | +/* Line 1455 of yacc.c */ | |
2278 | 2482 | #line 409 "parser.y" |
2279 | 2483 | { (yyval.expression) = (yyvsp[(1) - (1)].expression); } |
2280 | 2484 | break; |
2281 | 2485 | |
2282 | 2486 | case 91: |
2487 | + | |
2488 | +/* Line 1455 of yacc.c */ | |
2283 | 2489 | #line 411 "parser.y" |
2284 | 2490 | { |
2285 | 2491 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
... | ... | @@ -2288,6 +2494,8 @@ |
2288 | 2494 | break; |
2289 | 2495 | |
2290 | 2496 | case 92: |
2497 | + | |
2498 | +/* Line 1455 of yacc.c */ | |
2291 | 2499 | #line 416 "parser.y" |
2292 | 2500 | { |
2293 | 2501 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
... | ... | @@ -2296,6 +2504,8 @@ |
2296 | 2504 | break; |
2297 | 2505 | |
2298 | 2506 | case 93: |
2507 | + | |
2508 | +/* Line 1455 of yacc.c */ | |
2299 | 2509 | #line 421 "parser.y" |
2300 | 2510 | { |
2301 | 2511 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
... | ... | @@ -2304,6 +2514,8 @@ |
2304 | 2514 | break; |
2305 | 2515 | |
2306 | 2516 | case 94: |
2517 | + | |
2518 | +/* Line 1455 of yacc.c */ | |
2307 | 2519 | #line 426 "parser.y" |
2308 | 2520 | { |
2309 | 2521 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
2310 | 2522 | |
2311 | 2523 | |
2312 | 2524 | |
2313 | 2525 | |
2314 | 2526 | |
2315 | 2527 | |
2316 | 2528 | |
2317 | 2529 | |
2318 | 2530 | |
2319 | 2531 | |
2320 | 2532 | |
2321 | 2533 | |
... | ... | @@ -2312,58 +2524,76 @@ |
2312 | 2524 | break; |
2313 | 2525 | |
2314 | 2526 | case 95: |
2527 | + | |
2528 | +/* Line 1455 of yacc.c */ | |
2315 | 2529 | #line 432 "parser.y" |
2316 | 2530 | { (yyval.expression) = (yyvsp[(1) - (1)].expression); } |
2317 | 2531 | break; |
2318 | 2532 | |
2319 | 2533 | case 96: |
2534 | + | |
2535 | +/* Line 1455 of yacc.c */ | |
2320 | 2536 | #line 434 "parser.y" |
2321 | 2537 | { |
2322 | 2538 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
2323 | - (yyval.expression) = new ArithmeticExpr((yyvsp[(1) - (3)].expression), op, (yyvsp[(3) - (3)].expression)); | |
2539 | + (yyval.expression) = new EqualityExpr((yyvsp[(1) - (3)].expression), op, (yyvsp[(3) - (3)].expression)); | |
2324 | 2540 | } |
2325 | 2541 | break; |
2326 | 2542 | |
2327 | 2543 | case 97: |
2544 | + | |
2545 | +/* Line 1455 of yacc.c */ | |
2328 | 2546 | #line 439 "parser.y" |
2329 | 2547 | { |
2330 | 2548 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
2331 | - (yyval.expression) = new ArithmeticExpr((yyvsp[(1) - (3)].expression), op, (yyvsp[(3) - (3)].expression)); | |
2549 | + (yyval.expression) = new EqualityExpr((yyvsp[(1) - (3)].expression), op, (yyvsp[(3) - (3)].expression)); | |
2332 | 2550 | } |
2333 | 2551 | break; |
2334 | 2552 | |
2335 | 2553 | case 98: |
2554 | + | |
2555 | +/* Line 1455 of yacc.c */ | |
2336 | 2556 | #line 445 "parser.y" |
2337 | 2557 | { (yyval.expression) = (yyvsp[(1) - (1)].expression); } |
2338 | 2558 | break; |
2339 | 2559 | |
2340 | 2560 | case 99: |
2561 | + | |
2562 | +/* Line 1455 of yacc.c */ | |
2341 | 2563 | #line 447 "parser.y" |
2342 | 2564 | { |
2343 | 2565 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
2344 | - (yyval.expression) = new ArithmeticExpr((yyvsp[(1) - (3)].expression), op, (yyvsp[(3) - (3)].expression)); | |
2566 | + (yyval.expression) = new LogicalExpr((yyvsp[(1) - (3)].expression), op, (yyvsp[(3) - (3)].expression)); | |
2345 | 2567 | } |
2346 | 2568 | break; |
2347 | 2569 | |
2348 | 2570 | case 100: |
2571 | + | |
2572 | +/* Line 1455 of yacc.c */ | |
2349 | 2573 | #line 453 "parser.y" |
2350 | 2574 | { (yyval.expression) = (yyvsp[(1) - (1)].expression); } |
2351 | 2575 | break; |
2352 | 2576 | |
2353 | 2577 | case 101: |
2578 | + | |
2579 | +/* Line 1455 of yacc.c */ | |
2354 | 2580 | #line 455 "parser.y" |
2355 | 2581 | { |
2356 | 2582 | Operator *op = new Operator(yylloc, (yyvsp[(2) - (3)].identifier)); |
2357 | - (yyval.expression) = new ArithmeticExpr((yyvsp[(1) - (3)].expression), op, (yyvsp[(3) - (3)].expression)); | |
2583 | + (yyval.expression) = new LogicalExpr((yyvsp[(1) - (3)].expression), op, (yyvsp[(3) - (3)].expression)); | |
2358 | 2584 | } |
2359 | 2585 | break; |
2360 | 2586 | |
2361 | 2587 | case 102: |
2588 | + | |
2589 | +/* Line 1455 of yacc.c */ | |
2362 | 2590 | #line 461 "parser.y" |
2363 | 2591 | { (yyval.expression) = (yyvsp[(1) - (1)].expression); } |
2364 | 2592 | break; |
2365 | 2593 | |
2366 | 2594 | case 103: |
2595 | + | |
2596 | +/* Line 1455 of yacc.c */ | |
2367 | 2597 | #line 463 "parser.y" |
2368 | 2598 | { |
2369 | 2599 | (yyval.expression) = new ConditionalExpr((yyvsp[(1) - (5)].expression), (yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].expression)); |
... | ... | @@ -2371,6 +2601,8 @@ |
2371 | 2601 | break; |
2372 | 2602 | |
2373 | 2603 | case 104: |
2604 | + | |
2605 | +/* Line 1455 of yacc.c */ | |
2374 | 2606 | #line 467 "parser.y" |
2375 | 2607 | { |
2376 | 2608 | (yyval.expression) = new AssignExpr((yyvsp[(1) - (3)].expression), (yyvsp[(2) - (3)].ops), (yyvsp[(3) - (3)].expression)); |
2377 | 2609 | |
2378 | 2610 | |
2379 | 2611 | |
2380 | 2612 | |
2381 | 2613 | |
... | ... | @@ -2378,33 +2610,44 @@ |
2378 | 2610 | break; |
2379 | 2611 | |
2380 | 2612 | case 105: |
2613 | + | |
2614 | +/* Line 1455 of yacc.c */ | |
2381 | 2615 | #line 472 "parser.y" |
2382 | 2616 | { (yyval.ops) = new Operator(yylloc, (yyvsp[(1) - (1)].identifier)); } |
2383 | 2617 | break; |
2384 | 2618 | |
2385 | 2619 | case 106: |
2620 | + | |
2621 | +/* Line 1455 of yacc.c */ | |
2386 | 2622 | #line 473 "parser.y" |
2387 | 2623 | { (yyval.ops) = new Operator(yylloc, "+="); } |
2388 | 2624 | break; |
2389 | 2625 | |
2390 | 2626 | case 107: |
2627 | + | |
2628 | +/* Line 1455 of yacc.c */ | |
2391 | 2629 | #line 474 "parser.y" |
2392 | 2630 | { (yyval.ops) = new Operator(yylloc, "-="); } |
2393 | 2631 | break; |
2394 | 2632 | |
2395 | 2633 | case 108: |
2634 | + | |
2635 | +/* Line 1455 of yacc.c */ | |
2396 | 2636 | #line 475 "parser.y" |
2397 | 2637 | { (yyval.ops) = new Operator(yylloc, "*="); } |
2398 | 2638 | break; |
2399 | 2639 | |
2400 | 2640 | case 109: |
2641 | + | |
2642 | +/* Line 1455 of yacc.c */ | |
2401 | 2643 | #line 476 "parser.y" |
2402 | 2644 | { (yyval.ops) = new Operator(yylloc, "/="); } |
2403 | 2645 | break; |
2404 | 2646 | |
2405 | 2647 | |
2406 | -/* Line 1267 of yacc.c. */ | |
2407 | -#line 2408 "y.tab.c" | |
2648 | + | |
2649 | +/* Line 1455 of yacc.c */ | |
2650 | +#line 2651 "y.tab.c" | |
2408 | 2651 | default: break; |
2409 | 2652 | } |
2410 | 2653 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); |
... | ... | @@ -2480,7 +2723,7 @@ |
2480 | 2723 | |
2481 | 2724 | if (yyerrstatus == 3) |
2482 | 2725 | { |
2483 | - /* If just tried and failed to reuse look-ahead token after an | |
2726 | + /* If just tried and failed to reuse lookahead token after an | |
2484 | 2727 | error, discard it. */ |
2485 | 2728 | |
2486 | 2729 | if (yychar <= YYEOF) |
... | ... | @@ -2497,7 +2740,7 @@ |
2497 | 2740 | } |
2498 | 2741 | } |
2499 | 2742 | |
2500 | - /* Else will try to reuse look-ahead token after shifting the error | |
2743 | + /* Else will try to reuse lookahead token after shifting the error | |
2501 | 2744 | token. */ |
2502 | 2745 | goto yyerrlab1; |
2503 | 2746 | |
2504 | 2747 | |
... | ... | @@ -2555,14 +2798,11 @@ |
2555 | 2798 | YY_STACK_PRINT (yyss, yyssp); |
2556 | 2799 | } |
2557 | 2800 | |
2558 | - if (yyn == YYFINAL) | |
2559 | - YYACCEPT; | |
2560 | - | |
2561 | 2801 | *++yyvsp = yylval; |
2562 | 2802 | |
2563 | 2803 | yyerror_range[1] = yylloc; |
2564 | 2804 | /* Using YYLLOC is tempting, but would change the location of |
2565 | - the look-ahead. YYLOC is available though. */ | |
2805 | + the lookahead. YYLOC is available though. */ | |
2566 | 2806 | YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); |
2567 | 2807 | *++yylsp = yyloc; |
2568 | 2808 | |
... | ... | @@ -2587,7 +2827,7 @@ |
2587 | 2827 | yyresult = 1; |
2588 | 2828 | goto yyreturn; |
2589 | 2829 | |
2590 | -#ifndef yyoverflow | |
2830 | +#if !defined(yyoverflow) || YYERROR_VERBOSE | |
2591 | 2831 | /*-------------------------------------------------. |
2592 | 2832 | | yyexhaustedlab -- memory exhaustion comes here. | |
2593 | 2833 | `-------------------------------------------------*/ |
... | ... | @@ -2598,7 +2838,7 @@ |
2598 | 2838 | #endif |
2599 | 2839 | |
2600 | 2840 | yyreturn: |
2601 | - if (yychar != YYEOF && yychar != YYEMPTY) | |
2841 | + if (yychar != YYEMPTY) | |
2602 | 2842 | yydestruct ("Cleanup: discarding lookahead", |
2603 | 2843 | yytoken, &yylval, &yylloc); |
2604 | 2844 | /* Do not reclaim the symbols of the rule which action triggered |
... | ... | @@ -2624,6 +2864,8 @@ |
2624 | 2864 | } |
2625 | 2865 | |
2626 | 2866 | |
2867 | + | |
2868 | +/* Line 1675 of yacc.c */ | |
2627 | 2869 | #line 479 "parser.y" |
2628 | 2870 | |
2629 | 2871 |
y.tab.h
View file @
c189b2a
1 | -/* A Bison parser, made by GNU Bison 2.3. */ | |
2 | 1 | |
3 | -/* Skeleton interface for Bison's Yacc-like parsers in C | |
2 | +/* A Bison parser, made by GNU Bison 2.4.1. */ | |
4 | 3 | |
5 | - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 | |
4 | +/* Skeleton interface for Bison's Yacc-like parsers in C | |
5 | + | |
6 | + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 | |
6 | 7 | Free Software Foundation, Inc. |
7 | - | |
8 | - This program is free software; you can redistribute it and/or modify | |
8 | + | |
9 | + This program is free software: you can redistribute it and/or modify | |
9 | 10 | it under the terms of the GNU General Public License as published by |
10 | - the Free Software Foundation; either version 2, or (at your option) | |
11 | - any later version. | |
12 | - | |
11 | + the Free Software Foundation, either version 3 of the License, or | |
12 | + (at your option) any later version. | |
13 | + | |
13 | 14 | This program is distributed in the hope that it will be useful, |
14 | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | 17 | GNU General Public License for more details. |
17 | - | |
18 | + | |
18 | 19 | You should have received a copy of the GNU General Public License |
19 | - along with this program; if not, write to the Free Software | |
20 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
21 | - Boston, MA 02110-1301, USA. */ | |
20 | + along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
22 | 21 | |
23 | 22 | /* As a special exception, you may create a larger work that contains |
24 | 23 | part or all of the Bison parser skeleton and distribute that work |
25 | 24 | |
... | ... | @@ -29,10 +28,11 @@ |
29 | 28 | special exception, which will cause the skeleton and the resulting |
30 | 29 | Bison output files to be licensed under the GNU General Public |
31 | 30 | License without this special exception. |
32 | - | |
31 | + | |
33 | 32 | This special exception was added by the Free Software Foundation in |
34 | 33 | version 2.2 of Bison. */ |
35 | 34 | |
35 | + | |
36 | 36 | /* Tokens. */ |
37 | 37 | #ifndef YYTOKENTYPE |
38 | 38 | # define YYTOKENTYPE |
39 | 39 | |
... | ... | @@ -192,8 +192,11 @@ |
192 | 192 | |
193 | 193 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
194 | 194 | typedef union YYSTYPE |
195 | -#line 41 "parser.y" | |
196 | 195 | { |
196 | + | |
197 | +/* Line 1676 of yacc.c */ | |
198 | +#line 41 "parser.y" | |
199 | + | |
197 | 200 | int integerConstant; |
198 | 201 | bool boolConstant; |
199 | 202 | double floatConstant; |
200 | 203 | |
... | ... | @@ -211,13 +214,15 @@ |
211 | 214 | Operator *ops; |
212 | 215 | Identifier *funcId; |
213 | 216 | List<Expr*> *argList; |
214 | -} | |
215 | -/* Line 1529 of yacc.c. */ | |
216 | -#line 217 "y.tab.h" | |
217 | - YYSTYPE; | |
217 | + | |
218 | + | |
219 | + | |
220 | +/* Line 1676 of yacc.c */ | |
221 | +#line 222 "y.tab.h" | |
222 | +} YYSTYPE; | |
223 | +# define YYSTYPE_IS_TRIVIAL 1 | |
218 | 224 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
219 | 225 | # define YYSTYPE_IS_DECLARED 1 |
220 | -# define YYSTYPE_IS_TRIVIAL 1 | |
221 | 226 | #endif |
222 | 227 | |
223 | 228 | extern YYSTYPE yylval; |