1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton interface for Bison LALR(1) parsers in C++
5 Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
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)
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.
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. */
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.
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
35 /* C++ LALR(1) parser skeleton written by Akim Demaille. */
37 #ifndef PARSER_HEADER_H
38 # define PARSER_HEADER_H
50 /* First part of user declarations. */
51 #line 25 "json_parser.yy"
54 #include "json_scanner.h"
55 #include "qjson_debug.h"
57 #include <QtCore/QByteArray>
58 #include <QtCore/QMap>
59 #include <QtCore/QString>
60 #include <QtCore/QVariant>
70 #define YYERROR_VERBOSE 1
73 /* Line 35 of lalr1.cc. */
74 #line 75 "json_parser.hh"
76 #include "location.hh"
78 /* Enabling traces. */
83 /* Enabling verbose error messages. */
84 #ifdef YYERROR_VERBOSE
85 # undef YYERROR_VERBOSE
86 # define YYERROR_VERBOSE 1
88 # define YYERROR_VERBOSE 1
91 /* Enabling the token table. */
93 # define YYTOKEN_TABLE 0
96 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
97 If N is 0, then set CURRENT to the empty location which ends
98 the previous symbol: RHS[0] (always defined). */
100 #ifndef YYLLOC_DEFAULT
101 # define YYLLOC_DEFAULT(Current, Rhs, N) \
105 (Current).begin = (Rhs)[1].begin; \
106 (Current).end = (Rhs)[N].end; \
110 (Current).begin = (Current).end = (Rhs)[0].end; \
122 /// Symbol semantic values.
124 typedef int semantic_type;
126 typedef YYSTYPE semantic_type;
128 /// Symbol locations.
129 typedef location location_type;
136 CURLY_BRACKET_OPEN = 1,
137 CURLY_BRACKET_CLOSE = 2,
138 SQUARE_BRACKET_OPEN = 3,
139 SQUARE_BRACKET_CLOSE = 4,
158 typedef token::yytokentype token_type;
160 /// Build a parser object.
161 json_parser (QJson::ParserPrivate* driver_yyarg);
162 virtual ~json_parser ();
165 /// \returns 0 iff parsing succeeded.
166 virtual int parse ();
168 /// The current debugging stream.
169 std::ostream& debug_stream () const;
170 /// Set the current debugging stream.
171 void set_debug_stream (std::ostream &);
173 /// Type for debugging levels.
174 typedef int debug_level_type;
175 /// The current debugging level.
176 debug_level_type debug_level () const;
177 /// Set the current debugging level.
178 void set_debug_level (debug_level_type l);
181 /// Report a syntax error.
182 /// \param loc where the syntax error is found.
183 /// \param msg a description of the syntax error.
184 virtual void error (const location_type& loc, const std::string& msg);
186 /// Generate an error message.
187 /// \param state the state where the error occurred.
188 /// \param tok the look-ahead token.
189 virtual std::string yysyntax_error_ (int yystate, int tok);
192 /// \brief Report a symbol value on the debug stream.
193 /// \param yytype The token type.
194 /// \param yyvaluep Its semantic value.
195 /// \param yylocationp Its location.
196 virtual void yy_symbol_value_print_ (int yytype,
197 const semantic_type* yyvaluep,
198 const location_type* yylocationp);
199 /// \brief Report a symbol on the debug stream.
200 /// \param yytype The token type.
201 /// \param yyvaluep Its semantic value.
202 /// \param yylocationp Its location.
203 virtual void yy_symbol_print_ (int yytype,
204 const semantic_type* yyvaluep,
205 const location_type* yylocationp);
206 #endif /* ! YYDEBUG */
210 typedef int state_type;
211 /// State stack type.
212 typedef stack<state_type> state_stack_type;
213 /// Semantic value stack type.
214 typedef stack<semantic_type> semantic_stack_type;
215 /// location stack type.
216 typedef stack<location_type> location_stack_type;
219 state_stack_type yystate_stack_;
220 /// The semantic value stack.
221 semantic_stack_type yysemantic_stack_;
222 /// The location stack.
223 location_stack_type yylocation_stack_;
225 /// Internal symbol numbers.
226 typedef unsigned char token_number_type;
228 /// For a state, the index in \a yytable_ of its portion.
229 static const signed char yypact_[];
230 static const signed char yypact_ninf_;
232 /// For a state, default rule to reduce.
233 /// Unless\a yytable_ specifies something else to do.
234 /// Zero means the default is an error.
235 static const unsigned char yydefact_[];
237 static const signed char yypgoto_[];
238 static const signed char yydefgoto_[];
240 /// What to do in a state.
241 /// \a yytable_[yypact_[s]]: what to do in state \a s.
242 /// - if positive, shift that token.
243 /// - if negative, reduce the rule which number is the opposite.
244 /// - if zero, do what YYDEFACT says.
245 static const unsigned char yytable_[];
246 static const signed char yytable_ninf_;
248 static const signed char yycheck_[];
250 /// For a state, its accessing symbol.
251 static const unsigned char yystos_[];
253 /// For a rule, its LHS.
254 static const unsigned char yyr1_[];
255 /// For a rule, its RHS length.
256 static const unsigned char yyr2_[];
258 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
259 /// For a symbol, its name in clear.
260 static const char* const yytname_[];
264 /// Convert the symbol name \a n to a form suitable for a diagnostic.
265 virtual std::string yytnamerr_ (const char *n);
269 /// A type to store symbol numbers and -1.
270 typedef signed char rhs_number_type;
271 /// A `-1'-separated list of the rules' RHS.
272 static const rhs_number_type yyrhs_[];
273 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
274 static const unsigned char yyprhs_[];
275 /// For each rule, its source line number.
276 static const unsigned char yyrline_[];
277 /// For each scanner token number, its symbol number.
278 static const unsigned short int yytoken_number_[];
279 /// Report on the debug stream that the rule \a r is going to be reduced.
280 virtual void yy_reduce_print_ (int r);
281 /// Print the state stack on the debug stream.
282 virtual void yystack_print_ ();
285 /// Convert a scanner token number \a t to a symbol number.
286 token_number_type yytranslate_ (int t);
288 /// \brief Reclaim the memory associated to a symbol.
289 /// \param yymsg Why this token is reclaimed.
290 /// \param yytype The symbol type.
291 /// \param yyvaluep Its semantic value.
292 /// \param yylocationp Its location.
293 inline void yydestruct_ (const char* yymsg,
295 semantic_type* yyvaluep,
296 location_type* yylocationp);
298 /// Pop \a n symbols the three stacks.
299 inline void yypop_ (unsigned int n = 1);
302 static const int yyeof_;
303 /* LAST_ -- Last index in TABLE_. */
304 static const int yylast_;
305 static const int yynnts_;
306 static const int yyempty_;
307 static const int yyfinal_;
308 static const int yyterror_;
309 static const int yyerrcode_;
310 static const int yyntokens_;
311 static const unsigned int yyuser_token_number_max_;
312 static const token_number_type yyundef_token_;
316 std::ostream* yycdebug_;
319 /* User arguments. */
320 QJson::ParserPrivate* driver;
325 #endif /* ! defined PARSER_HEADER_H */