| 1 |
216 |
diegovalve |
|
| 2 |
|
|
/* A Bison parser, made by GNU Bison 2.4.1. */
|
| 3 |
|
|
|
| 4 |
|
|
/* Skeleton implementation for Bison LALR(1) parsers in C++
|
| 5 |
|
|
|
| 6 |
|
|
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
|
| 7 |
|
|
Foundation, Inc.
|
| 8 |
|
|
|
| 9 |
|
|
This program is free software: you can redistribute it and/or modify
|
| 10 |
|
|
it under the terms of the GNU General Public License as published by
|
| 11 |
|
|
the Free Software Foundation, either version 3 of the License, or
|
| 12 |
|
|
(at your option) any later version.
|
| 13 |
|
|
|
| 14 |
|
|
This program is distributed in the hope that it will be useful,
|
| 15 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 |
|
|
GNU General Public License for more details.
|
| 18 |
|
|
|
| 19 |
|
|
You should have received a copy of the GNU General Public License
|
| 20 |
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
| 21 |
|
|
|
| 22 |
|
|
/* As a special exception, you may create a larger work that contains
|
| 23 |
|
|
part or all of the Bison parser skeleton and distribute that work
|
| 24 |
|
|
under terms of your choice, so long as that work isn't itself a
|
| 25 |
|
|
parser generator using the skeleton or a modified version thereof
|
| 26 |
|
|
as a parser skeleton. Alternatively, if you modify or redistribute
|
| 27 |
|
|
the parser skeleton itself, you may (at your option) remove this
|
| 28 |
|
|
special exception, which will cause the skeleton and the resulting
|
| 29 |
|
|
Bison output files to be licensed under the GNU General Public
|
| 30 |
|
|
License without this special exception.
|
| 31 |
|
|
|
| 32 |
|
|
This special exception was added by the Free Software Foundation in
|
| 33 |
|
|
version 2.2 of Bison. */
|
| 34 |
|
|
|
| 35 |
|
|
|
| 36 |
|
|
/* First part of user declarations. */
|
| 37 |
|
|
|
| 38 |
|
|
|
| 39 |
|
|
/* Line 311 of lalr1.cc */
|
| 40 |
|
|
#line 41 "parser.tab.c"
|
| 41 |
|
|
|
| 42 |
|
|
|
| 43 |
|
|
#include "parser.tab.h"
|
| 44 |
|
|
|
| 45 |
|
|
/* User implementation prologue. */
|
| 46 |
|
|
|
| 47 |
|
|
|
| 48 |
|
|
/* Line 317 of lalr1.cc */
|
| 49 |
|
|
#line 50 "parser.tab.c"
|
| 50 |
|
|
/* Unqualified %code blocks. */
|
| 51 |
|
|
|
| 52 |
|
|
/* Line 318 of lalr1.cc */
|
| 53 |
|
|
#line 68 "parser.y"
|
| 54 |
|
|
|
| 55 |
|
|
#include "Instruction.h"
|
| 56 |
|
|
#include <vector>
|
| 57 |
|
|
CControlInstruction I;
|
| 58 |
|
|
std::vector< unsigned int > gBranchStack;
|
| 59 |
|
|
static int gInsertedInstructions = 0;
|
| 60 |
|
|
static int gWhileLoopAddress = 0;
|
| 61 |
|
|
#define FUNCTION_PARAM_START_REGION 4
|
| 62 |
|
|
#define FUNCTION_PARAM_LAST_REGION 7
|
| 63 |
|
|
std::map<std::string, unsigned int> gVaribleMap;
|
| 64 |
|
|
|
| 65 |
|
|
#define AUTOVAR_START_REGION 9
|
| 66 |
|
|
#define TEMP_VAR_START_OFFSET 128
|
| 67 |
|
|
unsigned int gAutoVarIndex = AUTOVAR_START_REGION;
|
| 68 |
|
|
|
| 69 |
|
|
unsigned int gFunctionParameterIndex = FUNCTION_PARAM_START_REGION;
|
| 70 |
|
|
//----------------------------------------------------------
|
| 71 |
|
|
int GetCurrentLineNumber( const Theia::Parser::location_type &loc )
|
| 72 |
|
|
{
|
| 73 |
|
|
int ret = -1;
|
| 74 |
|
|
std::stringstream ss2;
|
| 75 |
|
|
std::string where;
|
| 76 |
|
|
ss2 << loc;
|
| 77 |
|
|
ss2 >> where;
|
| 78 |
|
|
where.erase(where.find_first_of("."));
|
| 79 |
|
|
std::stringstream ss3;
|
| 80 |
|
|
ss3 << where;
|
| 81 |
|
|
ss3 >> ret;
|
| 82 |
|
|
return ret;
|
| 83 |
|
|
}
|
| 84 |
|
|
//----------------------------------------------------------
|
| 85 |
|
|
unsigned int GetAddressFromIdentifier( std::string aIdentifier, Theia::Parser::location_type yylloc )
|
| 86 |
|
|
{
|
| 87 |
|
|
if (aIdentifier.find("R") != std::string::npos)
|
| 88 |
|
|
{
|
| 89 |
|
|
return atoi(aIdentifier.c_str()+1);
|
| 90 |
|
|
}
|
| 91 |
|
|
if (gVaribleMap.find(aIdentifier) == gVaribleMap.end())
|
| 92 |
|
|
{
|
| 93 |
|
|
std::ostringstream ret;
|
| 94 |
|
|
ret << "Undefined variable '" << aIdentifier << "' at line " << yylloc << " \n";
|
| 95 |
|
|
throw ret.str();
|
| 96 |
|
|
}
|
| 97 |
|
|
|
| 98 |
|
|
return gVaribleMap[ aIdentifier ];
|
| 99 |
|
|
|
| 100 |
|
|
}
|
| 101 |
|
|
//----------------------------------------------------------
|
| 102 |
|
|
unsigned int gTempRegisterIndex = TEMP_VAR_START_OFFSET;
|
| 103 |
|
|
//----------------------------------------------------------
|
| 104 |
|
|
unsigned int GetFreeTempRegister( void )
|
| 105 |
|
|
{
|
| 106 |
|
|
|
| 107 |
|
|
return gTempRegisterIndex++;
|
| 108 |
|
|
|
| 109 |
|
|
}
|
| 110 |
|
|
//----------------------------------------------------------
|
| 111 |
|
|
void ResetTempRegisterIndex( void )
|
| 112 |
|
|
{
|
| 113 |
|
|
|
| 114 |
|
|
gTempRegisterIndex = TEMP_VAR_START_OFFSET;
|
| 115 |
|
|
}
|
| 116 |
|
|
//----------------------------------------------------------
|
| 117 |
|
|
unsigned int AllocateVariable( )
|
| 118 |
|
|
{
|
| 119 |
|
|
gAutoVarIndex++;
|
| 120 |
|
|
return gAutoVarIndex;
|
| 121 |
|
|
|
| 122 |
|
|
}
|
| 123 |
|
|
//----------------------------------------------------------
|
| 124 |
|
|
// Prototype for the yylex function
|
| 125 |
|
|
static int yylex(Theia::Parser::semantic_type * yylval,
|
| 126 |
|
|
Theia::Parser::location_type * yylloc,
|
| 127 |
|
|
Theia::Scanner &scanner);
|
| 128 |
|
|
|
| 129 |
|
|
|
| 130 |
|
|
|
| 131 |
|
|
/* Line 318 of lalr1.cc */
|
| 132 |
|
|
#line 133 "parser.tab.c"
|
| 133 |
|
|
|
| 134 |
|
|
#ifndef YY_
|
| 135 |
|
|
# if YYENABLE_NLS
|
| 136 |
|
|
# if ENABLE_NLS
|
| 137 |
|
|
# include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
|
| 138 |
|
|
# define YY_(msgid) dgettext ("bison-runtime", msgid)
|
| 139 |
|
|
# endif
|
| 140 |
|
|
# endif
|
| 141 |
|
|
# ifndef YY_
|
| 142 |
|
|
# define YY_(msgid) msgid
|
| 143 |
|
|
# endif
|
| 144 |
|
|
#endif
|
| 145 |
|
|
|
| 146 |
|
|
/* Suppress unused-variable warnings by "using" E. */
|
| 147 |
|
|
#define YYUSE(e) ((void) (e))
|
| 148 |
|
|
|
| 149 |
|
|
/* Enable debugging if requested. */
|
| 150 |
|
|
#if YYDEBUG
|
| 151 |
|
|
|
| 152 |
|
|
/* A pseudo ostream that takes yydebug_ into account. */
|
| 153 |
|
|
# define YYCDEBUG if (yydebug_) (*yycdebug_)
|
| 154 |
|
|
|
| 155 |
|
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
| 156 |
|
|
do { \
|
| 157 |
|
|
if (yydebug_) \
|
| 158 |
|
|
{ \
|
| 159 |
|
|
*yycdebug_ << Title << ' '; \
|
| 160 |
|
|
yy_symbol_print_ ((Type), (Value), (Location)); \
|
| 161 |
|
|
*yycdebug_ << std::endl; \
|
| 162 |
|
|
} \
|
| 163 |
|
|
} while (false)
|
| 164 |
|
|
|
| 165 |
|
|
# define YY_REDUCE_PRINT(Rule) \
|
| 166 |
|
|
do { \
|
| 167 |
|
|
if (yydebug_) \
|
| 168 |
|
|
yy_reduce_print_ (Rule); \
|
| 169 |
|
|
} while (false)
|
| 170 |
|
|
|
| 171 |
|
|
# define YY_STACK_PRINT() \
|
| 172 |
|
|
do { \
|
| 173 |
|
|
if (yydebug_) \
|
| 174 |
|
|
yystack_print_ (); \
|
| 175 |
|
|
} while (false)
|
| 176 |
|
|
|
| 177 |
|
|
#else /* !YYDEBUG */
|
| 178 |
|
|
|
| 179 |
|
|
# define YYCDEBUG if (false) std::cerr
|
| 180 |
|
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
| 181 |
|
|
# define YY_REDUCE_PRINT(Rule)
|
| 182 |
|
|
# define YY_STACK_PRINT()
|
| 183 |
|
|
|
| 184 |
|
|
#endif /* !YYDEBUG */
|
| 185 |
|
|
|
| 186 |
|
|
#define yyerrok (yyerrstatus_ = 0)
|
| 187 |
|
|
#define yyclearin (yychar = yyempty_)
|
| 188 |
|
|
|
| 189 |
|
|
#define YYACCEPT goto yyacceptlab
|
| 190 |
|
|
#define YYABORT goto yyabortlab
|
| 191 |
|
|
#define YYERROR goto yyerrorlab
|
| 192 |
|
|
#define YYRECOVERING() (!!yyerrstatus_)
|
| 193 |
|
|
|
| 194 |
|
|
|
| 195 |
|
|
/* Line 380 of lalr1.cc */
|
| 196 |
|
|
#line 28 "parser.y"
|
| 197 |
|
|
namespace Theia {
|
| 198 |
|
|
|
| 199 |
|
|
/* Line 380 of lalr1.cc */
|
| 200 |
|
|
#line 201 "parser.tab.c"
|
| 201 |
|
|
#if YYERROR_VERBOSE
|
| 202 |
|
|
|
| 203 |
|
|
/* Return YYSTR after stripping away unnecessary quotes and
|
| 204 |
|
|
backslashes, so that it's suitable for yyerror. The heuristic is
|
| 205 |
|
|
that double-quoting is unnecessary unless the string contains an
|
| 206 |
|
|
apostrophe, a comma, or backslash (other than backslash-backslash).
|
| 207 |
|
|
YYSTR is taken from yytname. */
|
| 208 |
|
|
std::string
|
| 209 |
|
|
Parser::yytnamerr_ (const char *yystr)
|
| 210 |
|
|
{
|
| 211 |
|
|
if (*yystr == '"')
|
| 212 |
|
|
{
|
| 213 |
|
|
std::string yyr = "";
|
| 214 |
|
|
char const *yyp = yystr;
|
| 215 |
|
|
|
| 216 |
|
|
for (;;)
|
| 217 |
|
|
switch (*++yyp)
|
| 218 |
|
|
{
|
| 219 |
|
|
case '\'':
|
| 220 |
|
|
case ',':
|
| 221 |
|
|
goto do_not_strip_quotes;
|
| 222 |
|
|
|
| 223 |
|
|
case '\\':
|
| 224 |
|
|
if (*++yyp != '\\')
|
| 225 |
|
|
goto do_not_strip_quotes;
|
| 226 |
|
|
/* Fall through. */
|
| 227 |
|
|
default:
|
| 228 |
|
|
yyr += *yyp;
|
| 229 |
|
|
break;
|
| 230 |
|
|
|
| 231 |
|
|
case '"':
|
| 232 |
|
|
return yyr;
|
| 233 |
|
|
}
|
| 234 |
|
|
do_not_strip_quotes: ;
|
| 235 |
|
|
}
|
| 236 |
|
|
|
| 237 |
|
|
return yystr;
|
| 238 |
|
|
}
|
| 239 |
|
|
|
| 240 |
|
|
#endif
|
| 241 |
|
|
|
| 242 |
|
|
/// Build a parser object.
|
| 243 |
|
|
Parser::Parser (Theia::Scanner &scanner_yyarg, std::map<std::string,unsigned int> & mSymbolMap_yyarg, std::vector< CControlInstruction > &mInstructions_yyarg, bool &mGenerateFixedPointArithmetic_yyarg)
|
| 244 |
|
|
:
|
| 245 |
|
|
#if YYDEBUG
|
| 246 |
|
|
yydebug_ (false),
|
| 247 |
|
|
yycdebug_ (&std::cerr),
|
| 248 |
|
|
#endif
|
| 249 |
|
|
scanner (scanner_yyarg),
|
| 250 |
|
|
mSymbolMap (mSymbolMap_yyarg),
|
| 251 |
|
|
mInstructions (mInstructions_yyarg),
|
| 252 |
|
|
mGenerateFixedPointArithmetic (mGenerateFixedPointArithmetic_yyarg)
|
| 253 |
|
|
{
|
| 254 |
|
|
}
|
| 255 |
|
|
|
| 256 |
|
|
Parser::~Parser ()
|
| 257 |
|
|
{
|
| 258 |
|
|
}
|
| 259 |
|
|
|
| 260 |
|
|
#if YYDEBUG
|
| 261 |
|
|
/*--------------------------------.
|
| 262 |
|
|
| Print this symbol on YYOUTPUT. |
|
| 263 |
|
|
`--------------------------------*/
|
| 264 |
|
|
|
| 265 |
|
|
inline void
|
| 266 |
|
|
Parser::yy_symbol_value_print_ (int yytype,
|
| 267 |
|
|
const semantic_type* yyvaluep, const location_type* yylocationp)
|
| 268 |
|
|
{
|
| 269 |
|
|
YYUSE (yylocationp);
|
| 270 |
|
|
YYUSE (yyvaluep);
|
| 271 |
|
|
switch (yytype)
|
| 272 |
|
|
{
|
| 273 |
|
|
default:
|
| 274 |
|
|
break;
|
| 275 |
|
|
}
|
| 276 |
|
|
}
|
| 277 |
|
|
|
| 278 |
|
|
|
| 279 |
|
|
void
|
| 280 |
|
|
Parser::yy_symbol_print_ (int yytype,
|
| 281 |
|
|
const semantic_type* yyvaluep, const location_type* yylocationp)
|
| 282 |
|
|
{
|
| 283 |
|
|
*yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
|
| 284 |
|
|
<< ' ' << yytname_[yytype] << " ("
|
| 285 |
|
|
<< *yylocationp << ": ";
|
| 286 |
|
|
yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
|
| 287 |
|
|
*yycdebug_ << ')';
|
| 288 |
|
|
}
|
| 289 |
|
|
#endif
|
| 290 |
|
|
|
| 291 |
|
|
void
|
| 292 |
|
|
Parser::yydestruct_ (const char* yymsg,
|
| 293 |
|
|
int yytype, semantic_type* yyvaluep, location_type* yylocationp)
|
| 294 |
|
|
{
|
| 295 |
|
|
YYUSE (yylocationp);
|
| 296 |
|
|
YYUSE (yymsg);
|
| 297 |
|
|
YYUSE (yyvaluep);
|
| 298 |
|
|
|
| 299 |
|
|
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
| 300 |
|
|
|
| 301 |
|
|
switch (yytype)
|
| 302 |
|
|
{
|
| 303 |
|
|
|
| 304 |
|
|
default:
|
| 305 |
|
|
break;
|
| 306 |
|
|
}
|
| 307 |
|
|
}
|
| 308 |
|
|
|
| 309 |
|
|
void
|
| 310 |
|
|
Parser::yypop_ (unsigned int n)
|
| 311 |
|
|
{
|
| 312 |
|
|
yystate_stack_.pop (n);
|
| 313 |
|
|
yysemantic_stack_.pop (n);
|
| 314 |
|
|
yylocation_stack_.pop (n);
|
| 315 |
|
|
}
|
| 316 |
|
|
|
| 317 |
|
|
#if YYDEBUG
|
| 318 |
|
|
std::ostream&
|
| 319 |
|
|
Parser::debug_stream () const
|
| 320 |
|
|
{
|
| 321 |
|
|
return *yycdebug_;
|
| 322 |
|
|
}
|
| 323 |
|
|
|
| 324 |
|
|
void
|
| 325 |
|
|
Parser::set_debug_stream (std::ostream& o)
|
| 326 |
|
|
{
|
| 327 |
|
|
yycdebug_ = &o;
|
| 328 |
|
|
}
|
| 329 |
|
|
|
| 330 |
|
|
|
| 331 |
|
|
Parser::debug_level_type
|
| 332 |
|
|
Parser::debug_level () const
|
| 333 |
|
|
{
|
| 334 |
|
|
return yydebug_;
|
| 335 |
|
|
}
|
| 336 |
|
|
|
| 337 |
|
|
void
|
| 338 |
|
|
Parser::set_debug_level (debug_level_type l)
|
| 339 |
|
|
{
|
| 340 |
|
|
yydebug_ = l;
|
| 341 |
|
|
}
|
| 342 |
|
|
#endif
|
| 343 |
|
|
|
| 344 |
|
|
int
|
| 345 |
|
|
Parser::parse ()
|
| 346 |
|
|
{
|
| 347 |
|
|
/// Lookahead and lookahead in internal form.
|
| 348 |
|
|
int yychar = yyempty_;
|
| 349 |
|
|
int yytoken = 0;
|
| 350 |
|
|
|
| 351 |
|
|
/* State. */
|
| 352 |
|
|
int yyn;
|
| 353 |
|
|
int yylen = 0;
|
| 354 |
|
|
int yystate = 0;
|
| 355 |
|
|
|
| 356 |
|
|
/* Error handling. */
|
| 357 |
|
|
int yynerrs_ = 0;
|
| 358 |
|
|
int yyerrstatus_ = 0;
|
| 359 |
|
|
|
| 360 |
|
|
/// Semantic value of the lookahead.
|
| 361 |
|
|
semantic_type yylval;
|
| 362 |
|
|
/// Location of the lookahead.
|
| 363 |
|
|
location_type yylloc;
|
| 364 |
|
|
/// The locations where the error started and ended.
|
| 365 |
|
|
location_type yyerror_range[2];
|
| 366 |
|
|
|
| 367 |
|
|
/// $$.
|
| 368 |
|
|
semantic_type yyval;
|
| 369 |
|
|
/// @$.
|
| 370 |
|
|
location_type yyloc;
|
| 371 |
|
|
|
| 372 |
|
|
int yyresult;
|
| 373 |
|
|
|
| 374 |
|
|
YYCDEBUG << "Starting parse" << std::endl;
|
| 375 |
|
|
|
| 376 |
|
|
|
| 377 |
|
|
/* Initialize the stacks. The initial state will be pushed in
|
| 378 |
|
|
yynewstate, since the latter expects the semantical and the
|
| 379 |
|
|
location values to have been already stored, initialize these
|
| 380 |
|
|
stacks with a primary value. */
|
| 381 |
|
|
yystate_stack_ = state_stack_type (0);
|
| 382 |
|
|
yysemantic_stack_ = semantic_stack_type (0);
|
| 383 |
|
|
yylocation_stack_ = location_stack_type (0);
|
| 384 |
|
|
yysemantic_stack_.push (yylval);
|
| 385 |
|
|
yylocation_stack_.push (yylloc);
|
| 386 |
|
|
|
| 387 |
|
|
/* New state. */
|
| 388 |
|
|
yynewstate:
|
| 389 |
|
|
yystate_stack_.push (yystate);
|
| 390 |
|
|
YYCDEBUG << "Entering state " << yystate << std::endl;
|
| 391 |
|
|
|
| 392 |
|
|
/* Accept? */
|
| 393 |
|
|
if (yystate == yyfinal_)
|
| 394 |
|
|
goto yyacceptlab;
|
| 395 |
|
|
|
| 396 |
|
|
goto yybackup;
|
| 397 |
|
|
|
| 398 |
|
|
/* Backup. */
|
| 399 |
|
|
yybackup:
|
| 400 |
|
|
|
| 401 |
|
|
/* Try to take a decision without lookahead. */
|
| 402 |
|
|
yyn = yypact_[yystate];
|
| 403 |
|
|
if (yyn == yypact_ninf_)
|
| 404 |
|
|
goto yydefault;
|
| 405 |
|
|
|
| 406 |
|
|
/* Read a lookahead token. */
|
| 407 |
|
|
if (yychar == yyempty_)
|
| 408 |
|
|
{
|
| 409 |
|
|
YYCDEBUG << "Reading a token: ";
|
| 410 |
|
|
yychar = yylex (&yylval, &yylloc, scanner);
|
| 411 |
|
|
}
|
| 412 |
|
|
|
| 413 |
|
|
|
| 414 |
|
|
/* Convert token to internal form. */
|
| 415 |
|
|
if (yychar <= yyeof_)
|
| 416 |
|
|
{
|
| 417 |
|
|
yychar = yytoken = yyeof_;
|
| 418 |
|
|
YYCDEBUG << "Now at end of input." << std::endl;
|
| 419 |
|
|
}
|
| 420 |
|
|
else
|
| 421 |
|
|
{
|
| 422 |
|
|
yytoken = yytranslate_ (yychar);
|
| 423 |
|
|
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
| 424 |
|
|
}
|
| 425 |
|
|
|
| 426 |
|
|
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
| 427 |
|
|
detect an error, take that action. */
|
| 428 |
|
|
yyn += yytoken;
|
| 429 |
|
|
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
|
| 430 |
|
|
goto yydefault;
|
| 431 |
|
|
|
| 432 |
|
|
/* Reduce or error. */
|
| 433 |
|
|
yyn = yytable_[yyn];
|
| 434 |
|
|
if (yyn <= 0)
|
| 435 |
|
|
{
|
| 436 |
|
|
if (yyn == 0 || yyn == yytable_ninf_)
|
| 437 |
|
|
goto yyerrlab;
|
| 438 |
|
|
yyn = -yyn;
|
| 439 |
|
|
goto yyreduce;
|
| 440 |
|
|
}
|
| 441 |
|
|
|
| 442 |
|
|
/* Shift the lookahead token. */
|
| 443 |
|
|
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
|
| 444 |
|
|
|
| 445 |
|
|
/* Discard the token being shifted. */
|
| 446 |
|
|
yychar = yyempty_;
|
| 447 |
|
|
|
| 448 |
|
|
yysemantic_stack_.push (yylval);
|
| 449 |
|
|
yylocation_stack_.push (yylloc);
|
| 450 |
|
|
|
| 451 |
|
|
/* Count tokens shifted since error; after three, turn off error
|
| 452 |
|
|
status. */
|
| 453 |
|
|
if (yyerrstatus_)
|
| 454 |
|
|
--yyerrstatus_;
|
| 455 |
|
|
|
| 456 |
|
|
yystate = yyn;
|
| 457 |
|
|
goto yynewstate;
|
| 458 |
|
|
|
| 459 |
|
|
/*-----------------------------------------------------------.
|
| 460 |
|
|
| yydefault -- do the default action for the current state. |
|
| 461 |
|
|
`-----------------------------------------------------------*/
|
| 462 |
|
|
yydefault:
|
| 463 |
|
|
yyn = yydefact_[yystate];
|
| 464 |
|
|
if (yyn == 0)
|
| 465 |
|
|
goto yyerrlab;
|
| 466 |
|
|
goto yyreduce;
|
| 467 |
|
|
|
| 468 |
|
|
/*-----------------------------.
|
| 469 |
|
|
| yyreduce -- Do a reduction. |
|
| 470 |
|
|
`-----------------------------*/
|
| 471 |
|
|
yyreduce:
|
| 472 |
|
|
yylen = yyr2_[yyn];
|
| 473 |
|
|
/* If YYLEN is nonzero, implement the default value of the action:
|
| 474 |
|
|
`$$ = $1'. Otherwise, use the top of the stack.
|
| 475 |
|
|
|
| 476 |
|
|
Otherwise, the following line sets YYVAL to garbage.
|
| 477 |
|
|
This behavior is undocumented and Bison
|
| 478 |
|
|
users should not rely upon it. */
|
| 479 |
|
|
if (yylen)
|
| 480 |
|
|
yyval = yysemantic_stack_[yylen - 1];
|
| 481 |
|
|
else
|
| 482 |
|
|
yyval = yysemantic_stack_[0];
|
| 483 |
|
|
|
| 484 |
|
|
{
|
| 485 |
|
|
slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
|
| 486 |
|
|
YYLLOC_DEFAULT (yyloc, slice, yylen);
|
| 487 |
|
|
}
|
| 488 |
|
|
YY_REDUCE_PRINT (yyn);
|
| 489 |
|
|
switch (yyn)
|
| 490 |
|
|
{
|
| 491 |
|
|
case 5:
|
| 492 |
|
|
|
| 493 |
|
|
/* Line 678 of lalr1.cc */
|
| 494 |
|
|
#line 158 "parser.y"
|
| 495 |
|
|
{
|
| 496 |
|
|
|
| 497 |
|
|
unsigned int ImmediateValue;
|
| 498 |
|
|
std::string StringHex = (yysemantic_stack_[(5) - (3)]);
|
| 499 |
|
|
std::stringstream ss;
|
| 500 |
|
|
ss << std::hex << StringHex;
|
| 501 |
|
|
ss >> ImmediateValue;
|
| 502 |
|
|
|
| 503 |
|
|
|
| 504 |
|
|
I.mComment = "Start";
|
| 505 |
|
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
| 506 |
|
|
I.SetOperation(EOPERATION_DELIVERCOMMAND);
|
| 507 |
|
|
I.SetDestinationAddress( ImmediateValue+1 );
|
| 508 |
|
|
I.SetSrc1Address( VP_COMMAND_START_MAIN_THREAD );
|
| 509 |
|
|
mInstructions.push_back(I);
|
| 510 |
|
|
I.Clear();
|
| 511 |
|
|
}
|
| 512 |
|
|
break;
|
| 513 |
|
|
|
| 514 |
|
|
case 7:
|
| 515 |
|
|
|
| 516 |
|
|
/* Line 678 of lalr1.cc */
|
| 517 |
|
|
#line 179 "parser.y"
|
| 518 |
|
|
{
|
| 519 |
|
|
|
| 520 |
|
|
I.SetOperation( EOPERATION_ADD );
|
| 521 |
|
|
I.mComment = "Setting destination ID SPR for Copy data block";
|
| 522 |
|
|
I.SetDestinationAddress( BLOCK_DST_REG );
|
| 523 |
|
|
I.SetSrc1Address( GetAddressFromIdentifier((yysemantic_stack_[(9) - (3)]),yylloc));
|
| 524 |
|
|
I.SetSrc0Address(0);
|
| 525 |
|
|
mInstructions.push_back(I);
|
| 526 |
|
|
I.Clear();
|
| 527 |
|
|
|
| 528 |
|
|
std::cout << "COPY_DATA_BLOCK I(" << GetAddressFromIdentifier((yysemantic_stack_[(9) - (3)]),yylloc) << ") " << GetAddressFromIdentifier((yysemantic_stack_[(9) - (5)]),yylloc) << " " << GetAddressFromIdentifier((yysemantic_stack_[(9) - (7)]),yylloc) << "\n";
|
| 529 |
|
|
I.mComment = "Copy data block";
|
| 530 |
|
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
| 531 |
|
|
I.SetOperation(EOPERATION_COPYBLOCK);
|
| 532 |
|
|
//I.SetCopyDestinationId(ImmediateValue);
|
| 533 |
|
|
I.SetCopyDestinationId(0);
|
| 534 |
|
|
I.SetCopyDestinationAddress(GetAddressFromIdentifier((yysemantic_stack_[(9) - (5)]),yylloc));
|
| 535 |
|
|
I.SetCopySourceAddress(GetAddressFromIdentifier((yysemantic_stack_[(9) - (7)]),yylloc));
|
| 536 |
|
|
I.SetCopySize(GetAddressFromIdentifier((yysemantic_stack_[(9) - (9)]),yylloc));
|
| 537 |
|
|
mInstructions.push_back(I);
|
| 538 |
|
|
I.Clear();
|
| 539 |
|
|
}
|
| 540 |
|
|
break;
|
| 541 |
|
|
|
| 542 |
|
|
case 8:
|
| 543 |
|
|
|
| 544 |
|
|
/* Line 678 of lalr1.cc */
|
| 545 |
|
|
#line 203 "parser.y"
|
| 546 |
|
|
{
|
| 547 |
|
|
//Insert a stupid NOP before the exit... is a bug but easier to just patch like this...
|
| 548 |
|
|
|
| 549 |
|
|
I.mComment = "Exit";
|
| 550 |
|
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
| 551 |
|
|
I.SetOperation(EOPERATION_EXIT);
|
| 552 |
|
|
mInstructions.push_back(I);
|
| 553 |
|
|
I.Clear();
|
| 554 |
|
|
}
|
| 555 |
|
|
break;
|
| 556 |
|
|
|
| 557 |
|
|
case 9:
|
| 558 |
|
|
|
| 559 |
|
|
/* Line 678 of lalr1.cc */
|
| 560 |
|
|
#line 215 "parser.y"
|
| 561 |
|
|
{
|
| 562 |
|
|
|
| 563 |
|
|
I.mComment = "Storing constant '1'";
|
| 564 |
|
|
I.SetOperation( EOPERATION_SUB );
|
| 565 |
|
|
unsigned int TmpReg = GetFreeTempRegister();
|
| 566 |
|
|
I.SetDestinationAddress( TmpReg );
|
| 567 |
|
|
I.SetLiteral(1);
|
| 568 |
|
|
mInstructions.push_back( I );
|
| 569 |
|
|
I.Clear();
|
| 570 |
|
|
|
| 571 |
|
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
| 572 |
|
|
I.SetOperation( EOPERATION_ADD );
|
| 573 |
|
|
I.SetDestinationAddress( GetAddressFromIdentifier((yysemantic_stack_[(4) - (1)]),yylloc) );
|
| 574 |
|
|
I.SetSrc1Address( GetAddressFromIdentifier((yysemantic_stack_[(4) - (3)]),yylloc));
|
| 575 |
|
|
I.SetSrc0Address( TmpReg );
|
| 576 |
|
|
mInstructions.push_back( I );
|
| 577 |
|
|
I.Clear();
|
| 578 |
|
|
gInsertedInstructions = 0;
|
| 579 |
|
|
ResetTempRegisterIndex();
|
| 580 |
|
|
}
|
| 581 |
|
|
break;
|
| 582 |
|
|
|
| 583 |
|
|
case 10:
|
| 584 |
|
|
|
| 585 |
|
|
/* Line 678 of lalr1.cc */
|
| 586 |
|
|
#line 237 "parser.y"
|
| 587 |
|
|
{
|
| 588 |
|
|
|
| 589 |
|
|
I.mComment = "Storing constant '1'";
|
| 590 |
|
|
I.SetOperation( EOPERATION_ADD );
|
| 591 |
|
|
unsigned int TmpReg = GetFreeTempRegister();
|
| 592 |
|
|
I.SetDestinationAddress( TmpReg );
|
| 593 |
|
|
I.SetLiteral(1);
|
| 594 |
|
|
mInstructions.push_back( I );
|
| 595 |
|
|
I.Clear();
|
| 596 |
|
|
|
| 597 |
|
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
| 598 |
|
|
I.SetOperation( EOPERATION_ADD );
|
| 599 |
|
|
I.SetDestinationAddress( GetAddressFromIdentifier((yysemantic_stack_[(4) - (1)]),yylloc) );
|
| 600 |
|
|
I.SetSrc1Address( GetAddressFromIdentifier((yysemantic_stack_[(4) - (3)]),yylloc));
|
| 601 |
|
|
I.SetSrc0Address( TmpReg );
|
| 602 |
|
|
mInstructions.push_back( I );
|
| 603 |
|
|
I.Clear();
|
| 604 |
|
|
gInsertedInstructions = 0;
|
| 605 |
|
|
ResetTempRegisterIndex();
|
| 606 |
|
|
|
| 607 |
|
|
}
|
| 608 |
|
|
break;
|
| 609 |
|
|
|
| 610 |
|
|
case 11:
|
| 611 |
|
|
|
| 612 |
|
|
/* Line 678 of lalr1.cc */
|
| 613 |
|
|
#line 260 "parser.y"
|
| 614 |
|
|
{
|
| 615 |
|
|
mInstructions[mInstructions.size()-gInsertedInstructions].mSourceLine = GetCurrentLineNumber( yylloc );
|
| 616 |
|
|
I.SetOperation( EOPERATION_ADD );
|
| 617 |
|
|
I.SetDestinationAddress( GetAddressFromIdentifier((yysemantic_stack_[(4) - (1)]),yylloc) );
|
| 618 |
|
|
I.SetSrc1Address( GetAddressFromIdentifier((yysemantic_stack_[(4) - (3)]),yylloc));
|
| 619 |
|
|
I.SetSrc0Address(0);
|
| 620 |
|
|
mInstructions.push_back( I );
|
| 621 |
|
|
I.Clear();
|
| 622 |
|
|
gInsertedInstructions = 0;
|
| 623 |
|
|
ResetTempRegisterIndex();
|
| 624 |
|
|
}
|
| 625 |
|
|
break;
|
| 626 |
|
|
|
| 627 |
|
|
case 12:
|
| 628 |
|
|
|
| 629 |
|
|
/* Line 678 of lalr1.cc */
|
| 630 |
|
|
#line 273 "parser.y"
|
| 631 |
|
|
{
|
| 632 |
|
|
mInstructions[mInstructions.size()-gInsertedInstructions].mSourceLine = GetCurrentLineNumber( yylloc );
|
| 633 |
|
|
I.SetOperation( EOPERATION_ADD );
|
| 634 |
|
|
I.SetDestinationAddress( GetAddressFromIdentifier((yysemantic_stack_[(5) - (1)]),yylloc) );
|
| 635 |
|
|
I.SetSrc1Address( GetAddressFromIdentifier((yysemantic_stack_[(5) - (4)]),yylloc));
|
| 636 |
|
|
I.SetSrc0Address( GetAddressFromIdentifier((yysemantic_stack_[(5) - (1)]),yylloc) );
|
| 637 |
|
|
mInstructions.push_back( I );
|
| 638 |
|
|
I.Clear();
|
| 639 |
|
|
gInsertedInstructions = 0;
|
| 640 |
|
|
}
|
| 641 |
|
|
break;
|
| 642 |
|
|
|
| 643 |
|
|
case 13:
|
| 644 |
|
|
|
| 645 |
|
|
/* Line 678 of lalr1.cc */
|
| 646 |
|
|
#line 284 "parser.y"
|
| 647 |
|
|
{gWhileLoopAddress = (mInstructions.size());}
|
| 648 |
|
|
break;
|
| 649 |
|
|
|
| 650 |
|
|
case 14:
|
| 651 |
|
|
|
| 652 |
|
|
/* Line 678 of lalr1.cc */
|
| 653 |
|
|
#line 285 "parser.y"
|
| 654 |
|
|
{
|
| 655 |
|
|
mInstructions[gBranchStack.back()].SetDestinationAddress(mInstructions.size()+1);
|
| 656 |
|
|
gBranchStack.pop_back();
|
| 657 |
|
|
//Now I need to put a GOTO so that the while gets evaluated again...
|
| 658 |
|
|
//jump out of the if
|
| 659 |
|
|
I.Clear();
|
| 660 |
|
|
I.SetOperation( EOPERATION_BRANCH );
|
| 661 |
|
|
I.mComment = "while loop goto re-eval boolean";
|
| 662 |
|
|
I.SetDestinationAddress( gWhileLoopAddress );
|
| 663 |
|
|
mInstructions.push_back(I);
|
| 664 |
|
|
I.Clear();
|
| 665 |
|
|
|
| 666 |
|
|
I.SetOperation( EOPERATION_NOP );
|
| 667 |
|
|
I.mComment = "branch delay";
|
| 668 |
|
|
I.SetDestinationAddress( gWhileLoopAddress );
|
| 669 |
|
|
mInstructions.push_back(I);
|
| 670 |
|
|
I.Clear();
|
| 671 |
|
|
gInsertedInstructions = 0;
|
| 672 |
|
|
}
|
| 673 |
|
|
break;
|
| 674 |
|
|
|
| 675 |
|
|
case 15:
|
| 676 |
|
|
|
| 677 |
|
|
/* Line 678 of lalr1.cc */
|
| 678 |
|
|
#line 306 "parser.y"
|
| 679 |
|
|
{
|
| 680 |
|
|
|
| 681 |
|
|
}
|
| 682 |
|
|
break;
|
| 683 |
|
|
|
| 684 |
|
|
case 16:
|
| 685 |
|
|
|
| 686 |
|
|
/* Line 678 of lalr1.cc */
|
| 687 |
|
|
#line 316 "parser.y"
|
| 688 |
|
|
{
|
| 689 |
|
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
| 690 |
|
|
I.SetOperation( EOPERATION_ADD );
|
| 691 |
|
|
I.SetDestinationAddress( TempRegIndex );
|
| 692 |
|
|
I.SetSrc1Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (1)]),yylloc));
|
| 693 |
|
|
I.SetSrc0Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (3)]),yylloc));
|
| 694 |
|
|
mInstructions.push_back(I);
|
| 695 |
|
|
gInsertedInstructions++;
|
| 696 |
|
|
I.Clear();
|
| 697 |
|
|
std::stringstream ss;
|
| 698 |
|
|
ss << "R" << TempRegIndex;
|
| 699 |
|
|
(yyval) = ss.str();
|
| 700 |
|
|
|
| 701 |
|
|
//$$ = ss.str();
|
| 702 |
|
|
|
| 703 |
|
|
}
|
| 704 |
|
|
break;
|
| 705 |
|
|
|
| 706 |
|
|
case 17:
|
| 707 |
|
|
|
| 708 |
|
|
/* Line 678 of lalr1.cc */
|
| 709 |
|
|
#line 334 "parser.y"
|
| 710 |
|
|
{
|
| 711 |
|
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
| 712 |
|
|
I.SetOperation( EOPERATION_OR );
|
| 713 |
|
|
I.SetDestinationAddress( TempRegIndex );
|
| 714 |
|
|
I.SetSrc1Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (1)]),yylloc));
|
| 715 |
|
|
I.SetSrc0Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (3)]),yylloc));
|
| 716 |
|
|
mInstructions.push_back(I);
|
| 717 |
|
|
gInsertedInstructions++;
|
| 718 |
|
|
I.Clear();
|
| 719 |
|
|
std::stringstream ss;
|
| 720 |
|
|
ss << "R" << TempRegIndex;
|
| 721 |
|
|
(yyval) = ss.str();
|
| 722 |
|
|
}
|
| 723 |
|
|
break;
|
| 724 |
|
|
|
| 725 |
|
|
case 18:
|
| 726 |
|
|
|
| 727 |
|
|
/* Line 678 of lalr1.cc */
|
| 728 |
|
|
#line 349 "parser.y"
|
| 729 |
|
|
{
|
| 730 |
|
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
| 731 |
|
|
I.SetOperation( EOPERATION_SUB );
|
| 732 |
|
|
I.SetDestinationAddress( TempRegIndex );
|
| 733 |
|
|
I.SetSrc1Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (1)]),yylloc));
|
| 734 |
|
|
I.SetSrc0Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (3)]),yylloc));
|
| 735 |
|
|
mInstructions.push_back(I);
|
| 736 |
|
|
gInsertedInstructions++;
|
| 737 |
|
|
I.Clear();
|
| 738 |
|
|
std::stringstream ss;
|
| 739 |
|
|
ss << "R" << TempRegIndex;
|
| 740 |
|
|
(yyval) = ss.str();
|
| 741 |
|
|
}
|
| 742 |
|
|
break;
|
| 743 |
|
|
|
| 744 |
|
|
case 19:
|
| 745 |
|
|
|
| 746 |
|
|
/* Line 678 of lalr1.cc */
|
| 747 |
|
|
#line 364 "parser.y"
|
| 748 |
|
|
{
|
| 749 |
|
|
(yyval) = (yysemantic_stack_[(1) - (1)]);
|
| 750 |
|
|
}
|
| 751 |
|
|
break;
|
| 752 |
|
|
|
| 753 |
|
|
case 20:
|
| 754 |
|
|
|
| 755 |
|
|
/* Line 678 of lalr1.cc */
|
| 756 |
|
|
#line 372 "parser.y"
|
| 757 |
|
|
{
|
| 758 |
|
|
|
| 759 |
|
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
| 760 |
|
|
I.SetOperation( EOPERATION_SHL );
|
| 761 |
|
|
I.SetDestinationAddress( TempRegIndex );
|
| 762 |
|
|
I.SetSrc1Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (1)]),yylloc));
|
| 763 |
|
|
I.SetSrc0Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (3)]),yylloc));
|
| 764 |
|
|
mInstructions.push_back(I);
|
| 765 |
|
|
gInsertedInstructions++;
|
| 766 |
|
|
I.Clear();
|
| 767 |
|
|
std::stringstream ss;
|
| 768 |
|
|
ss << "R" << TempRegIndex;
|
| 769 |
|
|
(yyval) = ss.str();
|
| 770 |
|
|
}
|
| 771 |
|
|
break;
|
| 772 |
|
|
|
| 773 |
|
|
case 21:
|
| 774 |
|
|
|
| 775 |
|
|
/* Line 678 of lalr1.cc */
|
| 776 |
|
|
#line 388 "parser.y"
|
| 777 |
|
|
{
|
| 778 |
|
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
| 779 |
|
|
I.SetOperation( EOPERATION_SHR );
|
| 780 |
|
|
I.SetDestinationAddress( TempRegIndex );
|
| 781 |
|
|
I.SetSrc1Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (1)]),yylloc));
|
| 782 |
|
|
I.SetSrc0Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (3)]),yylloc));
|
| 783 |
|
|
mInstructions.push_back(I);
|
| 784 |
|
|
gInsertedInstructions++;
|
| 785 |
|
|
I.Clear();
|
| 786 |
|
|
std::stringstream ss;
|
| 787 |
|
|
ss << "R" << TempRegIndex;
|
| 788 |
|
|
(yyval) = ss.str();
|
| 789 |
|
|
}
|
| 790 |
|
|
break;
|
| 791 |
|
|
|
| 792 |
|
|
case 22:
|
| 793 |
|
|
|
| 794 |
|
|
/* Line 678 of lalr1.cc */
|
| 795 |
|
|
#line 403 "parser.y"
|
| 796 |
|
|
{
|
| 797 |
|
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
| 798 |
|
|
I.SetOperation( EOPERATION_AND );
|
| 799 |
|
|
I.SetDestinationAddress( TempRegIndex );
|
| 800 |
|
|
I.SetSrc1Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (1)]),yylloc));
|
| 801 |
|
|
I.SetSrc0Address(GetAddressFromIdentifier((yysemantic_stack_[(3) - (3)]),yylloc));
|
| 802 |
|
|
mInstructions.push_back(I);
|
| 803 |
|
|
gInsertedInstructions++;
|
| 804 |
|
|
I.Clear();
|
| 805 |
|
|
std::stringstream ss;
|
| 806 |
|
|
ss << "R" << TempRegIndex;
|
| 807 |
|
|
(yyval) = ss.str();
|
| 808 |
|
|
}
|
| 809 |
|
|
break;
|
| 810 |
|
|
|
| 811 |
|
|
case 23:
|
| 812 |
|
|
|
| 813 |
|
|
/* Line 678 of lalr1.cc */
|
| 814 |
|
|
#line 418 "parser.y"
|
| 815 |
|
|
{
|
| 816 |
|
|
(yyval) = (yysemantic_stack_[(1) - (1)]);
|
| 817 |
|
|
}
|
| 818 |
|
|
break;
|
| 819 |
|
|
|
| 820 |
|
|
case 24:
|
| 821 |
|
|
|
| 822 |
|
|
/* Line 678 of lalr1.cc */
|
| 823 |
|
|
#line 426 "parser.y"
|
| 824 |
|
|
{
|
| 825 |
|
|
(yyval) = (yysemantic_stack_[(1) - (1)]);
|
| 826 |
|
|
}
|
| 827 |
|
|
break;
|
| 828 |
|
|
|
| 829 |
|
|
case 25:
|
| 830 |
|
|
|
| 831 |
|
|
/* Line 678 of lalr1.cc */
|
| 832 |
|
|
#line 431 "parser.y"
|
| 833 |
|
|
{
|
| 834 |
|
|
(yyval) = (yysemantic_stack_[(3) - (2)]);
|
| 835 |
|
|
}
|
| 836 |
|
|
break;
|
| 837 |
|
|
|
| 838 |
|
|
case 26:
|
| 839 |
|
|
|
| 840 |
|
|
/* Line 678 of lalr1.cc */
|
| 841 |
|
|
#line 436 "parser.y"
|
| 842 |
|
|
{
|
| 843 |
|
|
unsigned int ImmediateValue;
|
| 844 |
|
|
std::string StringHex = (yysemantic_stack_[(1) - (1)]);
|
| 845 |
|
|
std::stringstream ss;
|
| 846 |
|
|
ss << std::hex << StringHex;
|
| 847 |
|
|
ss >> ImmediateValue;
|
| 848 |
|
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
| 849 |
|
|
I.SetOperation( EOPERATION_ASSIGN );
|
| 850 |
|
|
// I.mSourceLine = GetCurrentLineNumber( yylloc );
|
| 851 |
|
|
|
| 852 |
|
|
I.SetDestinationAddress( TempRegIndex );
|
| 853 |
|
|
|
| 854 |
|
|
I.SetLiteral(ImmediateValue);
|
| 855 |
|
|
|
| 856 |
|
|
mInstructions.push_back(I);
|
| 857 |
|
|
|
| 858 |
|
|
gInsertedInstructions++;
|
| 859 |
|
|
I.Clear();
|
| 860 |
|
|
std::stringstream ss2;
|
| 861 |
|
|
ss2 << "R" << TempRegIndex;
|
| 862 |
|
|
(yyval) = ss2.str();
|
| 863 |
|
|
}
|
| 864 |
|
|
break;
|
| 865 |
|
|
|
| 866 |
|
|
case 27:
|
| 867 |
|
|
|
| 868 |
|
|
/* Line 678 of lalr1.cc */
|
| 869 |
|
|
#line 465 "parser.y"
|
| 870 |
|
|
{
|
| 871 |
|
|
// Transform to HEX string
|
| 872 |
|
|
unsigned int Val;
|
| 873 |
|
|
std::string StringDec = (yysemantic_stack_[(1) - (1)]);
|
| 874 |
|
|
std::stringstream ss;
|
| 875 |
|
|
ss << StringDec;
|
| 876 |
|
|
ss >> Val;
|
| 877 |
|
|
std::stringstream ss2;
|
| 878 |
|
|
ss2 << std::hex << Val;
|
| 879 |
|
|
(yyval) = ss2.str();
|
| 880 |
|
|
}
|
| 881 |
|
|
break;
|
| 882 |
|
|
|
| 883 |
|
|
case 28:
|
| 884 |
|
|
|
| 885 |
|
|
/* Line 678 of lalr1.cc */
|
| 886 |
|
|
#line 478 "parser.y"
|
| 887 |
|
|
{
|
| 888 |
|
|
std::string StringHex = (yysemantic_stack_[(1) - (1)]);
|
| 889 |
|
|
// Get rid of the 0x
|
| 890 |
|
|
StringHex.erase(StringHex.begin(),StringHex.begin()+2);
|
| 891 |
|
|
std::stringstream ss;
|
| 892 |
|
|
ss << std::hex << StringHex;
|
| 893 |
|
|
|
| 894 |
|
|
(yyval) = ss.str();
|
| 895 |
|
|
}
|
| 896 |
|
|
break;
|
| 897 |
|
|
|
| 898 |
|
|
case 29:
|
| 899 |
|
|
|
| 900 |
|
|
/* Line 678 of lalr1.cc */
|
| 901 |
|
|
#line 489 "parser.y"
|
| 902 |
|
|
{
|
| 903 |
|
|
// Transform to HEX string
|
| 904 |
|
|
std::string StringBin = (yysemantic_stack_[(1) - (1)]);
|
| 905 |
|
|
// Get rid of the 0b
|
| 906 |
|
|
StringBin.erase(StringBin.begin(),StringBin.begin()+2);
|
| 907 |
|
|
std::bitset<32> Bitset( StringBin );
|
| 908 |
|
|
std::stringstream ss2;
|
| 909 |
|
|
ss2 << std::hex << Bitset;
|
| 910 |
|
|
(yyval) = ss2.str();
|
| 911 |
|
|
}
|
| 912 |
|
|
break;
|
| 913 |
|
|
|
| 914 |
|
|
case 30:
|
| 915 |
|
|
|
| 916 |
|
|
/* Line 678 of lalr1.cc */
|
| 917 |
|
|
#line 504 "parser.y"
|
| 918 |
|
|
{
|
| 919 |
|
|
|
| 920 |
|
|
unsigned int ImmediateValue = 0x1;
|
| 921 |
|
|
unsigned int TempRegIndex0 = GetFreeTempRegister();
|
| 922 |
|
|
I.SetOperation( EOPERATION_ASSIGN );
|
| 923 |
|
|
I.SetDestinationAddress( TempRegIndex0 );
|
| 924 |
|
|
I.SetLiteral(ImmediateValue);
|
| 925 |
|
|
mInstructions.push_back(I);
|
| 926 |
|
|
gInsertedInstructions++;
|
| 927 |
|
|
|
| 928 |
|
|
|
| 929 |
|
|
I.SetOperation( EOPERATION_BEQ );
|
| 930 |
|
|
I.SetDestinationAddress( 0 );
|
| 931 |
|
|
I.SetSrc1Address( STATUS_REG );
|
| 932 |
|
|
I.SetSrc0Address(TempRegIndex0);
|
| 933 |
|
|
mInstructions.push_back(I);
|
| 934 |
|
|
gInsertedInstructions++;
|
| 935 |
|
|
gBranchStack.push_back(mInstructions.size() - 1);
|
| 936 |
|
|
I.Clear();
|
| 937 |
|
|
|
| 938 |
|
|
I.SetOperation( EOPERATION_NOP );
|
| 939 |
|
|
I.mComment = "branch delay";
|
| 940 |
|
|
I.SetDestinationAddress( gWhileLoopAddress );
|
| 941 |
|
|
mInstructions.push_back(I);
|
| 942 |
|
|
I.Clear();
|
| 943 |
|
|
|
| 944 |
|
|
|
| 945 |
|
|
|
| 946 |
|
|
}
|
| 947 |
|
|
break;
|
| 948 |
|
|
|
| 949 |
|
|
case 31:
|
| 950 |
|
|
|
| 951 |
|
|
/* Line 678 of lalr1.cc */
|
| 952 |
|
|
#line 535 "parser.y"
|
| 953 |
|
|
{
|
| 954 |
|
|
|
| 955 |
|
|
I.SetOperation( EOPERATION_BNE );
|
| 956 |
|
|
I.SetDestinationAddress( 0 );
|
| 957 |
|
|
I.SetSrc1Address( GetAddressFromIdentifier((yysemantic_stack_[(3) - (1)]),yylloc) );
|
| 958 |
|
|
I.SetSrc0Address( GetAddressFromIdentifier((yysemantic_stack_[(3) - (3)]),yylloc));
|
| 959 |
|
|
mInstructions.push_back(I);
|
| 960 |
|
|
gInsertedInstructions++;
|
| 961 |
|
|
gBranchStack.push_back(mInstructions.size() - 1);
|
| 962 |
|
|
I.Clear();
|
| 963 |
|
|
|
| 964 |
|
|
I.SetOperation( EOPERATION_NOP );
|
| 965 |
|
|
I.mComment = "branch delay";
|
| 966 |
|
|
I.SetDestinationAddress( gWhileLoopAddress );
|
| 967 |
|
|
mInstructions.push_back(I);
|
| 968 |
|
|
I.Clear();
|
| 969 |
|
|
|
| 970 |
|
|
}
|
| 971 |
|
|
break;
|
| 972 |
|
|
|
| 973 |
|
|
case 32:
|
| 974 |
|
|
|
| 975 |
|
|
/* Line 678 of lalr1.cc */
|
| 976 |
|
|
#line 555 "parser.y"
|
| 977 |
|
|
{
|
| 978 |
|
|
|
| 979 |
|
|
I.SetOperation( EOPERATION_BLE );
|
| 980 |
|
|
I.SetDestinationAddress( 0 );
|
| 981 |
|
|
I.SetSrc1Address( GetAddressFromIdentifier((yysemantic_stack_[(3) - (1)]),yylloc) );
|
| 982 |
|
|
I.SetSrc0Address( GetAddressFromIdentifier((yysemantic_stack_[(3) - (3)]),yylloc));
|
| 983 |
|
|
mInstructions.push_back(I);
|
| 984 |
|
|
gInsertedInstructions++;
|
| 985 |
|
|
gBranchStack.push_back(mInstructions.size() - 1);
|
| 986 |
|
|
I.Clear();
|
| 987 |
|
|
|
| 988 |
|
|
I.SetOperation( EOPERATION_NOP );
|
| 989 |
|
|
I.mComment = "branch delay";
|
| 990 |
|
|
I.SetDestinationAddress( gWhileLoopAddress );
|
| 991 |
|
|
mInstructions.push_back(I);
|
| 992 |
|
|
I.Clear();
|
| 993 |
|
|
|
| 994 |
|
|
}
|
| 995 |
|
|
break;
|
| 996 |
|
|
|
| 997 |
|
|
case 33:
|
| 998 |
|
|
|
| 999 |
|
|
/* Line 678 of lalr1.cc */
|
| 1000 |
|
|
#line 577 "parser.y"
|
| 1001 |
|
|
{
|
| 1002 |
|
|
if (gVaribleMap.find((yysemantic_stack_[(3) - (1)])) != gVaribleMap.end())
|
| 1003 |
|
|
{
|
| 1004 |
|
|
std::ostringstream ret;
|
| 1005 |
|
|
ret << "Duplicated symbol '" << (yysemantic_stack_[(3) - (1)]) << "'\n";
|
| 1006 |
|
|
throw ret.str();
|
| 1007 |
|
|
}
|
| 1008 |
|
|
|
| 1009 |
|
|
gVaribleMap[ (yysemantic_stack_[(3) - (1)]) ] = AllocateVariable();
|
| 1010 |
|
|
}
|
| 1011 |
|
|
break;
|
| 1012 |
|
|
|
| 1013 |
|
|
case 34:
|
| 1014 |
|
|
|
| 1015 |
|
|
/* Line 678 of lalr1.cc */
|
| 1016 |
|
|
#line 589 "parser.y"
|
| 1017 |
|
|
{
|
| 1018 |
|
|
if (gVaribleMap.find((yysemantic_stack_[(5) - (1)])) != gVaribleMap.end())
|
| 1019 |
|
|
{
|
| 1020 |
|
|
std::ostringstream ret;
|
| 1021 |
|
|
ret << "Duplicated symbol '" << (yysemantic_stack_[(5) - (1)]) << "'\n";
|
| 1022 |
|
|
throw ret.str();
|
| 1023 |
|
|
}
|
| 1024 |
|
|
|
| 1025 |
|
|
gVaribleMap[ (yysemantic_stack_[(5) - (1)]) ] = AllocateVariable();
|
| 1026 |
|
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
| 1027 |
|
|
I.SetOperation( EOPERATION_ASSIGN );
|
| 1028 |
|
|
I.SetDestinationAddress( gVaribleMap[ (yysemantic_stack_[(5) - (1)]) ] );
|
| 1029 |
|
|
I.SetLiteral( atoi((yysemantic_stack_[(5) - (3)]).c_str() ) );
|
| 1030 |
|
|
mInstructions.push_back( I );
|
| 1031 |
|
|
I.Clear();
|
| 1032 |
|
|
|
| 1033 |
|
|
}
|
| 1034 |
|
|
break;
|
| 1035 |
|
|
|
| 1036 |
|
|
case 35:
|
| 1037 |
|
|
|
| 1038 |
|
|
/* Line 678 of lalr1.cc */
|
| 1039 |
|
|
#line 608 "parser.y"
|
| 1040 |
|
|
{
|
| 1041 |
|
|
if (gVaribleMap.find((yysemantic_stack_[(3) - (1)])) != gVaribleMap.end())
|
| 1042 |
|
|
{
|
| 1043 |
|
|
std::ostringstream ret;
|
| 1044 |
|
|
ret << "Duplicated symbol '" << (yysemantic_stack_[(3) - (1)]) << "'\n";
|
| 1045 |
|
|
throw ret.str();
|
| 1046 |
|
|
}
|
| 1047 |
|
|
unsigned int ImmediateValue;
|
| 1048 |
|
|
std::string StringHex = (yysemantic_stack_[(3) - (3)]);
|
| 1049 |
|
|
std::stringstream ss;
|
| 1050 |
|
|
ss << std::hex << StringHex;
|
| 1051 |
|
|
ss >> ImmediateValue;
|
| 1052 |
|
|
gVaribleMap[ (yysemantic_stack_[(3) - (1)]) ] = AllocateVariable();
|
| 1053 |
|
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
| 1054 |
|
|
I.SetOperation( EOPERATION_ASSIGN );
|
| 1055 |
|
|
I.SetDestinationAddress( gVaribleMap[ (yysemantic_stack_[(3) - (1)]) ] );
|
| 1056 |
|
|
I.SetLiteral( ImmediateValue );
|
| 1057 |
|
|
mInstructions.push_back( I );
|
| 1058 |
|
|
I.Clear();
|
| 1059 |
|
|
}
|
| 1060 |
|
|
break;
|
| 1061 |
|
|
|
| 1062 |
|
|
case 36:
|
| 1063 |
|
|
|
| 1064 |
|
|
/* Line 678 of lalr1.cc */
|
| 1065 |
|
|
#line 630 "parser.y"
|
| 1066 |
|
|
{
|
| 1067 |
|
|
if (gVaribleMap.find((yysemantic_stack_[(1) - (1)])) != gVaribleMap.end())
|
| 1068 |
|
|
{
|
| 1069 |
|
|
std::ostringstream ret;
|
| 1070 |
|
|
ret << "Duplicated symbol '" << (yysemantic_stack_[(1) - (1)]) << "'\n";
|
| 1071 |
|
|
throw ret.str();
|
| 1072 |
|
|
}
|
| 1073 |
|
|
|
| 1074 |
|
|
gVaribleMap[ (yysemantic_stack_[(1) - (1)]) ] = AllocateVariable();
|
| 1075 |
|
|
}
|
| 1076 |
|
|
break;
|
| 1077 |
|
|
|
| 1078 |
|
|
|
| 1079 |
|
|
|
| 1080 |
|
|
/* Line 678 of lalr1.cc */
|
| 1081 |
|
|
#line 1082 "parser.tab.c"
|
| 1082 |
|
|
default:
|
| 1083 |
|
|
break;
|
| 1084 |
|
|
}
|
| 1085 |
|
|
YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
|
| 1086 |
|
|
|
| 1087 |
|
|
yypop_ (yylen);
|
| 1088 |
|
|
yylen = 0;
|
| 1089 |
|
|
YY_STACK_PRINT ();
|
| 1090 |
|
|
|
| 1091 |
|
|
yysemantic_stack_.push (yyval);
|
| 1092 |
|
|
yylocation_stack_.push (yyloc);
|
| 1093 |
|
|
|
| 1094 |
|
|
/* Shift the result of the reduction. */
|
| 1095 |
|
|
yyn = yyr1_[yyn];
|
| 1096 |
|
|
yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
|
| 1097 |
|
|
if (0 <= yystate && yystate <= yylast_
|
| 1098 |
|
|
&& yycheck_[yystate] == yystate_stack_[0])
|
| 1099 |
|
|
yystate = yytable_[yystate];
|
| 1100 |
|
|
else
|
| 1101 |
|
|
yystate = yydefgoto_[yyn - yyntokens_];
|
| 1102 |
|
|
goto yynewstate;
|
| 1103 |
|
|
|
| 1104 |
|
|
/*------------------------------------.
|
| 1105 |
|
|
| yyerrlab -- here on detecting error |
|
| 1106 |
|
|
`------------------------------------*/
|
| 1107 |
|
|
yyerrlab:
|
| 1108 |
|
|
/* If not already recovering from an error, report this error. */
|
| 1109 |
|
|
if (!yyerrstatus_)
|
| 1110 |
|
|
{
|
| 1111 |
|
|
++yynerrs_;
|
| 1112 |
|
|
error (yylloc, yysyntax_error_ (yystate, yytoken));
|
| 1113 |
|
|
}
|
| 1114 |
|
|
|
| 1115 |
|
|
yyerror_range[0] = yylloc;
|
| 1116 |
|
|
if (yyerrstatus_ == 3)
|
| 1117 |
|
|
{
|
| 1118 |
|
|
/* If just tried and failed to reuse lookahead token after an
|
| 1119 |
|
|
error, discard it. */
|
| 1120 |
|
|
|
| 1121 |
|
|
if (yychar <= yyeof_)
|
| 1122 |
|
|
{
|
| 1123 |
|
|
/* Return failure if at end of input. */
|
| 1124 |
|
|
if (yychar == yyeof_)
|
| 1125 |
|
|
YYABORT;
|
| 1126 |
|
|
}
|
| 1127 |
|
|
else
|
| 1128 |
|
|
{
|
| 1129 |
|
|
yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
|
| 1130 |
|
|
yychar = yyempty_;
|
| 1131 |
|
|
}
|
| 1132 |
|
|
}
|
| 1133 |
|
|
|
| 1134 |
|
|
/* Else will try to reuse lookahead token after shifting the error
|
| 1135 |
|
|
token. */
|
| 1136 |
|
|
goto yyerrlab1;
|
| 1137 |
|
|
|
| 1138 |
|
|
|
| 1139 |
|
|
/*---------------------------------------------------.
|
| 1140 |
|
|
| yyerrorlab -- error raised explicitly by YYERROR. |
|
| 1141 |
|
|
`---------------------------------------------------*/
|
| 1142 |
|
|
yyerrorlab:
|
| 1143 |
|
|
|
| 1144 |
|
|
/* Pacify compilers like GCC when the user code never invokes
|
| 1145 |
|
|
YYERROR and the label yyerrorlab therefore never appears in user
|
| 1146 |
|
|
code. */
|
| 1147 |
|
|
if (false)
|
| 1148 |
|
|
goto yyerrorlab;
|
| 1149 |
|
|
|
| 1150 |
|
|
yyerror_range[0] = yylocation_stack_[yylen - 1];
|
| 1151 |
|
|
/* Do not reclaim the symbols of the rule which action triggered
|
| 1152 |
|
|
this YYERROR. */
|
| 1153 |
|
|
yypop_ (yylen);
|
| 1154 |
|
|
yylen = 0;
|
| 1155 |
|
|
yystate = yystate_stack_[0];
|
| 1156 |
|
|
goto yyerrlab1;
|
| 1157 |
|
|
|
| 1158 |
|
|
/*-------------------------------------------------------------.
|
| 1159 |
|
|
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
| 1160 |
|
|
`-------------------------------------------------------------*/
|
| 1161 |
|
|
yyerrlab1:
|
| 1162 |
|
|
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
| 1163 |
|
|
|
| 1164 |
|
|
for (;;)
|
| 1165 |
|
|
{
|
| 1166 |
|
|
yyn = yypact_[yystate];
|
| 1167 |
|
|
if (yyn != yypact_ninf_)
|
| 1168 |
|
|
{
|
| 1169 |
|
|
yyn += yyterror_;
|
| 1170 |
|
|
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
| 1171 |
|
|
{
|
| 1172 |
|
|
yyn = yytable_[yyn];
|
| 1173 |
|
|
if (0 < yyn)
|
| 1174 |
|
|
break;
|
| 1175 |
|
|
}
|
| 1176 |
|
|
}
|
| 1177 |
|
|
|
| 1178 |
|
|
/* Pop the current state because it cannot handle the error token. */
|
| 1179 |
|
|
if (yystate_stack_.height () == 1)
|
| 1180 |
|
|
YYABORT;
|
| 1181 |
|
|
|
| 1182 |
|
|
yyerror_range[0] = yylocation_stack_[0];
|
| 1183 |
|
|
yydestruct_ ("Error: popping",
|
| 1184 |
|
|
yystos_[yystate],
|
| 1185 |
|
|
&yysemantic_stack_[0], &yylocation_stack_[0]);
|
| 1186 |
|
|
yypop_ ();
|
| 1187 |
|
|
yystate = yystate_stack_[0];
|
| 1188 |
|
|
YY_STACK_PRINT ();
|
| 1189 |
|
|
}
|
| 1190 |
|
|
|
| 1191 |
|
|
yyerror_range[1] = yylloc;
|
| 1192 |
|
|
// Using YYLLOC is tempting, but would change the location of
|
| 1193 |
|
|
// the lookahead. YYLOC is available though.
|
| 1194 |
|
|
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
|
| 1195 |
|
|
yysemantic_stack_.push (yylval);
|
| 1196 |
|
|
yylocation_stack_.push (yyloc);
|
| 1197 |
|
|
|
| 1198 |
|
|
/* Shift the error token. */
|
| 1199 |
|
|
YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
|
| 1200 |
|
|
&yysemantic_stack_[0], &yylocation_stack_[0]);
|
| 1201 |
|
|
|
| 1202 |
|
|
yystate = yyn;
|
| 1203 |
|
|
goto yynewstate;
|
| 1204 |
|
|
|
| 1205 |
|
|
/* Accept. */
|
| 1206 |
|
|
yyacceptlab:
|
| 1207 |
|
|
yyresult = 0;
|
| 1208 |
|
|
goto yyreturn;
|
| 1209 |
|
|
|
| 1210 |
|
|
/* Abort. */
|
| 1211 |
|
|
yyabortlab:
|
| 1212 |
|
|
yyresult = 1;
|
| 1213 |
|
|
goto yyreturn;
|
| 1214 |
|
|
|
| 1215 |
|
|
yyreturn:
|
| 1216 |
|
|
if (yychar != yyempty_)
|
| 1217 |
|
|
yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
|
| 1218 |
|
|
|
| 1219 |
|
|
/* Do not reclaim the symbols of the rule which action triggered
|
| 1220 |
|
|
this YYABORT or YYACCEPT. */
|
| 1221 |
|
|
yypop_ (yylen);
|
| 1222 |
|
|
while (yystate_stack_.height () != 1)
|
| 1223 |
|
|
{
|
| 1224 |
|
|
yydestruct_ ("Cleanup: popping",
|
| 1225 |
|
|
yystos_[yystate_stack_[0]],
|
| 1226 |
|
|
&yysemantic_stack_[0],
|
| 1227 |
|
|
&yylocation_stack_[0]);
|
| 1228 |
|
|
yypop_ ();
|
| 1229 |
|
|
}
|
| 1230 |
|
|
|
| 1231 |
|
|
return yyresult;
|
| 1232 |
|
|
}
|
| 1233 |
|
|
|
| 1234 |
|
|
// Generate an error message.
|
| 1235 |
|
|
std::string
|
| 1236 |
|
|
Parser::yysyntax_error_ (int yystate, int tok)
|
| 1237 |
|
|
{
|
| 1238 |
|
|
std::string res;
|
| 1239 |
|
|
YYUSE (yystate);
|
| 1240 |
|
|
#if YYERROR_VERBOSE
|
| 1241 |
|
|
int yyn = yypact_[yystate];
|
| 1242 |
|
|
if (yypact_ninf_ < yyn && yyn <= yylast_)
|
| 1243 |
|
|
{
|
| 1244 |
|
|
/* Start YYX at -YYN if negative to avoid negative indexes in
|
| 1245 |
|
|
YYCHECK. */
|
| 1246 |
|
|
int yyxbegin = yyn < 0 ? -yyn : 0;
|
| 1247 |
|
|
|
| 1248 |
|
|
/* Stay within bounds of both yycheck and yytname. */
|
| 1249 |
|
|
int yychecklim = yylast_ - yyn + 1;
|
| 1250 |
|
|
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
| 1251 |
|
|
int count = 0;
|
| 1252 |
|
|
for (int x = yyxbegin; x < yyxend; ++x)
|
| 1253 |
|
|
if (yycheck_[x + yyn] == x && x != yyterror_)
|
| 1254 |
|
|
++count;
|
| 1255 |
|
|
|
| 1256 |
|
|
// FIXME: This method of building the message is not compatible
|
| 1257 |
|
|
// with internationalization. It should work like yacc.c does it.
|
| 1258 |
|
|
// That is, first build a string that looks like this:
|
| 1259 |
|
|
// "syntax error, unexpected %s or %s or %s"
|
| 1260 |
|
|
// Then, invoke YY_ on this string.
|
| 1261 |
|
|
// Finally, use the string as a format to output
|
| 1262 |
|
|
// yytname_[tok], etc.
|
| 1263 |
|
|
// Until this gets fixed, this message appears in English only.
|
| 1264 |
|
|
res = "syntax error, unexpected ";
|
| 1265 |
|
|
res += yytnamerr_ (yytname_[tok]);
|
| 1266 |
|
|
if (count < 5)
|
| 1267 |
|
|
{
|
| 1268 |
|
|
count = 0;
|
| 1269 |
|
|
for (int x = yyxbegin; x < yyxend; ++x)
|
| 1270 |
|
|
if (yycheck_[x + yyn] == x && x != yyterror_)
|
| 1271 |
|
|
{
|
| 1272 |
|
|
res += (!count++) ? ", expecting " : " or ";
|
| 1273 |
|
|
res += yytnamerr_ (yytname_[x]);
|
| 1274 |
|
|
}
|
| 1275 |
|
|
}
|
| 1276 |
|
|
}
|
| 1277 |
|
|
else
|
| 1278 |
|
|
#endif
|
| 1279 |
|
|
res = YY_("syntax error");
|
| 1280 |
|
|
return res;
|
| 1281 |
|
|
}
|
| 1282 |
|
|
|
| 1283 |
|
|
|
| 1284 |
|
|
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
| 1285 |
|
|
STATE-NUM. */
|
| 1286 |
|
|
const signed char Parser::yypact_ninf_ = -21;
|
| 1287 |
|
|
const signed char
|
| 1288 |
|
|
Parser::yypact_[] =
|
| 1289 |
|
|
{
|
| 1290 |
|
|
17, -19, 12, 65, -21, 16, 7, 4, -21, -14,
|
| 1291 |
|
|
22, -21, 76, 73, -3, 29, 34, 28, 76, -21,
|
| 1292 |
|
|
-21, 34, -19, -21, 76, -21, -21, -21, -21, 46,
|
| 1293 |
|
|
-21, 9, -21, 76, 40, 57, 39, 85, -21, 47,
|
| 1294 |
|
|
78, -21, 43, 76, -21, 76, 76, 76, 76, 76,
|
| 1295 |
|
|
53, -21, -21, -21, 20, 84, 86, 76, -19, -21,
|
| 1296 |
|
|
-21, -21, -21, -21, -21, -21, -21, 76, 76, 92,
|
| 1297 |
|
|
-21, 62, -21, 63, 63, 17, 76, -2, 0, -21,
|
| 1298 |
|
|
87, -21
|
| 1299 |
|
|
};
|
| 1300 |
|
|
|
| 1301 |
|
|
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
|
| 1302 |
|
|
doesn't specify something else to do. Zero means the default is an
|
| 1303 |
|
|
error. */
|
| 1304 |
|
|
const unsigned char
|
| 1305 |
|
|
Parser::yydefact_[] =
|
| 1306 |
|
|
{
|
| 1307 |
|
|
2, 0, 0, 0, 13, 0, 0, 0, 4, 36,
|
| 1308 |
|
|
0, 8, 0, 0, 0, 0, 0, 0, 0, 1,
|
| 1309 |
|
|
3, 0, 0, 6, 0, 27, 28, 29, 24, 0,
|
| 1310 |
|
|
19, 23, 26, 0, 0, 0, 0, 0, 15, 0,
|
| 1311 |
|
|
35, 33, 0, 0, 11, 0, 0, 0, 0, 0,
|
| 1312 |
|
|
0, 10, 9, 30, 0, 0, 0, 0, 0, 25,
|
| 1313 |
|
|
16, 18, 17, 20, 21, 22, 12, 0, 0, 0,
|
| 1314 |
|
|
5, 0, 34, 31, 32, 2, 0, 0, 0, 14,
|
| 1315 |
|
|
0, 7
|
| 1316 |
|
|
};
|
| 1317 |
|
|
|
| 1318 |
|
|
/* YYPGOTO[NTERM-NUM]. */
|
| 1319 |
|
|
const signed char
|
| 1320 |
|
|
Parser::yypgoto_[] =
|
| 1321 |
|
|
{
|
| 1322 |
|
|
-21, 38, -7, -21, -17, 59, 60, -1, -21, -20
|
| 1323 |
|
|
};
|
| 1324 |
|
|
|
| 1325 |
|
|
/* YYDEFGOTO[NTERM-NUM]. */
|
| 1326 |
|
|
const signed char
|
| 1327 |
|
|
Parser::yydefgoto_[] =
|
| 1328 |
|
|
{
|
| 1329 |
|
|
-1, 7, 8, 15, 29, 30, 31, 32, 55, 10
|
| 1330 |
|
|
};
|
| 1331 |
|
|
|
| 1332 |
|
|
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
| 1333 |
|
|
positive, shift that token. If negative, reduce the rule which
|
| 1334 |
|
|
number is the opposite. If zero, do what YYDEFACT says. */
|
| 1335 |
|
|
const signed char Parser::yytable_ninf_ = -1;
|
| 1336 |
|
|
const unsigned char
|
| 1337 |
|
|
Parser::yytable_[] =
|
| 1338 |
|
|
{
|
| 1339 |
|
|
20, 39, 41, 1, 19, 2, 21, 42, 9, 1,
|
| 1340 |
|
|
80, 2, 47, 48, 22, 37, 50, 79, 18, 54,
|
| 1341 |
|
|
40, 43, 1, 35, 2, 3, 45, 16, 67, 4,
|
| 1342 |
|
|
5, 3, 68, 6, 46, 4, 5, 11, 72, 6,
|
| 1343 |
|
|
71, 43, 49, 17, 3, 36, 45, 23, 4, 5,
|
| 1344 |
|
|
73, 74, 6, 38, 46, 24, 25, 26, 27, 78,
|
| 1345 |
|
|
59, 25, 26, 27, 43, 51, 28, 43, 43, 45,
|
| 1346 |
|
|
20, 44, 45, 45, 43, 57, 53, 46, 66, 45,
|
| 1347 |
|
|
46, 46, 52, 43, 43, 12, 13, 46, 45, 45,
|
| 1348 |
|
|
76, 14, 24, 33, 34, 56, 46, 46, 25, 26,
|
| 1349 |
|
|
27, 69, 60, 28, 61, 62, 58, 63, 64, 65,
|
| 1350 |
|
|
75, 70, 81, 77
|
| 1351 |
|
|
};
|
| 1352 |
|
|
|
| 1353 |
|
|
/* YYCHECK. */
|
| 1354 |
|
|
const unsigned char
|
| 1355 |
|
|
Parser::yycheck_[] =
|
| 1356 |
|
|
{
|
| 1357 |
|
|
7, 18, 22, 5, 0, 7, 20, 24, 27, 5,
|
| 1358 |
|
|
10, 7, 3, 4, 28, 16, 33, 19, 11, 36,
|
| 1359 |
|
|
21, 21, 5, 26, 7, 27, 26, 11, 8, 31,
|
| 1360 |
|
|
32, 27, 12, 35, 34, 31, 32, 25, 58, 35,
|
| 1361 |
|
|
57, 21, 33, 27, 27, 16, 26, 25, 31, 32,
|
| 1362 |
|
|
67, 68, 35, 25, 34, 16, 22, 23, 24, 76,
|
| 1363 |
|
|
17, 22, 23, 24, 21, 25, 27, 21, 21, 26,
|
| 1364 |
|
|
77, 25, 26, 26, 21, 28, 37, 34, 25, 26,
|
| 1365 |
|
|
34, 34, 25, 21, 21, 20, 21, 34, 26, 26,
|
| 1366 |
|
|
28, 26, 16, 20, 21, 10, 34, 34, 22, 23,
|
| 1367 |
|
|
24, 17, 43, 27, 45, 46, 28, 47, 48, 49,
|
| 1368 |
|
|
18, 25, 25, 75
|
| 1369 |
|
|
};
|
| 1370 |
|
|
|
| 1371 |
|
|
/* STOS_[STATE-NUM] -- The (internal number of the) accessing
|
| 1372 |
|
|
symbol of state STATE-NUM. */
|
| 1373 |
|
|
const unsigned char
|
| 1374 |
|
|
Parser::yystos_[] =
|
| 1375 |
|
|
{
|
| 1376 |
|
|
0, 5, 7, 27, 31, 32, 35, 39, 40, 27,
|
| 1377 |
|
|
47, 25, 20, 21, 26, 41, 11, 27, 11, 0,
|
| 1378 |
|
|
40, 20, 28, 25, 16, 22, 23, 24, 27, 42,
|
| 1379 |
|
|
43, 44, 45, 20, 21, 26, 16, 45, 25, 42,
|
| 1380 |
|
|
45, 47, 42, 21, 25, 26, 34, 3, 4, 33,
|
| 1381 |
|
|
42, 25, 25, 37, 42, 46, 10, 28, 28, 17,
|
| 1382 |
|
|
43, 43, 43, 44, 44, 44, 25, 8, 12, 17,
|
| 1383 |
|
|
25, 42, 47, 42, 42, 18, 28, 39, 42, 19,
|
| 1384 |
|
|
10, 25
|
| 1385 |
|
|
};
|
| 1386 |
|
|
|
| 1387 |
|
|
#if YYDEBUG
|
| 1388 |
|
|
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
| 1389 |
|
|
to YYLEX-NUM. */
|
| 1390 |
|
|
const unsigned short int
|
| 1391 |
|
|
Parser::yytoken_number_[] =
|
| 1392 |
|
|
{
|
| 1393 |
|
|
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
|
| 1394 |
|
|
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
|
| 1395 |
|
|
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
|
| 1396 |
|
|
285, 286, 287, 288, 289, 290, 291, 292
|
| 1397 |
|
|
};
|
| 1398 |
|
|
#endif
|
| 1399 |
|
|
|
| 1400 |
|
|
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
| 1401 |
|
|
const unsigned char
|
| 1402 |
|
|
Parser::yyr1_[] =
|
| 1403 |
|
|
{
|
| 1404 |
|
|
0, 38, 39, 39, 39, 40, 40, 40, 40, 40,
|
| 1405 |
|
|
40, 40, 40, 41, 40, 40, 42, 42, 42, 42,
|
| 1406 |
|
|
43, 43, 43, 43, 44, 44, 44, 45, 45, 45,
|
| 1407 |
|
|
46, 46, 46, 47, 47, 47, 47
|
| 1408 |
|
|
};
|
| 1409 |
|
|
|
| 1410 |
|
|
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
| 1411 |
|
|
const unsigned char
|
| 1412 |
|
|
Parser::yyr2_[] =
|
| 1413 |
|
|
{
|
| 1414 |
|
|
0, 2, 0, 2, 1, 5, 3, 9, 2, 4,
|
| 1415 |
|
|
4, 4, 5, 0, 8, 3, 3, 3, 3, 1,
|
| 1416 |
|
|
3, 3, 3, 1, 1, 3, 1, 1, 1, 1,
|
| 1417 |
|
|
1, 3, 3, 3, 5, 3, 1
|
| 1418 |
|
|
};
|
| 1419 |
|
|
|
| 1420 |
|
|
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
| 1421 |
|
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
| 1422 |
|
|
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
| 1423 |
|
|
const char*
|
| 1424 |
|
|
const Parser::yytname_[] =
|
| 1425 |
|
|
{
|
| 1426 |
|
|
"$end", "error", "$undefined", "SHL", "SHR", "SCALAR", "RETURN", "EXIT",
|
| 1427 |
|
|
"EQUAL", "NOT_EQUAL", "GREATER_THAN", "LESS_THAN", "LESS_OR_EQUAL_THAN",
|
| 1428 |
|
|
"GREATER_OR_EQUAL_THAN", "IF", "ELSE", "OPEN_ROUND_BRACE",
|
| 1429 |
|
|
"CLOSE_ROUND_BRACE", "OPEN_BRACE", "CLOSE_BRACE", "ASSIGN", "ADD",
|
| 1430 |
|
|
"DECCONST", "HEXCONST", "BINCONST", "EOS", "MINUS", "IDENTIFIER",
|
| 1431 |
|
|
"COMMA", "OPEN_SQUARE_BRACE", "CLOSE_SQUARE_BRACE", "WHILE", "START",
|
| 1432 |
|
|
"BITWISE_AND", "BITWISE_OR", "COPY_DATA_BLOCK", "COPY_CODE_BLOCK",
|
| 1433 |
|
|
"BLOCK_TRANSFER_IN_PROGRESS", "$accept", "statement_list", "statement",
|
| 1434 |
|
|
"$@1", "expression", "term", "factor", "constant", "boolean_expression",
|
| 1435 |
|
|
"scalar_list", 0
|
| 1436 |
|
|
};
|
| 1437 |
|
|
#endif
|
| 1438 |
|
|
|
| 1439 |
|
|
#if YYDEBUG
|
| 1440 |
|
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
| 1441 |
|
|
const Parser::rhs_number_type
|
| 1442 |
|
|
Parser::yyrhs_[] =
|
| 1443 |
|
|
{
|
| 1444 |
|
|
39, 0, -1, -1, 39, 40, -1, 40, -1, 32,
|
| 1445 |
|
|
11, 45, 10, 25, -1, 5, 47, 25, -1, 35,
|
| 1446 |
|
|
11, 42, 28, 42, 28, 42, 10, 25, -1, 7,
|
| 1447 |
|
|
25, -1, 27, 26, 26, 25, -1, 27, 21, 21,
|
| 1448 |
|
|
25, -1, 27, 20, 42, 25, -1, 27, 21, 20,
|
| 1449 |
|
|
42, 25, -1, -1, 31, 41, 16, 46, 17, 18,
|
| 1450 |
|
|
39, 19, -1, 32, 27, 25, -1, 42, 21, 43,
|
| 1451 |
|
|
-1, 42, 34, 43, -1, 42, 26, 43, -1, 43,
|
| 1452 |
|
|
-1, 44, 3, 44, -1, 44, 4, 44, -1, 44,
|
| 1453 |
|
|
33, 44, -1, 44, -1, 27, -1, 16, 42, 17,
|
| 1454 |
|
|
-1, 45, -1, 22, -1, 23, -1, 24, -1, 37,
|
| 1455 |
|
|
-1, 42, 8, 42, -1, 42, 12, 42, -1, 27,
|
| 1456 |
|
|
28, 47, -1, 27, 20, 45, 28, 47, -1, 27,
|
| 1457 |
|
|
20, 45, -1, 27, -1
|
| 1458 |
|
|
};
|
| 1459 |
|
|
|
| 1460 |
|
|
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
| 1461 |
|
|
YYRHS. */
|
| 1462 |
|
|
const unsigned char
|
| 1463 |
|
|
Parser::yyprhs_[] =
|
| 1464 |
|
|
{
|
| 1465 |
|
|
0, 0, 3, 4, 7, 9, 15, 19, 29, 32,
|
| 1466 |
|
|
37, 42, 47, 53, 54, 63, 67, 71, 75, 79,
|
| 1467 |
|
|
81, 85, 89, 93, 95, 97, 101, 103, 105, 107,
|
| 1468 |
|
|
109, 111, 115, 119, 123, 129, 133
|
| 1469 |
|
|
};
|
| 1470 |
|
|
|
| 1471 |
|
|
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
| 1472 |
|
|
const unsigned short int
|
| 1473 |
|
|
Parser::yyrline_[] =
|
| 1474 |
|
|
{
|
| 1475 |
|
|
0, 148, 148, 150, 152, 157, 176, 178, 202, 214,
|
| 1476 |
|
|
236, 259, 272, 284, 284, 305, 315, 333, 348, 363,
|
| 1477 |
|
|
371, 387, 402, 417, 425, 430, 435, 464, 477, 488,
|
| 1478 |
|
|
503, 534, 554, 576, 588, 607, 629
|
| 1479 |
|
|
};
|
| 1480 |
|
|
|
| 1481 |
|
|
// Print the state stack on the debug stream.
|
| 1482 |
|
|
void
|
| 1483 |
|
|
Parser::yystack_print_ ()
|
| 1484 |
|
|
{
|
| 1485 |
|
|
*yycdebug_ << "Stack now";
|
| 1486 |
|
|
for (state_stack_type::const_iterator i = yystate_stack_.begin ();
|
| 1487 |
|
|
i != yystate_stack_.end (); ++i)
|
| 1488 |
|
|
*yycdebug_ << ' ' << *i;
|
| 1489 |
|
|
*yycdebug_ << std::endl;
|
| 1490 |
|
|
}
|
| 1491 |
|
|
|
| 1492 |
|
|
// Report on the debug stream that the rule \a yyrule is going to be reduced.
|
| 1493 |
|
|
void
|
| 1494 |
|
|
Parser::yy_reduce_print_ (int yyrule)
|
| 1495 |
|
|
{
|
| 1496 |
|
|
unsigned int yylno = yyrline_[yyrule];
|
| 1497 |
|
|
int yynrhs = yyr2_[yyrule];
|
| 1498 |
|
|
/* Print the symbols being reduced, and their result. */
|
| 1499 |
|
|
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
|
| 1500 |
|
|
<< " (line " << yylno << "):" << std::endl;
|
| 1501 |
|
|
/* The symbols being reduced. */
|
| 1502 |
|
|
for (int yyi = 0; yyi < yynrhs; yyi++)
|
| 1503 |
|
|
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
|
| 1504 |
|
|
yyrhs_[yyprhs_[yyrule] + yyi],
|
| 1505 |
|
|
&(yysemantic_stack_[(yynrhs) - (yyi + 1)]),
|
| 1506 |
|
|
&(yylocation_stack_[(yynrhs) - (yyi + 1)]));
|
| 1507 |
|
|
}
|
| 1508 |
|
|
#endif // YYDEBUG
|
| 1509 |
|
|
|
| 1510 |
|
|
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
| 1511 |
|
|
Parser::token_number_type
|
| 1512 |
|
|
Parser::yytranslate_ (int t)
|
| 1513 |
|
|
{
|
| 1514 |
|
|
static
|
| 1515 |
|
|
const token_number_type
|
| 1516 |
|
|
translate_table[] =
|
| 1517 |
|
|
{
|
| 1518 |
|
|
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1519 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1520 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1521 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1522 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1523 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1524 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1525 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1526 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1527 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1528 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1529 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1530 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1531 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1532 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1533 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1534 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1535 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1536 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1537 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1538 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1539 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1540 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1541 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1542 |
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| 1543 |
|
|
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
|
| 1544 |
|
|
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
| 1545 |
|
|
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
| 1546 |
|
|
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
|
| 1547 |
|
|
35, 36, 37
|
| 1548 |
|
|
};
|
| 1549 |
|
|
if ((unsigned int) t <= yyuser_token_number_max_)
|
| 1550 |
|
|
return translate_table[t];
|
| 1551 |
|
|
else
|
| 1552 |
|
|
return yyundef_token_;
|
| 1553 |
|
|
}
|
| 1554 |
|
|
|
| 1555 |
|
|
const int Parser::yyeof_ = 0;
|
| 1556 |
|
|
const int Parser::yylast_ = 113;
|
| 1557 |
|
|
const int Parser::yynnts_ = 10;
|
| 1558 |
|
|
const int Parser::yyempty_ = -2;
|
| 1559 |
|
|
const int Parser::yyfinal_ = 19;
|
| 1560 |
|
|
const int Parser::yyterror_ = 1;
|
| 1561 |
|
|
const int Parser::yyerrcode_ = 256;
|
| 1562 |
|
|
const int Parser::yyntokens_ = 38;
|
| 1563 |
|
|
|
| 1564 |
|
|
const unsigned int Parser::yyuser_token_number_max_ = 292;
|
| 1565 |
|
|
const Parser::token_number_type Parser::yyundef_token_ = 2;
|
| 1566 |
|
|
|
| 1567 |
|
|
|
| 1568 |
|
|
/* Line 1054 of lalr1.cc */
|
| 1569 |
|
|
#line 28 "parser.y"
|
| 1570 |
|
|
} // Theia
|
| 1571 |
|
|
|
| 1572 |
|
|
/* Line 1054 of lalr1.cc */
|
| 1573 |
|
|
#line 1574 "parser.tab.c"
|
| 1574 |
|
|
|
| 1575 |
|
|
|
| 1576 |
|
|
/* Line 1056 of lalr1.cc */
|
| 1577 |
|
|
#line 643 "parser.y"
|
| 1578 |
|
|
|
| 1579 |
|
|
|
| 1580 |
|
|
|
| 1581 |
|
|
|
| 1582 |
|
|
// Error function throws an exception (std::string) with the location and error message
|
| 1583 |
|
|
void Theia::Parser::error(const Theia::Parser::location_type &loc,
|
| 1584 |
|
|
const std::string &msg) {
|
| 1585 |
|
|
std::ostringstream ret;
|
| 1586 |
|
|
ret << "\ncp_compile -- Parser Error at " << loc << ": " << msg;
|
| 1587 |
|
|
throw ret.str();
|
| 1588 |
|
|
}
|
| 1589 |
|
|
|
| 1590 |
|
|
// Now that we have the Parser declared, we can declare the Scanner and implement
|
| 1591 |
|
|
// the yylex function
|
| 1592 |
|
|
#include "Scanner.h"
|
| 1593 |
|
|
static int yylex(Theia::Parser::semantic_type * yylval,
|
| 1594 |
|
|
Theia::Parser::location_type * yylloc,
|
| 1595 |
|
|
Theia::Scanner &scanner) {
|
| 1596 |
|
|
return scanner.yylex(yylval, yylloc);
|
| 1597 |
|
|
}
|
| 1598 |
|
|
|
| 1599 |
|
|
|