comparison WindowsOnly/WinScript2/script-parser.hh @ 0:db40c85cad7a default tip

upload sample source
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Mon, 09 May 2011 03:11:59 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:db40c85cad7a
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 4 "d:\\Work\\ScriptEngine\\Samples\\WinScript2\\script-parser.yy"
52
53 #ifdef _MSC_VER
54 #pragma warning(disable: 4800)
55 #pragma warning(disable: 4267)
56 #endif
57
58 #include <string>
59 #include "node.h"
60 class compiler;
61
62
63 /* Line 303 of lalr1.cc. */
64 #line 65 "script-parser.hh"
65
66 #include "location.hh"
67
68 /* Enabling traces. */
69 #ifndef YYDEBUG
70 # define YYDEBUG 0
71 #endif
72
73 /* Enabling verbose error messages. */
74 #ifdef YYERROR_VERBOSE
75 # undef YYERROR_VERBOSE
76 # define YYERROR_VERBOSE 1
77 #else
78 # define YYERROR_VERBOSE 1
79 #endif
80
81 /* Enabling the token table. */
82 #ifndef YYTOKEN_TABLE
83 # define YYTOKEN_TABLE 0
84 #endif
85
86 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
87 If N is 0, then set CURRENT to the empty location which ends
88 the previous symbol: RHS[0] (always defined). */
89
90 #ifndef YYLLOC_DEFAULT
91 # define YYLLOC_DEFAULT(Current, Rhs, N) \
92 do { \
93 if (N) \
94 { \
95 (Current).begin = (Rhs)[1].begin; \
96 (Current).end = (Rhs)[N].end; \
97 } \
98 else \
99 { \
100 (Current).begin = (Current).end = (Rhs)[0].end; \
101 } \
102 } while (false)
103 #endif
104
105 namespace yy
106 {
107
108 /// A Bison parser.
109 class script_parser
110 {
111 public:
112 /// Symbol semantic values.
113 #ifndef YYSTYPE
114 union semantic_type
115 #line 27 "d:\\Work\\ScriptEngine\\Samples\\WinScript2\\script-parser.yy"
116 {
117 int ival;
118 std::string *sval;
119
120 int type;
121 CValueList *value_list;
122 CArgList *arglist;
123 CDeclList *decls;
124 CStateList *states;
125 CStatement *statement;
126 CArgDef *argdef;
127 CArgs *args;
128 CValueNode *value;
129 CNode *expr;
130 CAssign *assign;
131 CStateBlock *block;
132 }
133 /* Line 303 of lalr1.cc. */
134 #line 135 "script-parser.hh"
135 ;
136 #else
137 typedef YYSTYPE semantic_type;
138 #endif
139 /// Symbol locations.
140 typedef location location_type;
141 /// Tokens.
142 struct token
143 {
144 /* Tokens. */
145 enum yytokentype {
146 END_OF_FILE = 0,
147 TK_IVAL = 258,
148 TK_IDENTIFIER = 259,
149 TK_SVAL = 260,
150 TK_LOGOR = 261,
151 TK_LOGAND = 262,
152 TK_EQ = 263,
153 TK_NE = 264,
154 TK_GE = 265,
155 TK_LE = 266,
156 TK_LSHIFT = 267,
157 TK_RSHIFT = 268,
158 TK_ADD_ASSIGN = 269,
159 TK_SUB_ASSIGN = 270,
160 TK_MUL_ASSIGN = 271,
161 TK_DIV_ASSIGN = 272,
162 TK_MOD_ASSIGN = 273,
163 TK_IF = 274,
164 TK_ELSE = 275,
165 TK_WHILE = 276,
166 TK_FOR = 277,
167 TK_SWITCH = 278,
168 TK_CASE = 279,
169 TK_DEFAULT = 280,
170 TK_BREAK = 281,
171 TK_RETURN = 282,
172 TK_INTEGER = 283,
173 TK_STRING = 284,
174 TK_VOID = 285,
175 NEG = 286
176 };
177
178 };
179 /// Token type.
180 typedef token::yytokentype token_type;
181
182 /// Build a parser object.
183 script_parser (compiler& driver_yyarg);
184 virtual ~script_parser ();
185
186 /// Parse.
187 /// \returns 0 iff parsing succeeded.
188 virtual int parse ();
189
190 /// The current debugging stream.
191 std::ostream& debug_stream () const;
192 /// Set the current debugging stream.
193 void set_debug_stream (std::ostream &);
194
195 /// Type for debugging levels.
196 typedef int debug_level_type;
197 /// The current debugging level.
198 debug_level_type debug_level () const;
199 /// Set the current debugging level.
200 void set_debug_level (debug_level_type l);
201
202 private:
203 /// Report a syntax error.
204 /// \param loc where the syntax error is found.
205 /// \param msg a description of the syntax error.
206 virtual void error (const location_type& loc, const std::string& msg);
207
208 /// Generate an error message.
209 /// \param state the state where the error occurred.
210 /// \param tok the look-ahead token.
211 virtual std::string yysyntax_error_ (int yystate, int tok);
212
213 #if YYDEBUG
214 /// \brief Report a symbol value on the debug stream.
215 /// \param yytype The token type.
216 /// \param yyvaluep Its semantic value.
217 /// \param yylocationp Its location.
218 virtual void yy_symbol_value_print_ (int yytype,
219 const semantic_type* yyvaluep,
220 const location_type* yylocationp);
221 /// \brief Report a symbol on the debug stream.
222 /// \param yytype The token type.
223 /// \param yyvaluep Its semantic value.
224 /// \param yylocationp Its location.
225 virtual void yy_symbol_print_ (int yytype,
226 const semantic_type* yyvaluep,
227 const location_type* yylocationp);
228 #endif /* ! YYDEBUG */
229
230
231 /// State numbers.
232 typedef int state_type;
233 /// State stack type.
234 typedef stack<state_type> state_stack_type;
235 /// Semantic value stack type.
236 typedef stack<semantic_type> semantic_stack_type;
237 /// location stack type.
238 typedef stack<location_type> location_stack_type;
239
240 /// The state stack.
241 state_stack_type yystate_stack_;
242 /// The semantic value stack.
243 semantic_stack_type yysemantic_stack_;
244 /// The location stack.
245 location_stack_type yylocation_stack_;
246
247 /// Internal symbol numbers.
248 typedef unsigned char token_number_type;
249 /* Tables. */
250 /// For a state, the index in \a yytable_ of its portion.
251 static const short int yypact_[];
252 static const signed char yypact_ninf_;
253
254 /// For a state, default rule to reduce.
255 /// Unless\a yytable_ specifies something else to do.
256 /// Zero means the default is an error.
257 static const unsigned char yydefact_[];
258
259 static const short int yypgoto_[];
260 static const signed char yydefgoto_[];
261
262 /// What to do in a state.
263 /// \a yytable_[yypact_[s]]: what to do in state \a s.
264 /// - if positive, shift that token.
265 /// - if negative, reduce the rule which number is the opposite.
266 /// - if zero, do what YYDEFACT says.
267 static const short int yytable_[];
268 static const signed char yytable_ninf_;
269
270 static const short int yycheck_[];
271
272 /// For a state, its accessing symbol.
273 static const unsigned char yystos_[];
274
275 /// For a rule, its LHS.
276 static const unsigned char yyr1_[];
277 /// For a rule, its RHS length.
278 static const unsigned char yyr2_[];
279
280 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
281 /// For a symbol, its name in clear.
282 static const char* const yytname_[];
283 #endif
284
285 #if YYERROR_VERBOSE
286 /// Convert the symbol name \a n to a form suitable for a diagnostic.
287 virtual std::string yytnamerr_ (const char *n);
288 #endif
289
290 #if YYDEBUG
291 /// A type to store symbol numbers and -1.
292 typedef signed char rhs_number_type;
293 /// A `-1'-separated list of the rules' RHS.
294 static const rhs_number_type yyrhs_[];
295 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
296 static const unsigned short int yyprhs_[];
297 /// For each rule, its source line number.
298 static const unsigned char yyrline_[];
299 /// For each scanner token number, its symbol number.
300 static const unsigned short int yytoken_number_[];
301 /// Report on the debug stream that the rule \a r is going to be reduced.
302 virtual void yy_reduce_print_ (int r);
303 /// Print the state stack on the debug stream.
304 virtual void yystack_print_ ();
305 #endif
306
307 /// Convert a scanner token number \a t to a symbol number.
308 token_number_type yytranslate_ (int t);
309
310 /// \brief Reclaim the memory associated to a symbol.
311 /// \param yymsg Why this token is reclaimed.
312 /// \param yytype The symbol type.
313 /// \param yyvaluep Its semantic value.
314 /// \param yylocationp Its location.
315 inline void yydestruct_ (const char* yymsg,
316 int yytype,
317 semantic_type* yyvaluep,
318 location_type* yylocationp);
319
320 /// Pop \a n symbols the three stacks.
321 inline void yypop_ (unsigned int n = 1);
322
323 /* Constants. */
324 static const int yyeof_;
325 /* LAST_ -- Last index in TABLE_. */
326 static const int yylast_;
327 static const int yynnts_;
328 static const int yyempty_;
329 static const int yyfinal_;
330 static const int yyterror_;
331 static const int yyerrcode_;
332 static const int yyntokens_;
333 static const unsigned int yyuser_token_number_max_;
334 static const token_number_type yyundef_token_;
335
336 /* Debugging. */
337 int yydebug_;
338 std::ostream* yycdebug_;
339
340
341 /* User arguments. */
342 compiler& driver;
343 };
344 }
345
346
347 #endif /* ! defined PARSER_HEADER_H */