|
|
@@ -1,8 +1,8 @@ |
|
|
|
/* A Bison parser, made by GNU Bison 2.5. */ |
|
|
|
/* A Bison parser, made by GNU Bison 2.4.2. */ |
|
|
|
|
|
|
|
/* Skeleton implementation for Bison LALR(1) parsers in C++ |
|
|
|
|
|
|
|
Copyright (C) 2002-2011 Free Software Foundation, Inc. |
|
|
|
Copyright (C) 2002-2010 Free Software Foundation, Inc. |
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify |
|
|
|
it under the terms of the GNU General Public License as published by |
|
|
@@ -35,13 +35,13 @@ |
|
|
|
|
|
|
|
/* First part of user declarations. */ |
|
|
|
|
|
|
|
/* Line 293 of lalr1.cc */ |
|
|
|
/* Line 310 of lalr1.cc */ |
|
|
|
#line 1 "gpu/lolfx-parser.y" |
|
|
|
|
|
|
|
// |
|
|
|
// Lol Engine |
|
|
|
// |
|
|
|
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> |
|
|
|
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> |
|
|
|
// This program is free software; you can redistribute it and/or |
|
|
|
// modify it under the terms of the Do What The Fuck You Want To |
|
|
|
// Public License, Version 2, as published by Sam Hocevar. See |
|
|
@@ -58,7 +58,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Line 293 of lalr1.cc */ |
|
|
|
/* Line 310 of lalr1.cc */ |
|
|
|
#line 63 "generated/lolfx-parser.cpp" |
|
|
|
|
|
|
|
|
|
|
@@ -66,7 +66,7 @@ |
|
|
|
|
|
|
|
/* User implementation prologue. */ |
|
|
|
|
|
|
|
/* Line 299 of lalr1.cc */ |
|
|
|
/* Line 316 of lalr1.cc */ |
|
|
|
#line 241 "gpu/lolfx-parser.y" |
|
|
|
|
|
|
|
#include "gpu/lolfx-compiler.h" |
|
|
@@ -75,7 +75,7 @@ |
|
|
|
#define yylex mc.m_lexer->lex |
|
|
|
|
|
|
|
|
|
|
|
/* Line 299 of lalr1.cc */ |
|
|
|
/* Line 316 of lalr1.cc */ |
|
|
|
#line 80 "generated/lolfx-parser.cpp" |
|
|
|
|
|
|
|
#ifndef YY_ |
|
|
@@ -90,26 +90,6 @@ |
|
|
|
# endif |
|
|
|
#endif |
|
|
|
|
|
|
|
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
|
|
|
If N is 0, then set CURRENT to the empty location which ends |
|
|
|
the previous symbol: RHS[0] (always defined). */ |
|
|
|
|
|
|
|
#define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
|
|
|
#ifndef YYLLOC_DEFAULT |
|
|
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \ |
|
|
|
do \ |
|
|
|
if (N) \ |
|
|
|
{ \ |
|
|
|
(Current).begin = YYRHSLOC (Rhs, 1).begin; \ |
|
|
|
(Current).end = YYRHSLOC (Rhs, N).end; \ |
|
|
|
} \ |
|
|
|
else \ |
|
|
|
{ \ |
|
|
|
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ |
|
|
|
} \ |
|
|
|
while (false) |
|
|
|
#endif |
|
|
|
|
|
|
|
/* Suppress unused-variable warnings by "using" E. */ |
|
|
|
#define YYUSE(e) ((void) (e)) |
|
|
|
|
|
|
@@ -161,8 +141,9 @@ do { \ |
|
|
|
|
|
|
|
namespace lol { |
|
|
|
|
|
|
|
/* Line 382 of lalr1.cc */ |
|
|
|
#line 166 "generated/lolfx-parser.cpp" |
|
|
|
/* Line 379 of lalr1.cc */ |
|
|
|
#line 146 "generated/lolfx-parser.cpp" |
|
|
|
#if YYERROR_VERBOSE |
|
|
|
|
|
|
|
/* Return YYSTR after stripping away unnecessary quotes and |
|
|
|
backslashes, so that it's suitable for yyerror. The heuristic is |
|
|
@@ -201,6 +182,7 @@ namespace lol { |
|
|
|
return yystr; |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
/// Build a parser object. |
|
|
|
LolFxParser::LolFxParser (class LolFxCompiler& mc_yyarg) |
|
|
@@ -301,18 +283,6 @@ namespace lol { |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
inline bool |
|
|
|
LolFxParser::yy_pact_value_is_default_ (int yyvalue) |
|
|
|
{ |
|
|
|
return yyvalue == yypact_ninf_; |
|
|
|
} |
|
|
|
|
|
|
|
inline bool |
|
|
|
LolFxParser::yy_table_value_is_error_ (int yyvalue) |
|
|
|
{ |
|
|
|
return yyvalue == yytable_ninf_; |
|
|
|
} |
|
|
|
|
|
|
|
int |
|
|
|
LolFxParser::parse () |
|
|
|
{ |
|
|
@@ -334,7 +304,7 @@ namespace lol { |
|
|
|
/// Location of the lookahead. |
|
|
|
location_type yylloc; |
|
|
|
/// The locations where the error started and ended. |
|
|
|
location_type yyerror_range[3]; |
|
|
|
location_type yyerror_range[2]; |
|
|
|
|
|
|
|
/// $$. |
|
|
|
semantic_type yyval; |
|
|
@@ -372,7 +342,7 @@ namespace lol { |
|
|
|
|
|
|
|
/* Try to take a decision without lookahead. */ |
|
|
|
yyn = yypact_[yystate]; |
|
|
|
if (yy_pact_value_is_default_ (yyn)) |
|
|
|
if (yyn == yypact_ninf_) |
|
|
|
goto yydefault; |
|
|
|
|
|
|
|
/* Read a lookahead token. */ |
|
|
@@ -405,8 +375,8 @@ namespace lol { |
|
|
|
yyn = yytable_[yyn]; |
|
|
|
if (yyn <= 0) |
|
|
|
{ |
|
|
|
if (yy_table_value_is_error_ (yyn)) |
|
|
|
goto yyerrlab; |
|
|
|
if (yyn == 0 || yyn == yytable_ninf_) |
|
|
|
goto yyerrlab; |
|
|
|
yyn = -yyn; |
|
|
|
goto yyreduce; |
|
|
|
} |
|
|
@@ -462,57 +432,46 @@ namespace lol { |
|
|
|
{ |
|
|
|
case 202: |
|
|
|
|
|
|
|
/* Line 690 of lalr1.cc */ |
|
|
|
/* Line 677 of lalr1.cc */ |
|
|
|
#line 728 "gpu/lolfx-parser.y" |
|
|
|
{ std::cout << "New tech " << std::endl; } |
|
|
|
break; |
|
|
|
|
|
|
|
case 203: |
|
|
|
|
|
|
|
/* Line 690 of lalr1.cc */ |
|
|
|
/* Line 677 of lalr1.cc */ |
|
|
|
#line 736 "gpu/lolfx-parser.y" |
|
|
|
{ std::cout << "New name " << (yysemantic_stack_[(1) - (1)].sval) << std::endl; } |
|
|
|
break; |
|
|
|
|
|
|
|
case 204: |
|
|
|
|
|
|
|
/* Line 690 of lalr1.cc */ |
|
|
|
/* Line 677 of lalr1.cc */ |
|
|
|
#line 737 "gpu/lolfx-parser.y" |
|
|
|
{ std::cout << "New name " << (yysemantic_stack_[(1) - (1)].sval) << std::endl; } |
|
|
|
break; |
|
|
|
|
|
|
|
case 207: |
|
|
|
|
|
|
|
/* Line 690 of lalr1.cc */ |
|
|
|
/* Line 677 of lalr1.cc */ |
|
|
|
#line 750 "gpu/lolfx-parser.y" |
|
|
|
{ std::cout << "New pass " << std::endl; } |
|
|
|
break; |
|
|
|
|
|
|
|
case 226: |
|
|
|
|
|
|
|
/* Line 690 of lalr1.cc */ |
|
|
|
/* Line 677 of lalr1.cc */ |
|
|
|
#line 786 "gpu/lolfx-parser.y" |
|
|
|
{ std::cout << "new shader" << std::endl; } |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Line 690 of lalr1.cc */ |
|
|
|
#line 502 "generated/lolfx-parser.cpp" |
|
|
|
/* Line 677 of lalr1.cc */ |
|
|
|
#line 472 "generated/lolfx-parser.cpp" |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
/* User semantic actions sometimes alter yychar, and that requires |
|
|
|
that yytoken be updated with the new translation. We take the |
|
|
|
approach of translating immediately before every use of yytoken. |
|
|
|
One alternative is translating here after every semantic action, |
|
|
|
but that translation would be missed if the semantic action |
|
|
|
invokes YYABORT, YYACCEPT, or YYERROR immediately after altering |
|
|
|
yychar. In the case of YYABORT or YYACCEPT, an incorrect |
|
|
|
destructor might then be invoked immediately. In the case of |
|
|
|
YYERROR, subsequent parser actions might lead to an incorrect |
|
|
|
destructor call or verbose syntax error message before the |
|
|
|
lookahead is translated. */ |
|
|
|
YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); |
|
|
|
|
|
|
|
yypop_ (yylen); |
|
|
@@ -536,20 +495,14 @@ namespace lol { |
|
|
|
| yyerrlab -- here on detecting error | |
|
|
|
`------------------------------------*/ |
|
|
|
yyerrlab: |
|
|
|
/* Make sure we have latest lookahead translation. See comments at |
|
|
|
user semantic actions for why this is necessary. */ |
|
|
|
yytoken = yytranslate_ (yychar); |
|
|
|
|
|
|
|
/* If not already recovering from an error, report this error. */ |
|
|
|
if (!yyerrstatus_) |
|
|
|
{ |
|
|
|
++yynerrs_; |
|
|
|
if (yychar == yyempty_) |
|
|
|
yytoken = yyempty_; |
|
|
|
error (yylloc, yysyntax_error_ (yystate, yytoken)); |
|
|
|
} |
|
|
|
|
|
|
|
yyerror_range[1] = yylloc; |
|
|
|
yyerror_range[0] = yylloc; |
|
|
|
if (yyerrstatus_ == 3) |
|
|
|
{ |
|
|
|
/* If just tried and failed to reuse lookahead token after an |
|
|
@@ -584,7 +537,7 @@ namespace lol { |
|
|
|
if (false) |
|
|
|
goto yyerrorlab; |
|
|
|
|
|
|
|
yyerror_range[1] = yylocation_stack_[yylen - 1]; |
|
|
|
yyerror_range[0] = yylocation_stack_[yylen - 1]; |
|
|
|
/* Do not reclaim the symbols of the rule which action triggered |
|
|
|
this YYERROR. */ |
|
|
|
yypop_ (yylen); |
|
|
@@ -601,7 +554,7 @@ namespace lol { |
|
|
|
for (;;) |
|
|
|
{ |
|
|
|
yyn = yypact_[yystate]; |
|
|
|
if (!yy_pact_value_is_default_ (yyn)) |
|
|
|
if (yyn != yypact_ninf_) |
|
|
|
{ |
|
|
|
yyn += yyterror_; |
|
|
|
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) |
|
|
@@ -616,7 +569,7 @@ namespace lol { |
|
|
|
if (yystate_stack_.height () == 1) |
|
|
|
YYABORT; |
|
|
|
|
|
|
|
yyerror_range[1] = yylocation_stack_[0]; |
|
|
|
yyerror_range[0] = yylocation_stack_[0]; |
|
|
|
yydestruct_ ("Error: popping", |
|
|
|
yystos_[yystate], |
|
|
|
&yysemantic_stack_[0], &yylocation_stack_[0]); |
|
|
@@ -625,10 +578,10 @@ namespace lol { |
|
|
|
YY_STACK_PRINT (); |
|
|
|
} |
|
|
|
|
|
|
|
yyerror_range[2] = yylloc; |
|
|
|
yyerror_range[1] = yylloc; |
|
|
|
// Using YYLLOC is tempting, but would change the location of |
|
|
|
// the lookahead. YYLOC is available though. |
|
|
|
YYLLOC_DEFAULT (yyloc, yyerror_range, 2); |
|
|
|
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); |
|
|
|
yysemantic_stack_.push (yylval); |
|
|
|
yylocation_stack_.push (yyloc); |
|
|
|
|
|
|
@@ -651,13 +604,7 @@ namespace lol { |
|
|
|
|
|
|
|
yyreturn: |
|
|
|
if (yychar != yyempty_) |
|
|
|
{ |
|
|
|
/* Make sure we have latest lookahead translation. See comments |
|
|
|
at user semantic actions for why this is necessary. */ |
|
|
|
yytoken = yytranslate_ (yychar); |
|
|
|
yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, |
|
|
|
&yylloc); |
|
|
|
} |
|
|
|
yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); |
|
|
|
|
|
|
|
/* Do not reclaim the symbols of the rule which action triggered |
|
|
|
this YYABORT or YYACCEPT. */ |
|
|
@@ -676,97 +623,51 @@ namespace lol { |
|
|
|
|
|
|
|
// Generate an error message. |
|
|
|
std::string |
|
|
|
LolFxParser::yysyntax_error_ (int yystate, int yytoken) |
|
|
|
LolFxParser::yysyntax_error_ (int yystate, int tok) |
|
|
|
{ |
|
|
|
std::string yyres; |
|
|
|
// Number of reported tokens (one for the "unexpected", one per |
|
|
|
// "expected"). |
|
|
|
size_t yycount = 0; |
|
|
|
// Its maximum. |
|
|
|
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; |
|
|
|
// Arguments of yyformat. |
|
|
|
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
|
|
|
|
|
|
|
/* There are many possibilities here to consider: |
|
|
|
- If this state is a consistent state with a default action, then |
|
|
|
the only way this function was invoked is if the default action |
|
|
|
is an error action. In that case, don't check for expected |
|
|
|
tokens because there are none. |
|
|
|
- The only way there can be no lookahead present (in yytoken) is |
|
|
|
if this state is a consistent state with a default action. |
|
|
|
Thus, detecting the absence of a lookahead is sufficient to |
|
|
|
determine that there is no unexpected or expected token to |
|
|
|
report. In that case, just report a simple "syntax error". |
|
|
|
- Don't assume there isn't a lookahead just because this state is |
|
|
|
a consistent state with a default action. There might have |
|
|
|
been a previous inconsistent state, consistent state with a |
|
|
|
non-default action, or user semantic action that manipulated |
|
|
|
yychar. |
|
|
|
- Of course, the expected token list depends on states to have |
|
|
|
correct lookahead information, and it depends on the parser not |
|
|
|
to perform extra reductions after fetching a lookahead from the |
|
|
|
scanner and before detecting a syntax error. Thus, state |
|
|
|
merging (from LALR or IELR) and default reductions corrupt the |
|
|
|
expected token list. However, the list is correct for |
|
|
|
canonical LR with one exception: it will still contain any |
|
|
|
token that will not be accepted due to an error action in a |
|
|
|
later state. |
|
|
|
*/ |
|
|
|
if (yytoken != yyempty_) |
|
|
|
{ |
|
|
|
yyarg[yycount++] = yytname_[yytoken]; |
|
|
|
int yyn = yypact_[yystate]; |
|
|
|
if (!yy_pact_value_is_default_ (yyn)) |
|
|
|
{ |
|
|
|
/* Start YYX at -YYN if negative to avoid negative indexes in |
|
|
|
YYCHECK. In other words, skip the first -YYN actions for |
|
|
|
this state because they are default actions. */ |
|
|
|
int yyxbegin = yyn < 0 ? -yyn : 0; |
|
|
|
/* Stay within bounds of both yycheck and yytname. */ |
|
|
|
int yychecklim = yylast_ - yyn + 1; |
|
|
|
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; |
|
|
|
for (int yyx = yyxbegin; yyx < yyxend; ++yyx) |
|
|
|
if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ |
|
|
|
&& !yy_table_value_is_error_ (yytable_[yyx + yyn])) |
|
|
|
{ |
|
|
|
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
|
|
|
{ |
|
|
|
yycount = 1; |
|
|
|
break; |
|
|
|
} |
|
|
|
else |
|
|
|
yyarg[yycount++] = yytname_[yyx]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
char const* yyformat = 0; |
|
|
|
switch (yycount) |
|
|
|
std::string res; |
|
|
|
YYUSE (yystate); |
|
|
|
#if YYERROR_VERBOSE |
|
|
|
int yyn = yypact_[yystate]; |
|
|
|
if (yypact_ninf_ < yyn && yyn <= yylast_) |
|
|
|
{ |
|
|
|
#define YYCASE_(N, S) \ |
|
|
|
case N: \ |
|
|
|
yyformat = S; \ |
|
|
|
break |
|
|
|
YYCASE_(0, YY_("syntax error")); |
|
|
|
YYCASE_(1, YY_("syntax error, unexpected %s")); |
|
|
|
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); |
|
|
|
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); |
|
|
|
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); |
|
|
|
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); |
|
|
|
#undef YYCASE_ |
|
|
|
/* Start YYX at -YYN if negative to avoid negative indexes in |
|
|
|
YYCHECK. */ |
|
|
|
int yyxbegin = yyn < 0 ? -yyn : 0; |
|
|
|
|
|
|
|
/* Stay within bounds of both yycheck and yytname. */ |
|
|
|
int yychecklim = yylast_ - yyn + 1; |
|
|
|
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; |
|
|
|
int count = 0; |
|
|
|
for (int x = yyxbegin; x < yyxend; ++x) |
|
|
|
if (yycheck_[x + yyn] == x && x != yyterror_) |
|
|
|
++count; |
|
|
|
|
|
|
|
// FIXME: This method of building the message is not compatible |
|
|
|
// with internationalization. It should work like yacc.c does it. |
|
|
|
// That is, first build a string that looks like this: |
|
|
|
// "syntax error, unexpected %s or %s or %s" |
|
|
|
// Then, invoke YY_ on this string. |
|
|
|
// Finally, use the string as a format to output |
|
|
|
// yytname_[tok], etc. |
|
|
|
// Until this gets fixed, this message appears in English only. |
|
|
|
res = "syntax error, unexpected "; |
|
|
|
res += yytnamerr_ (yytname_[tok]); |
|
|
|
if (count < 5) |
|
|
|
{ |
|
|
|
count = 0; |
|
|
|
for (int x = yyxbegin; x < yyxend; ++x) |
|
|
|
if (yycheck_[x + yyn] == x && x != yyterror_) |
|
|
|
{ |
|
|
|
res += (!count++) ? ", expecting " : " or "; |
|
|
|
res += yytnamerr_ (yytname_[x]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Argument number. |
|
|
|
size_t yyi = 0; |
|
|
|
for (char const* yyp = yyformat; *yyp; ++yyp) |
|
|
|
if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) |
|
|
|
{ |
|
|
|
yyres += yytnamerr_ (yyarg[yyi++]); |
|
|
|
++yyp; |
|
|
|
} |
|
|
|
else |
|
|
|
yyres += *yyp; |
|
|
|
return yyres; |
|
|
|
else |
|
|
|
#endif |
|
|
|
res = YY_("syntax error"); |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -845,9 +746,9 @@ namespace lol { |
|
|
|
-68, -559, -559, -559, -559 |
|
|
|
}; |
|
|
|
|
|
|
|
/* YYDEFACT[S] -- default reduction number in state S. Performed when |
|
|
|
YYTABLE doesn't specify something else to do. Zero means the |
|
|
|
default is an error. */ |
|
|
|
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE |
|
|
|
doesn't specify something else to do. Zero means the default is an |
|
|
|
error. */ |
|
|
|
const unsigned short int |
|
|
|
LolFxParser::yydefact_[] = |
|
|
|
{ |
|
|
@@ -954,7 +855,7 @@ namespace lol { |
|
|
|
|
|
|
|
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
|
|
|
positive, shift that token. If negative, reduce the rule which |
|
|
|
number is the opposite. If YYTABLE_NINF_, syntax error. */ |
|
|
|
number is the opposite. If zero, do what YYDEFACT says. */ |
|
|
|
const short int LolFxParser::yytable_ninf_ = -323; |
|
|
|
const short int |
|
|
|
LolFxParser::yytable_[] = |
|
|
@@ -3890,11 +3791,11 @@ namespace lol { |
|
|
|
|
|
|
|
} // lol |
|
|
|
|
|
|
|
/* Line 1136 of lalr1.cc */ |
|
|
|
#line 3895 "generated/lolfx-parser.cpp" |
|
|
|
/* Line 1053 of lalr1.cc */ |
|
|
|
#line 3796 "generated/lolfx-parser.cpp" |
|
|
|
|
|
|
|
|
|
|
|
/* Line 1138 of lalr1.cc */ |
|
|
|
/* Line 1055 of lalr1.cc */ |
|
|
|
#line 1298 "gpu/lolfx-parser.y" |
|
|
|
|
|
|
|
|
|
|
|