]> git.cworth.org Git - apitrace/blob - thirdparty/qjson/json_parser.hh
Bundle QJSON sources.
[apitrace] / thirdparty / qjson / json_parser.hh
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 yy
45 {
46   class position;
47   class location;
48 }
49
50 /* First part of user declarations.  */
51 #line 25 "json_parser.yy"
52
53   #include "parser_p.h"
54   #include "json_scanner.h"
55   #include "qjson_debug.h"
56
57   #include <QtCore/QByteArray>
58   #include <QtCore/QMap>
59   #include <QtCore/QString>
60   #include <QtCore/QVariant>
61
62   class JSonScanner;
63
64   namespace QJson {
65     class Parser;
66   }
67
68   #define YYERROR_VERBOSE 1
69
70
71 /* Line 303 of lalr1.cc.  */
72 #line 73 "json_parser.hh"
73
74 #include "location.hh"
75
76 /* Enabling traces.  */
77 #ifndef YYDEBUG
78 # define YYDEBUG 1
79 #endif
80
81 /* Enabling verbose error messages.  */
82 #ifdef YYERROR_VERBOSE
83 # undef YYERROR_VERBOSE
84 # define YYERROR_VERBOSE 1
85 #else
86 # define YYERROR_VERBOSE 1
87 #endif
88
89 /* Enabling the token table.  */
90 #ifndef YYTOKEN_TABLE
91 # define YYTOKEN_TABLE 0
92 #endif
93
94 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
95    If N is 0, then set CURRENT to the empty location which ends
96    the previous symbol: RHS[0] (always defined).  */
97
98 #ifndef YYLLOC_DEFAULT
99 # define YYLLOC_DEFAULT(Current, Rhs, N)                \
100 do {                                                    \
101   if (N)                                                \
102     {                                                   \
103       (Current).begin = (Rhs)[1].begin;                 \
104       (Current).end   = (Rhs)[N].end;                   \
105     }                                                   \
106   else                                                  \
107     {                                                   \
108       (Current).begin = (Current).end = (Rhs)[0].end;   \
109     }                                                   \
110 } while (false)
111 #endif
112
113 namespace yy
114 {
115
116   /// A Bison parser.
117   class json_parser
118   {
119   public:
120     /// Symbol semantic values.
121 #ifndef YYSTYPE
122     typedef int semantic_type;
123 #else
124     typedef YYSTYPE semantic_type;
125 #endif
126     /// Symbol locations.
127     typedef location location_type;
128     /// Tokens.
129     struct token
130     {
131       /* Tokens.  */
132    enum yytokentype {
133      END = 0,
134      CURLY_BRACKET_OPEN = 1,
135      CURLY_BRACKET_CLOSE = 2,
136      SQUARE_BRACKET_OPEN = 3,
137      SQUARE_BRACKET_CLOSE = 4,
138      COLON = 5,
139      COMMA = 6,
140      MINUS = 7,
141      DOT = 8,
142      DIGIT = 9,
143      E = 10,
144      TRUE_VAL = 11,
145      FALSE_VAL = 12,
146      NULL_VAL = 13,
147      QUOTMARKOPEN = 14,
148      QUOTMARKCLOSE = 15,
149      STRING = 16
150    };
151
152     };
153     /// Token type.
154     typedef token::yytokentype token_type;
155
156     /// Build a parser object.
157     json_parser (QJson::ParserPrivate* driver_yyarg);
158     virtual ~json_parser ();
159
160     /// Parse.
161     /// \returns  0 iff parsing succeeded.
162     virtual int parse ();
163
164     /// The current debugging stream.
165     std::ostream& debug_stream () const;
166     /// Set the current debugging stream.
167     void set_debug_stream (std::ostream &);
168
169     /// Type for debugging levels.
170     typedef int debug_level_type;
171     /// The current debugging level.
172     debug_level_type debug_level () const;
173     /// Set the current debugging level.
174     void set_debug_level (debug_level_type l);
175
176   private:
177     /// Report a syntax error.
178     /// \param loc    where the syntax error is found.
179     /// \param msg    a description of the syntax error.
180     virtual void error (const location_type& loc, const std::string& msg);
181
182     /// Generate an error message.
183     /// \param state   the state where the error occurred.
184     /// \param tok     the look-ahead token.
185     virtual std::string yysyntax_error_ (int yystate, int tok);
186
187 #if YYDEBUG
188     /// \brief Report a symbol value on the debug stream.
189     /// \param yytype       The token type.
190     /// \param yyvaluep     Its semantic value.
191     /// \param yylocationp  Its location.
192     virtual void yy_symbol_value_print_ (int yytype,
193                                          const semantic_type* yyvaluep,
194                                          const location_type* yylocationp);
195     /// \brief Report a symbol on the debug stream.
196     /// \param yytype       The token type.
197     /// \param yyvaluep     Its semantic value.
198     /// \param yylocationp  Its location.
199     virtual void yy_symbol_print_ (int yytype,
200                                    const semantic_type* yyvaluep,
201                                    const location_type* yylocationp);
202 #endif /* ! YYDEBUG */
203
204
205     /// State numbers.
206     typedef int state_type;
207     /// State stack type.
208     typedef stack<state_type>    state_stack_type;
209     /// Semantic value stack type.
210     typedef stack<semantic_type> semantic_stack_type;
211     /// location stack type.
212     typedef stack<location_type> location_stack_type;
213
214     /// The state stack.
215     state_stack_type yystate_stack_;
216     /// The semantic value stack.
217     semantic_stack_type yysemantic_stack_;
218     /// The location stack.
219     location_stack_type yylocation_stack_;
220
221     /// Internal symbol numbers.
222     typedef unsigned char token_number_type;
223     /* Tables.  */
224     /// For a state, the index in \a yytable_ of its portion.
225     static const signed char yypact_[];
226     static const signed char yypact_ninf_;
227
228     /// For a state, default rule to reduce.
229     /// Unless\a  yytable_ specifies something else to do.
230     /// Zero means the default is an error.
231     static const unsigned char yydefact_[];
232
233     static const signed char yypgoto_[];
234     static const signed char yydefgoto_[];
235
236     /// What to do in a state.
237     /// \a yytable_[yypact_[s]]: what to do in state \a s.
238     /// - if positive, shift that token.
239     /// - if negative, reduce the rule which number is the opposite.
240     /// - if zero, do what YYDEFACT says.
241     static const unsigned char yytable_[];
242     static const signed char yytable_ninf_;
243
244     static const unsigned char yycheck_[];
245
246     /// For a state, its accessing symbol.
247     static const unsigned char yystos_[];
248
249     /// For a rule, its LHS.
250     static const unsigned char yyr1_[];
251     /// For a rule, its RHS length.
252     static const unsigned char yyr2_[];
253
254 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
255     /// For a symbol, its name in clear.
256     static const char* const yytname_[];
257 #endif
258
259 #if YYERROR_VERBOSE
260     /// Convert the symbol name \a n to a form suitable for a diagnostic.
261     virtual std::string yytnamerr_ (const char *n);
262 #endif
263
264 #if YYDEBUG
265     /// A type to store symbol numbers and -1.
266     typedef signed char rhs_number_type;
267     /// A `-1'-separated list of the rules' RHS.
268     static const rhs_number_type yyrhs_[];
269     /// For each rule, the index of the first RHS symbol in \a yyrhs_.
270     static const unsigned char yyprhs_[];
271     /// For each rule, its source line number.
272     static const unsigned char yyrline_[];
273     /// For each scanner token number, its symbol number.
274     static const unsigned short int yytoken_number_[];
275     /// Report on the debug stream that the rule \a r is going to be reduced.
276     virtual void yy_reduce_print_ (int r);
277     /// Print the state stack on the debug stream.
278     virtual void yystack_print_ ();
279 #endif
280
281     /// Convert a scanner token number \a t to a symbol number.
282     token_number_type yytranslate_ (int t);
283
284     /// \brief Reclaim the memory associated to a symbol.
285     /// \param yymsg        Why this token is reclaimed.
286     /// \param yytype       The symbol type.
287     /// \param yyvaluep     Its semantic value.
288     /// \param yylocationp  Its location.
289     inline void yydestruct_ (const char* yymsg,
290                              int yytype,
291                              semantic_type* yyvaluep,
292                              location_type* yylocationp);
293
294     /// Pop \a n symbols the three stacks.
295     inline void yypop_ (unsigned int n = 1);
296
297     /* Constants.  */
298     static const int yyeof_;
299     /* LAST_ -- Last index in TABLE_.  */
300     static const int yylast_;
301     static const int yynnts_;
302     static const int yyempty_;
303     static const int yyfinal_;
304     static const int yyterror_;
305     static const int yyerrcode_;
306     static const int yyntokens_;
307     static const unsigned int yyuser_token_number_max_;
308     static const token_number_type yyundef_token_;
309
310     /* Debugging.  */
311     int yydebug_;
312     std::ostream* yycdebug_;
313
314
315     /* User arguments.  */
316     QJson::ParserPrivate* driver;
317   };
318 }
319
320
321 #endif /* ! defined PARSER_HEADER_H */