comparison Bison-Flex/BasicCompiler-StackBase/script-parser.hh @ 1:a3ea4c73696b

move files
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 10 May 2011 06:26:08 +0900
parents Bison-Flex/EUC/script-parser.hh@3f4ade70b4d2
children fbe42292d479
comparison
equal deleted inserted replaced
0:3f4ade70b4d2 1:a3ea4c73696b
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 "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 35 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 28 "script-parser.yy"
116 {
117 int ival;
118 std::string *sval;
119
120 CArgs *args;
121 CNode *expr;
122 CAssign *assign;
123 }
124 /* Line 35 of lalr1.cc. */
125 #line 126 "script-parser.hh"
126 ;
127 #else
128 typedef YYSTYPE semantic_type;
129 #endif
130 /// Symbol locations.
131 typedef location location_type;
132 /// Tokens.
133 struct token
134 {
135 /* Tokens. */
136 enum yytokentype {
137 END_OF_FILE = 0,
138 TK_IVAL = 258,
139 TK_IDENTIFIER = 259,
140 TK_EQ = 260,
141 TK_NE = 261,
142 TK_GE = 262,
143 TK_LE = 263,
144 TK_NEWLINE = 264,
145 TK_IF = 265,
146 TK_THEN = 266,
147 TK_ELSE = 267,
148 TK_ENDIF = 268,
149 TK_FOR = 269,
150 TK_TO = 270,
151 TK_NEXT = 271,
152 TK_WHILE = 272,
153 TK_WEND = 273,
154 TK_END = 274,
155 TK_RAND = 275,
156 TK_PRINT = 276,
157 NEG = 277
158 };
159
160 };
161 /// Token type.
162 typedef token::yytokentype token_type;
163
164 /// Build a parser object.
165 script_parser (compiler& driver_yyarg);
166 virtual ~script_parser ();
167
168 /// Parse.
169 /// \returns 0 iff parsing succeeded.
170 virtual int parse ();
171
172 /// The current debugging stream.
173 std::ostream& debug_stream () const;
174 /// Set the current debugging stream.
175 void set_debug_stream (std::ostream &);
176
177 /// Type for debugging levels.
178 typedef int debug_level_type;
179 /// The current debugging level.
180 debug_level_type debug_level () const;
181 /// Set the current debugging level.
182 void set_debug_level (debug_level_type l);
183
184 private:
185 /// Report a syntax error.
186 /// \param loc where the syntax error is found.
187 /// \param msg a description of the syntax error.
188 virtual void error (const location_type& loc, const std::string& msg);
189
190 /// Generate an error message.
191 /// \param state the state where the error occurred.
192 /// \param tok the look-ahead token.
193 virtual std::string yysyntax_error_ (int yystate, int tok);
194
195 #if YYDEBUG
196 /// \brief Report a symbol value on the debug stream.
197 /// \param yytype The token type.
198 /// \param yyvaluep Its semantic value.
199 /// \param yylocationp Its location.
200 virtual void yy_symbol_value_print_ (int yytype,
201 const semantic_type* yyvaluep,
202 const location_type* yylocationp);
203 /// \brief Report a symbol on the debug stream.
204 /// \param yytype The token type.
205 /// \param yyvaluep Its semantic value.
206 /// \param yylocationp Its location.
207 virtual void yy_symbol_print_ (int yytype,
208 const semantic_type* yyvaluep,
209 const location_type* yylocationp);
210 #endif /* ! YYDEBUG */
211
212
213 /// State numbers.
214 typedef int state_type;
215 /// State stack type.
216 typedef stack<state_type> state_stack_type;
217 /// Semantic value stack type.
218 typedef stack<semantic_type> semantic_stack_type;
219 /// location stack type.
220 typedef stack<location_type> location_stack_type;
221
222 /// The state stack.
223 state_stack_type yystate_stack_;
224 /// The semantic value stack.
225 semantic_stack_type yysemantic_stack_;
226 /// The location stack.
227 location_stack_type yylocation_stack_;
228
229 /// Internal symbol numbers.
230 typedef unsigned char token_number_type;
231 /* Tables. */
232 /// For a state, the index in \a yytable_ of its portion.
233 static const signed char yypact_[];
234 static const signed char yypact_ninf_;
235
236 /// For a state, default rule to reduce.
237 /// Unless\a yytable_ specifies something else to do.
238 /// Zero means the default is an error.
239 static const unsigned char yydefact_[];
240
241 static const signed char yypgoto_[];
242 static const signed char yydefgoto_[];
243
244 /// What to do in a state.
245 /// \a yytable_[yypact_[s]]: what to do in state \a s.
246 /// - if positive, shift that token.
247 /// - if negative, reduce the rule which number is the opposite.
248 /// - if zero, do what YYDEFACT says.
249 static const unsigned char yytable_[];
250 static const signed char yytable_ninf_;
251
252 static const signed char yycheck_[];
253
254 /// For a state, its accessing symbol.
255 static const unsigned char yystos_[];
256
257 /// For a rule, its LHS.
258 static const unsigned char yyr1_[];
259 /// For a rule, its RHS length.
260 static const unsigned char yyr2_[];
261
262 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
263 /// For a symbol, its name in clear.
264 static const char* const yytname_[];
265 #endif
266
267 #if YYERROR_VERBOSE
268 /// Convert the symbol name \a n to a form suitable for a diagnostic.
269 virtual std::string yytnamerr_ (const char *n);
270 #endif
271
272 #if YYDEBUG
273 /// A type to store symbol numbers and -1.
274 typedef signed char rhs_number_type;
275 /// A `-1'-separated list of the rules' RHS.
276 static const rhs_number_type yyrhs_[];
277 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
278 static const unsigned char yyprhs_[];
279 /// For each rule, its source line number.
280 static const unsigned char yyrline_[];
281 /// For each scanner token number, its symbol number.
282 static const unsigned short int yytoken_number_[];
283 /// Report on the debug stream that the rule \a r is going to be reduced.
284 virtual void yy_reduce_print_ (int r);
285 /// Print the state stack on the debug stream.
286 virtual void yystack_print_ ();
287 #endif
288
289 /// Convert a scanner token number \a t to a symbol number.
290 token_number_type yytranslate_ (int t);
291
292 /// \brief Reclaim the memory associated to a symbol.
293 /// \param yymsg Why this token is reclaimed.
294 /// \param yytype The symbol type.
295 /// \param yyvaluep Its semantic value.
296 /// \param yylocationp Its location.
297 inline void yydestruct_ (const char* yymsg,
298 int yytype,
299 semantic_type* yyvaluep,
300 location_type* yylocationp);
301
302 /// Pop \a n symbols the three stacks.
303 inline void yypop_ (unsigned int n = 1);
304
305 /* Constants. */
306 static const int yyeof_;
307 /* LAST_ -- Last index in TABLE_. */
308 static const int yylast_;
309 static const int yynnts_;
310 static const int yyempty_;
311 static const int yyfinal_;
312 static const int yyterror_;
313 static const int yyerrcode_;
314 static const int yyntokens_;
315 static const unsigned int yyuser_token_number_max_;
316 static const token_number_type yyundef_token_;
317
318 /* Debugging. */
319 int yydebug_;
320 std::ostream* yycdebug_;
321
322
323 /* User arguments. */
324 compiler& driver;
325 };
326 }
327
328
329 #endif /* ! defined PARSER_HEADER_H */