| 1 |
216 |
diegovalve |
|
| 2 |
|
|
/* A Bison parser, made by GNU Bison 2.4.1. */
|
| 3 |
|
|
|
| 4 |
|
|
/* Skeleton interface 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 |
|
|
/* C++ LALR(1) parser skeleton written by Akim Demaille. */
|
| 36 |
|
|
|
| 37 |
|
|
#ifndef PARSER_HEADER_H
|
| 38 |
|
|
# define PARSER_HEADER_H
|
| 39 |
|
|
|
| 40 |
|
|
/* "%code requires" blocks. */
|
| 41 |
|
|
|
| 42 |
|
|
/* Line 35 of lalr1.cc */
|
| 43 |
|
|
#line 36 "parser.y"
|
| 44 |
|
|
|
| 45 |
|
|
#include <string>
|
| 46 |
|
|
#include <sstream>
|
| 47 |
|
|
#include <iomanip>
|
| 48 |
|
|
#include <bitset>
|
| 49 |
|
|
#include <map>
|
| 50 |
|
|
#include "Instruction.h"
|
| 51 |
|
|
#include <vector>
|
| 52 |
|
|
|
| 53 |
|
|
|
| 54 |
|
|
// We want to return a string
|
| 55 |
|
|
#define YYSTYPE std::string
|
| 56 |
|
|
|
| 57 |
|
|
|
| 58 |
|
|
namespace Theia
|
| 59 |
|
|
{
|
| 60 |
|
|
// Forward-declare the Scanner class; the Parser needs to be assigned a
|
| 61 |
|
|
// Scanner, but the Scanner can't be declared without the Parser
|
| 62 |
|
|
class Scanner;
|
| 63 |
|
|
|
| 64 |
|
|
// We use a map to store the INI data
|
| 65 |
|
|
typedef std::map<std::string, std::map<std::string, std::string> > mapData;
|
| 66 |
|
|
|
| 67 |
|
|
|
| 68 |
|
|
|
| 69 |
|
|
|
| 70 |
|
|
|
| 71 |
|
|
}
|
| 72 |
|
|
|
| 73 |
|
|
|
| 74 |
|
|
|
| 75 |
|
|
|
| 76 |
|
|
/* Line 35 of lalr1.cc */
|
| 77 |
|
|
#line 78 "parser.tab.h"
|
| 78 |
|
|
|
| 79 |
|
|
|
| 80 |
|
|
#include <string>
|
| 81 |
|
|
#include <iostream>
|
| 82 |
|
|
#include "stack.hh"
|
| 83 |
|
|
|
| 84 |
|
|
|
| 85 |
|
|
/* Line 35 of lalr1.cc */
|
| 86 |
|
|
#line 28 "parser.y"
|
| 87 |
|
|
namespace Theia {
|
| 88 |
|
|
|
| 89 |
|
|
/* Line 35 of lalr1.cc */
|
| 90 |
|
|
#line 91 "parser.tab.h"
|
| 91 |
|
|
class position;
|
| 92 |
|
|
class location;
|
| 93 |
|
|
|
| 94 |
|
|
/* Line 35 of lalr1.cc */
|
| 95 |
|
|
#line 28 "parser.y"
|
| 96 |
|
|
} // Theia
|
| 97 |
|
|
|
| 98 |
|
|
/* Line 35 of lalr1.cc */
|
| 99 |
|
|
#line 100 "parser.tab.h"
|
| 100 |
|
|
|
| 101 |
|
|
#include "location.hh"
|
| 102 |
|
|
|
| 103 |
|
|
/* Enabling traces. */
|
| 104 |
|
|
#ifndef YYDEBUG
|
| 105 |
|
|
# define YYDEBUG 0
|
| 106 |
|
|
#endif
|
| 107 |
|
|
|
| 108 |
|
|
/* Enabling verbose error messages. */
|
| 109 |
|
|
#ifdef YYERROR_VERBOSE
|
| 110 |
|
|
# undef YYERROR_VERBOSE
|
| 111 |
|
|
# define YYERROR_VERBOSE 1
|
| 112 |
|
|
#else
|
| 113 |
|
|
# define YYERROR_VERBOSE 1
|
| 114 |
|
|
#endif
|
| 115 |
|
|
|
| 116 |
|
|
/* Enabling the token table. */
|
| 117 |
|
|
#ifndef YYTOKEN_TABLE
|
| 118 |
|
|
# define YYTOKEN_TABLE 0
|
| 119 |
|
|
#endif
|
| 120 |
|
|
|
| 121 |
|
|
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
| 122 |
|
|
If N is 0, then set CURRENT to the empty location which ends
|
| 123 |
|
|
the previous symbol: RHS[0] (always defined). */
|
| 124 |
|
|
|
| 125 |
|
|
#ifndef YYLLOC_DEFAULT
|
| 126 |
|
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
| 127 |
|
|
do { \
|
| 128 |
|
|
if (N) \
|
| 129 |
|
|
{ \
|
| 130 |
|
|
(Current).begin = (Rhs)[1].begin; \
|
| 131 |
|
|
(Current).end = (Rhs)[N].end; \
|
| 132 |
|
|
} \
|
| 133 |
|
|
else \
|
| 134 |
|
|
{ \
|
| 135 |
|
|
(Current).begin = (Current).end = (Rhs)[0].end; \
|
| 136 |
|
|
} \
|
| 137 |
|
|
} while (false)
|
| 138 |
|
|
#endif
|
| 139 |
|
|
|
| 140 |
|
|
|
| 141 |
|
|
/* Line 35 of lalr1.cc */
|
| 142 |
|
|
#line 28 "parser.y"
|
| 143 |
|
|
namespace Theia {
|
| 144 |
|
|
|
| 145 |
|
|
/* Line 35 of lalr1.cc */
|
| 146 |
|
|
#line 147 "parser.tab.h"
|
| 147 |
|
|
|
| 148 |
|
|
/// A Bison parser.
|
| 149 |
|
|
class Parser
|
| 150 |
|
|
{
|
| 151 |
|
|
public:
|
| 152 |
|
|
/// Symbol semantic values.
|
| 153 |
|
|
#ifndef YYSTYPE
|
| 154 |
|
|
typedef int semantic_type;
|
| 155 |
|
|
#else
|
| 156 |
|
|
typedef YYSTYPE semantic_type;
|
| 157 |
|
|
#endif
|
| 158 |
|
|
/// Symbol locations.
|
| 159 |
|
|
typedef location location_type;
|
| 160 |
|
|
/// Tokens.
|
| 161 |
|
|
struct token
|
| 162 |
|
|
{
|
| 163 |
|
|
/* Tokens. */
|
| 164 |
|
|
enum yytokentype {
|
| 165 |
|
|
SHL = 258,
|
| 166 |
|
|
SHR = 259,
|
| 167 |
|
|
SCALAR = 260,
|
| 168 |
|
|
RETURN = 261,
|
| 169 |
|
|
EXIT = 262,
|
| 170 |
|
|
EQUAL = 263,
|
| 171 |
|
|
NOT_EQUAL = 264,
|
| 172 |
|
|
GREATER_THAN = 265,
|
| 173 |
|
|
LESS_THAN = 266,
|
| 174 |
|
|
LESS_OR_EQUAL_THAN = 267,
|
| 175 |
|
|
GREATER_OR_EQUAL_THAN = 268,
|
| 176 |
|
|
IF = 269,
|
| 177 |
|
|
ELSE = 270,
|
| 178 |
|
|
OPEN_ROUND_BRACE = 271,
|
| 179 |
|
|
CLOSE_ROUND_BRACE = 272,
|
| 180 |
|
|
OPEN_BRACE = 273,
|
| 181 |
|
|
CLOSE_BRACE = 274,
|
| 182 |
|
|
ASSIGN = 275,
|
| 183 |
|
|
ADD = 276,
|
| 184 |
|
|
DECCONST = 277,
|
| 185 |
|
|
HEXCONST = 278,
|
| 186 |
|
|
BINCONST = 279,
|
| 187 |
|
|
EOS = 280,
|
| 188 |
|
|
MINUS = 281,
|
| 189 |
|
|
IDENTIFIER = 282,
|
| 190 |
|
|
COMMA = 283,
|
| 191 |
|
|
OPEN_SQUARE_BRACE = 284,
|
| 192 |
|
|
CLOSE_SQUARE_BRACE = 285,
|
| 193 |
|
|
WHILE = 286,
|
| 194 |
|
|
START = 287,
|
| 195 |
|
|
BITWISE_AND = 288,
|
| 196 |
|
|
BITWISE_OR = 289,
|
| 197 |
|
|
COPY_DATA_BLOCK = 290,
|
| 198 |
|
|
COPY_CODE_BLOCK = 291,
|
| 199 |
|
|
BLOCK_TRANSFER_IN_PROGRESS = 292
|
| 200 |
|
|
};
|
| 201 |
|
|
|
| 202 |
|
|
};
|
| 203 |
|
|
/// Token type.
|
| 204 |
|
|
typedef token::yytokentype token_type;
|
| 205 |
|
|
|
| 206 |
|
|
/// Build a parser object.
|
| 207 |
|
|
Parser (Theia::Scanner &scanner_yyarg, std::map<std::string,unsigned int> & mSymbolMap_yyarg, std::vector< CControlInstruction > &mInstructions_yyarg, bool &mGenerateFixedPointArithmetic_yyarg);
|
| 208 |
|
|
virtual ~Parser ();
|
| 209 |
|
|
|
| 210 |
|
|
/// Parse.
|
| 211 |
|
|
/// \returns 0 iff parsing succeeded.
|
| 212 |
|
|
virtual int parse ();
|
| 213 |
|
|
|
| 214 |
|
|
#if YYDEBUG
|
| 215 |
|
|
/// The current debugging stream.
|
| 216 |
|
|
std::ostream& debug_stream () const;
|
| 217 |
|
|
/// Set the current debugging stream.
|
| 218 |
|
|
void set_debug_stream (std::ostream &);
|
| 219 |
|
|
|
| 220 |
|
|
/// Type for debugging levels.
|
| 221 |
|
|
typedef int debug_level_type;
|
| 222 |
|
|
/// The current debugging level.
|
| 223 |
|
|
debug_level_type debug_level () const;
|
| 224 |
|
|
/// Set the current debugging level.
|
| 225 |
|
|
void set_debug_level (debug_level_type l);
|
| 226 |
|
|
#endif
|
| 227 |
|
|
|
| 228 |
|
|
private:
|
| 229 |
|
|
/// Report a syntax error.
|
| 230 |
|
|
/// \param loc where the syntax error is found.
|
| 231 |
|
|
/// \param msg a description of the syntax error.
|
| 232 |
|
|
virtual void error (const location_type& loc, const std::string& msg);
|
| 233 |
|
|
|
| 234 |
|
|
/// Generate an error message.
|
| 235 |
|
|
/// \param state the state where the error occurred.
|
| 236 |
|
|
/// \param tok the lookahead token.
|
| 237 |
|
|
virtual std::string yysyntax_error_ (int yystate, int tok);
|
| 238 |
|
|
|
| 239 |
|
|
#if YYDEBUG
|
| 240 |
|
|
/// \brief Report a symbol value on the debug stream.
|
| 241 |
|
|
/// \param yytype The token type.
|
| 242 |
|
|
/// \param yyvaluep Its semantic value.
|
| 243 |
|
|
/// \param yylocationp Its location.
|
| 244 |
|
|
virtual void yy_symbol_value_print_ (int yytype,
|
| 245 |
|
|
const semantic_type* yyvaluep,
|
| 246 |
|
|
const location_type* yylocationp);
|
| 247 |
|
|
/// \brief Report a symbol on the debug stream.
|
| 248 |
|
|
/// \param yytype The token type.
|
| 249 |
|
|
/// \param yyvaluep Its semantic value.
|
| 250 |
|
|
/// \param yylocationp Its location.
|
| 251 |
|
|
virtual void yy_symbol_print_ (int yytype,
|
| 252 |
|
|
const semantic_type* yyvaluep,
|
| 253 |
|
|
const location_type* yylocationp);
|
| 254 |
|
|
#endif
|
| 255 |
|
|
|
| 256 |
|
|
|
| 257 |
|
|
/// State numbers.
|
| 258 |
|
|
typedef int state_type;
|
| 259 |
|
|
/// State stack type.
|
| 260 |
|
|
typedef stack<state_type> state_stack_type;
|
| 261 |
|
|
/// Semantic value stack type.
|
| 262 |
|
|
typedef stack<semantic_type> semantic_stack_type;
|
| 263 |
|
|
/// location stack type.
|
| 264 |
|
|
typedef stack<location_type> location_stack_type;
|
| 265 |
|
|
|
| 266 |
|
|
/// The state stack.
|
| 267 |
|
|
state_stack_type yystate_stack_;
|
| 268 |
|
|
/// The semantic value stack.
|
| 269 |
|
|
semantic_stack_type yysemantic_stack_;
|
| 270 |
|
|
/// The location stack.
|
| 271 |
|
|
location_stack_type yylocation_stack_;
|
| 272 |
|
|
|
| 273 |
|
|
/// Internal symbol numbers.
|
| 274 |
|
|
typedef unsigned char token_number_type;
|
| 275 |
|
|
/* Tables. */
|
| 276 |
|
|
/// For a state, the index in \a yytable_ of its portion.
|
| 277 |
|
|
static const signed char yypact_[];
|
| 278 |
|
|
static const signed char yypact_ninf_;
|
| 279 |
|
|
|
| 280 |
|
|
/// For a state, default rule to reduce.
|
| 281 |
|
|
/// Unless\a yytable_ specifies something else to do.
|
| 282 |
|
|
/// Zero means the default is an error.
|
| 283 |
|
|
static const unsigned char yydefact_[];
|
| 284 |
|
|
|
| 285 |
|
|
static const signed char yypgoto_[];
|
| 286 |
|
|
static const signed char yydefgoto_[];
|
| 287 |
|
|
|
| 288 |
|
|
/// What to do in a state.
|
| 289 |
|
|
/// \a yytable_[yypact_[s]]: what to do in state \a s.
|
| 290 |
|
|
/// - if positive, shift that token.
|
| 291 |
|
|
/// - if negative, reduce the rule which number is the opposite.
|
| 292 |
|
|
/// - if zero, do what YYDEFACT says.
|
| 293 |
|
|
static const unsigned char yytable_[];
|
| 294 |
|
|
static const signed char yytable_ninf_;
|
| 295 |
|
|
|
| 296 |
|
|
static const unsigned char yycheck_[];
|
| 297 |
|
|
|
| 298 |
|
|
/// For a state, its accessing symbol.
|
| 299 |
|
|
static const unsigned char yystos_[];
|
| 300 |
|
|
|
| 301 |
|
|
/// For a rule, its LHS.
|
| 302 |
|
|
static const unsigned char yyr1_[];
|
| 303 |
|
|
/// For a rule, its RHS length.
|
| 304 |
|
|
static const unsigned char yyr2_[];
|
| 305 |
|
|
|
| 306 |
|
|
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
| 307 |
|
|
/// For a symbol, its name in clear.
|
| 308 |
|
|
static const char* const yytname_[];
|
| 309 |
|
|
#endif
|
| 310 |
|
|
|
| 311 |
|
|
#if YYERROR_VERBOSE
|
| 312 |
|
|
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
| 313 |
|
|
virtual std::string yytnamerr_ (const char *n);
|
| 314 |
|
|
#endif
|
| 315 |
|
|
|
| 316 |
|
|
#if YYDEBUG
|
| 317 |
|
|
/// A type to store symbol numbers and -1.
|
| 318 |
|
|
typedef signed char rhs_number_type;
|
| 319 |
|
|
/// A `-1'-separated list of the rules' RHS.
|
| 320 |
|
|
static const rhs_number_type yyrhs_[];
|
| 321 |
|
|
/// For each rule, the index of the first RHS symbol in \a yyrhs_.
|
| 322 |
|
|
static const unsigned char yyprhs_[];
|
| 323 |
|
|
/// For each rule, its source line number.
|
| 324 |
|
|
static const unsigned short int yyrline_[];
|
| 325 |
|
|
/// For each scanner token number, its symbol number.
|
| 326 |
|
|
static const unsigned short int yytoken_number_[];
|
| 327 |
|
|
/// Report on the debug stream that the rule \a r is going to be reduced.
|
| 328 |
|
|
virtual void yy_reduce_print_ (int r);
|
| 329 |
|
|
/// Print the state stack on the debug stream.
|
| 330 |
|
|
virtual void yystack_print_ ();
|
| 331 |
|
|
|
| 332 |
|
|
/* Debugging. */
|
| 333 |
|
|
int yydebug_;
|
| 334 |
|
|
std::ostream* yycdebug_;
|
| 335 |
|
|
#endif
|
| 336 |
|
|
|
| 337 |
|
|
/// Convert a scanner token number \a t to a symbol number.
|
| 338 |
|
|
token_number_type yytranslate_ (int t);
|
| 339 |
|
|
|
| 340 |
|
|
/// \brief Reclaim the memory associated to a symbol.
|
| 341 |
|
|
/// \param yymsg Why this token is reclaimed.
|
| 342 |
|
|
/// \param yytype The symbol type.
|
| 343 |
|
|
/// \param yyvaluep Its semantic value.
|
| 344 |
|
|
/// \param yylocationp Its location.
|
| 345 |
|
|
inline void yydestruct_ (const char* yymsg,
|
| 346 |
|
|
int yytype,
|
| 347 |
|
|
semantic_type* yyvaluep,
|
| 348 |
|
|
location_type* yylocationp);
|
| 349 |
|
|
|
| 350 |
|
|
/// Pop \a n symbols the three stacks.
|
| 351 |
|
|
inline void yypop_ (unsigned int n = 1);
|
| 352 |
|
|
|
| 353 |
|
|
/* Constants. */
|
| 354 |
|
|
static const int yyeof_;
|
| 355 |
|
|
/* LAST_ -- Last index in TABLE_. */
|
| 356 |
|
|
static const int yylast_;
|
| 357 |
|
|
static const int yynnts_;
|
| 358 |
|
|
static const int yyempty_;
|
| 359 |
|
|
static const int yyfinal_;
|
| 360 |
|
|
static const int yyterror_;
|
| 361 |
|
|
static const int yyerrcode_;
|
| 362 |
|
|
static const int yyntokens_;
|
| 363 |
|
|
static const unsigned int yyuser_token_number_max_;
|
| 364 |
|
|
static const token_number_type yyundef_token_;
|
| 365 |
|
|
|
| 366 |
|
|
/* User arguments. */
|
| 367 |
|
|
Theia::Scanner &scanner;
|
| 368 |
|
|
std::map<std::string,unsigned int> & mSymbolMap;
|
| 369 |
|
|
std::vector< CControlInstruction > &mInstructions;
|
| 370 |
|
|
bool &mGenerateFixedPointArithmetic;
|
| 371 |
|
|
};
|
| 372 |
|
|
|
| 373 |
|
|
/* Line 35 of lalr1.cc */
|
| 374 |
|
|
#line 28 "parser.y"
|
| 375 |
|
|
} // Theia
|
| 376 |
|
|
|
| 377 |
|
|
/* Line 35 of lalr1.cc */
|
| 378 |
|
|
#line 379 "parser.tab.h"
|
| 379 |
|
|
|
| 380 |
|
|
|
| 381 |
|
|
|
| 382 |
|
|
#endif /* ! defined PARSER_HEADER_H */
|