torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XdlParser.hpp
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 2.3. */
2 
3 /* Skeleton interface for Bison LALR(1) parsers in C++
4 
5  Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2, or (at your option)
10  any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA. */
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 #include <string>
41 #include <iostream>
42 #include "stack.hh"
43 
44 namespace torc
45 {
46  class position;
47  class location;
48 }
49 
50 /* First part of user declarations. */
51 #line 16 "parser.yy"
52 
53 
54 
55 // ------------------------------------------------------------------------------------------------
56 // -------------------------------------- C/C++ declarations --------------------------------------
57 // ------------------------------------------------------------------------------------------------
58 
59 
60 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
61 // $HeadURL: https://svn.east.isi.edu/torc/trunk/src/torc/physical/xdl/parser.yy $
62 // $Id: parser.yy 875 2011-10-07 00:34:34Z nsteiner $
63 
64 // This program is free software: you can redistribute it and/or modify it under the terms of the
65 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
66 // License, or (at your option) any later version.
67 //
68 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
69 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
70 // the GNU General Public License for more details.
71 //
72 // You should have received a copy of the GNU General Public License along with this program. If
73 // not, see <http://www.gnu.org/licenses/>.
74 
75 
80 #include <sstream>
81 #include <boost/algorithm/string/predicate.hpp>
82 #include <boost/smart_ptr.hpp>
83 
84 //#define YYPRINT(file, type, value) fprintf(file, "token [%d] \"%s\"", type, value);
85 
86 using std::string;
87 using namespace torc::physical;
88 
89 #define YYSTYPE std::string
90 
91 
92 #line 152 "parser.yy"
93 
94 
95 /// \brief Code to connect the bison parser in the importer to the flex scanner object.
96 /// \details This defines the yylex() function call to pull the next token from the current lexer
97 /// object in the importer.
98 #undef yylex
99 #define yylex xdl.lexer->lex
100 
101 
102 
103 /* Line 303 of lalr1.cc. */
104 #line 105 "XdlParser.hpp"
105 
106 #include "location.hh"
107 
108 /* Enabling traces. */
109 #ifndef YYDEBUG
110 # define YYDEBUG 0
111 #endif
112 
113 /* Enabling verbose error messages. */
114 #ifdef YYERROR_VERBOSE
115 # undef YYERROR_VERBOSE
116 # define YYERROR_VERBOSE 1
117 #else
118 # define YYERROR_VERBOSE 1
119 #endif
120 
121 /* Enabling the token table. */
122 #ifndef YYTOKEN_TABLE
123 # define YYTOKEN_TABLE 0
124 #endif
125 
126 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
127  If N is 0, then set CURRENT to the empty location which ends
128  the previous symbol: RHS[0] (always defined). */
129 
130 #ifndef YYLLOC_DEFAULT
131 # define YYLLOC_DEFAULT(Current, Rhs, N) \
132 do { \
133  if (N) \
134  { \
135  (Current).begin = (Rhs)[1].begin; \
136  (Current).end = (Rhs)[N].end; \
137  } \
138  else \
139  { \
140  (Current).begin = (Current).end = (Rhs)[0].end; \
141  } \
142 } while (false)
143 #endif
144 
145 namespace torc
146 {
147 
148  /// A Bison parser.
149  class XdlParser
150  {
151  public:
152  /// Symbol semantic values.
153 #ifndef YYSTYPE
154  typedef int semantic_type;
155 #else
157 #endif
158  /// Symbol locations.
160  /// Tokens.
161  struct token
162  {
163  /* Tokens. */
164  enum yytokentype {
165  END = 0,
166  EOL = 258,
167  DESIGN = 259,
168  MODULE = 260,
169  ENDMODULE = 261,
170  PORT = 262,
171  INST = 263,
172  NET = 264,
173  CFG = 265,
174  PLACED = 266,
175  UNPLACED = 267,
176  BONDED = 268,
177  UNBONDED = 269,
178  POWER = 270,
179  GROUND = 271,
180  INPIN = 272,
181  OUTPIN = 273,
182  PIP = 274,
184  STRING = 276,
185  CFGSETTING = 277,
186  CFGNAME = 278,
187  CFGVALUE = 279,
188  IDENTIFIER = 280,
189  SPEEDGRADE = 281,
190  XDLVERSION = 282,
191  BIDIRUNBUF = 283,
192  BIDIRUNIBUF = 284,
193  BIDIRBIBUF = 285,
194  UNIDIRBUF = 286,
195  WORD = 287,
196  CHAR = 288,
197  QUOTE = 289,
198  OBRACE = 290,
199  EBRACE = 291
200  };
201 
202  };
203  /// Token type.
205 
206  /// Build a parser object.
207  XdlParser (class XdlImporter& xdl_yyarg);
208  virtual ~XdlParser ();
209 
210  /// Parse.
211  /// \returns 0 iff parsing succeeded.
212  virtual int parse ();
213 
214  /// The current debugging stream.
215  std::ostream& debug_stream () const;
216  /// Set the current debugging stream.
217  void set_debug_stream (std::ostream &);
218 
219  /// Type for debugging levels.
220  typedef int debug_level_type;
221  /// The current debugging level.
222  debug_level_type debug_level () const;
223  /// Set the current debugging level.
225 
226  private:
227  /// Report a syntax error.
228  /// \param loc where the syntax error is found.
229  /// \param msg a description of the syntax error.
230  virtual void error (const location_type& loc, const std::string& msg);
231 
232  /// Generate an error message.
233  /// \param state the state where the error occurred.
234  /// \param tok the look-ahead token.
235  virtual std::string yysyntax_error_ (int yystate, int tok);
236 
237 #if YYDEBUG
238  /// \brief Report a symbol value on the debug stream.
239  /// \param yytype The token type.
240  /// \param yyvaluep Its semantic value.
241  /// \param yylocationp Its location.
242  virtual void yy_symbol_value_print_ (int yytype,
243  const semantic_type* yyvaluep,
244  const location_type* yylocationp);
245  /// \brief Report a symbol on the debug stream.
246  /// \param yytype The token type.
247  /// \param yyvaluep Its semantic value.
248  /// \param yylocationp Its location.
249  virtual void yy_symbol_print_ (int yytype,
250  const semantic_type* yyvaluep,
251  const location_type* yylocationp);
252 #endif /* ! YYDEBUG */
253 
254 
255  /// State numbers.
256  typedef int state_type;
257  /// State stack type.
259  /// Semantic value stack type.
261  /// location stack type.
263 
264  /// The state stack.
266  /// The semantic value stack.
268  /// The location stack.
270 
271  /// Internal symbol numbers.
272  typedef unsigned char token_number_type;
273  /* Tables. */
274  /// For a state, the index in \a yytable_ of its portion.
275  static const signed char yypact_[];
276  static const signed char yypact_ninf_;
277 
278  /// For a state, default rule to reduce.
279  /// Unless\a yytable_ specifies something else to do.
280  /// Zero means the default is an error.
281  static const unsigned char yydefact_[];
282 
283  static const signed char yypgoto_[];
284  static const short int yydefgoto_[];
285 
286  /// What to do in a state.
287  /// \a yytable_[yypact_[s]]: what to do in state \a s.
288  /// - if positive, shift that token.
289  /// - if negative, reduce the rule which number is the opposite.
290  /// - if zero, do what YYDEFACT says.
291  static const short int yytable_[];
292  static const signed char yytable_ninf_;
293 
294  static const short int yycheck_[];
295 
296  /// For a state, its accessing symbol.
297  static const unsigned char yystos_[];
298 
299  /// For a rule, its LHS.
300  static const unsigned char yyr1_[];
301  /// For a rule, its RHS length.
302  static const unsigned char yyr2_[];
303 
304 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
305  /// For a symbol, its name in clear.
306  static const char* const yytname_[];
307 #endif
308 
309 #if YYERROR_VERBOSE
310  /// Convert the symbol name \a n to a form suitable for a diagnostic.
311  virtual std::string yytnamerr_ (const char *n);
312 #endif
313 
314 #if YYDEBUG
315  /// A type to store symbol numbers and -1.
316  typedef signed char rhs_number_type;
317  /// A `-1'-separated list of the rules' RHS.
318  static const rhs_number_type yyrhs_[];
319  /// For each rule, the index of the first RHS symbol in \a yyrhs_.
320  static const unsigned short int yyprhs_[];
321  /// For each rule, its source line number.
322  static const unsigned short int yyrline_[];
323  /// For each scanner token number, its symbol number.
324  static const unsigned short int yytoken_number_[];
325  /// Report on the debug stream that the rule \a r is going to be reduced.
326  virtual void yy_reduce_print_ (int r);
327  /// Print the state stack on the debug stream.
328  virtual void yystack_print_ ();
329 #endif
330 
331  /// Convert a scanner token number \a t to a symbol number.
333 
334  /// \brief Reclaim the memory associated to a symbol.
335  /// \param yymsg Why this token is reclaimed.
336  /// \param yytype The symbol type.
337  /// \param yyvaluep Its semantic value.
338  /// \param yylocationp Its location.
339  inline void yydestruct_ (const char* yymsg,
340  int yytype,
341  semantic_type* yyvaluep,
342  location_type* yylocationp);
343 
344  /// Pop \a n symbols the three stacks.
345  inline void yypop_ (unsigned int n = 1);
346 
347  /* Constants. */
348  static const int yyeof_;
349  /* LAST_ -- Last index in TABLE_. */
350  static const int yylast_;
351  static const int yynnts_;
352  static const int yyempty_;
353  static const int yyfinal_;
354  static const int yyterror_;
355  static const int yyerrcode_;
356  static const int yyntokens_;
357  static const unsigned int yyuser_token_number_max_;
359 
360  /* Debugging. */
361  int yydebug_;
362  std::ostream* yycdebug_;
363 
364 
365  /* User arguments. */
366  class XdlImporter& xdl;
367  };
368 }
369 
370 
371 #endif /* ! defined PARSER_HEADER_H */
A Bison parser.
Definition: XdlParser.hpp:149
static const signed char yypact_ninf_
Definition: XdlParser.hpp:276
static const int yyfinal_
Definition: XdlParser.hpp:353
static const signed char yypact_[]
For a state, the index in yytable_ of its portion.
Definition: XdlParser.hpp:275
int debug_level_type
Type for debugging levels.
Definition: XdlParser.hpp:220
std::ostream * yycdebug_
Definition: XdlParser.hpp:362
static const unsigned char yystos_[]
For a state, its accessing symbol.
Definition: XdlParser.hpp:297
void yydestruct_(const char *yymsg, int yytype, semantic_type *yyvaluep, location_type *yylocationp)
Reclaim the memory associated to a symbol.
Definition: XdlParser.cpp:190
static const int yyterror_
Definition: XdlParser.hpp:354
static const char *const yytname_[]
For a symbol, its name in clear.
Definition: XdlParser.hpp:306
stack< location_type > location_stack_type
location stack type.
Definition: XdlParser.hpp:262
static const short int yycheck_[]
Definition: XdlParser.hpp:294
static const int yyntokens_
Definition: XdlParser.hpp:356
static const int yyempty_
Definition: XdlParser.hpp:352
virtual std::string yysyntax_error_(int yystate, int tok)
Definition: XdlParser.cpp:1097
Header for the DeviceDesignator class.
stack< semantic_type > semantic_stack_type
Semantic value stack type.
Definition: XdlParser.hpp:260
token::yytokentype token_type
Token type.
Definition: XdlParser.hpp:204
static const unsigned int yyuser_token_number_max_
Definition: XdlParser.hpp:357
stack< state_type > state_stack_type
State stack type.
Definition: XdlParser.hpp:258
unsigned char token_number_type
Internal symbol numbers.
Definition: XdlParser.hpp:272
#define YYSTYPE
Definition: XdlParser.hpp:89
void yypop_(unsigned int n=1)
Pop n symbols the three stacks.
Definition: XdlParser.cpp:208
virtual void error(const location_type &loc, const std::string &msg)
Definition: XdlParser.cpp:1525
std::string string
YYSTYPE semantic_type
Symbol semantic values.
Definition: XdlParser.hpp:156
Header for the XdlImporter class.
static const unsigned char yydefact_[]
Definition: XdlParser.hpp:281
static const int yyeof_
Definition: XdlParser.hpp:348
state_stack_type yystate_stack_
The state stack.
Definition: XdlParser.hpp:265
Header for torc::physical output stream helpers.
virtual std::string yytnamerr_(const char *n)
Convert the symbol name n to a form suitable for a diagnostic.
static const unsigned char yyr1_[]
For a rule, its LHS.
Definition: XdlParser.hpp:300
static const short int yydefgoto_[]
Definition: XdlParser.hpp:284
debug_level_type debug_level() const
The current debugging level.
Definition: XdlParser.cpp:229
static const unsigned char yyr2_[]
For a rule, its RHS length.
Definition: XdlParser.hpp:302
virtual int parse()
Definition: XdlParser.cpp:242
location_stack_type yylocation_stack_
The location stack.
Definition: XdlParser.hpp:269
location location_type
Symbol locations.
Definition: XdlParser.hpp:159
static const short int yytable_[]
Definition: XdlParser.hpp:291
void set_debug_stream(std::ostream &)
Set the current debugging stream.
Definition: XdlParser.cpp:222
XdlParser(class XdlImporter &xdl_yyarg)
Build a parser object.
Definition: XdlParser.cpp:147
static const token_number_type yyundef_token_
Definition: XdlParser.hpp:358
token_number_type yytranslate_(int t)
Convert a scanner token number t to a symbol number.
Definition: XdlParser.cpp:1459
Importer from XDL format into a physical design.
int state_type
State numbers.
Definition: XdlParser.hpp:256
virtual ~XdlParser()
Definition: XdlParser.cpp:154
static const int yylast_
Definition: XdlParser.hpp:350
static const signed char yypgoto_[]
Definition: XdlParser.hpp:283
class XdlImporter & xdl
Definition: XdlParser.hpp:366
static const int yynnts_
Definition: XdlParser.hpp:351
Header for the Factory class.
void set_debug_level(debug_level_type l)
Set the current debugging level.
Definition: XdlParser.cpp:235
std::ostream & debug_stream() const
The current debugging stream.
Definition: XdlParser.cpp:216
semantic_stack_type yysemantic_stack_
The semantic value stack.
Definition: XdlParser.hpp:267
static const signed char yytable_ninf_
Definition: XdlParser.hpp:292
static const int yyerrcode_
Definition: XdlParser.hpp:355