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. */
53
/***************************************************************************
54
* Copyright (C) 2005 by Alexander Dymo *
55
* adymo@kdevelop.org *
56
* Copyright (C) 2006 by Andreas Pakulat *
59
* This program is free software; you can redistribute it and/or modify *
60
* it under the terms of the GNU Library General Public License as *
61
* published by the Free Software Foundation; either version 2 of the *
62
* License, or (at your option) any later version. *
64
* This program is distributed in the hope that it will be useful, *
65
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
66
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
67
* GNU General Public License for more details. *
69
* You should have received a copy of the GNU Library General Public *
70
* License along with this program; if not, write to the *
71
* Free Software Foundation, Inc., *
72
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
73
***************************************************************************/
79
Simple LALR parser which builds the syntax tree (see @ref QMake::AST).
81
@todo Recognize comments after statements like:
82
SOURCES = foo #regognize me
84
@fixme Parser fails on files that do not end with a newline
85
@fixme 1 shift/reduce conflict in "line_body" rule
88
#include <qvaluestack.h>
92
#define YYSTYPE_IS_DECLARED
104
/**Type of semantic value for simple grammar rules.*/
106
/**Type of semantic value for grammar rules which are parts of AST.*/
108
/**Type of semantic value for "multiline_values" grammar rule.
109
Each line of multiline value is stored as a string in the list.
111
For example we have in .pro file:
117
The string list will be populated with three strings:
128
#define YYSTYPE Result
129
typedef Result YYSTYPE;
132
extern int QMakelex( QMake::Result* yylval, QMake::Lexer* lexer );
135
The stack to store ProjectAST pointers when a new child
136
ProjectAST is created and filled with statements.
138
Parser creates root ProjectAST for a .pro file, pushes it onto the stack and starts
139
adding statements. Each statement is added as a child StatementAST to the ProjectAST
140
currently on the top in the stack.
142
When a scope or function scope statement is parsed, the child ProjectAST is created
143
and pushed onto the stack. Therefore all statements which belong to the scope
144
or function scope are added as childs to their direct parent (scope or function scope).
146
//QValueStack<ProjectAST*> projects;
149
The current depth of AST node is stored here.
150
AST depth is important to know because automatic indentation can
151
be easily implemented (the parser itself looses all information
157
To debug this parser, put the line below into the next bison file section.
158
Don't forget to uncomment "yydebug = 1" line in qmakedriver.cpp.
163
/* Line 35 of lalr1.cc. */
164
#line 165 "qmake_yacc.hpp"
166
#include "location.hh"
168
/* Enabling traces. */
173
/* Enabling verbose error messages. */
174
#ifdef YYERROR_VERBOSE
175
# undef YYERROR_VERBOSE
176
# define YYERROR_VERBOSE 1
178
# define YYERROR_VERBOSE 0
181
/* Enabling the token table. */
182
#ifndef YYTOKEN_TABLE
183
# define YYTOKEN_TABLE 1
186
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
187
If N is 0, then set CURRENT to the empty location which ends
188
the previous symbol: RHS[0] (always defined). */
190
#ifndef YYLLOC_DEFAULT
191
# define YYLLOC_DEFAULT(Current, Rhs, N) \
195
(Current).begin = (Rhs)[1].begin; \
196
(Current).end = (Rhs)[N].end; \
200
(Current).begin = (Current).end = (Rhs)[0].end; \
212
/// Symbol semantic values.
214
typedef int semantic_type;
216
typedef YYSTYPE semantic_type;
218
/// Symbol locations.
219
typedef location location_type;
241
QUOTED_VARIABLE_VALUE = 274,
242
VARIABLE_VALUE = 275,
249
typedef token::yytokentype token_type;
251
/// Build a parser object.
252
Parser (QMake::Lexer* lexer_yyarg, QValueStack<ProjectAST*>& projects_yyarg, int depth_yyarg);
256
/// \returns 0 iff parsing succeeded.
257
virtual int parse ();
259
/// The current debugging stream.
260
std::ostream& debug_stream () const;
261
/// Set the current debugging stream.
262
void set_debug_stream (std::ostream &);
264
/// Type for debugging levels.
265
typedef int debug_level_type;
266
/// The current debugging level.
267
debug_level_type debug_level () const;
268
/// Set the current debugging level.
269
void set_debug_level (debug_level_type l);
272
/// Report a syntax error.
273
/// \param loc where the syntax error is found.
274
/// \param msg a description of the syntax error.
275
virtual void error (const location_type& loc, const std::string& msg);
277
/// Generate an error message.
278
/// \param state the state where the error occurred.
279
/// \param tok the look-ahead token.
280
virtual std::string yysyntax_error_ (int yystate);
283
/// \brief Report a symbol value on the debug stream.
284
/// \param yytype The token type.
285
/// \param yyvaluep Its semantic value.
286
/// \param yylocationp Its location.
287
virtual void yy_symbol_value_print_ (int yytype,
288
const semantic_type* yyvaluep,
289
const location_type* yylocationp);
290
/// \brief Report a symbol on the debug stream.
291
/// \param yytype The token type.
292
/// \param yyvaluep Its semantic value.
293
/// \param yylocationp Its location.
294
virtual void yy_symbol_print_ (int yytype,
295
const semantic_type* yyvaluep,
296
const location_type* yylocationp);
297
#endif /* ! YYDEBUG */
301
typedef int state_type;
302
/// State stack type.
303
typedef stack<state_type> state_stack_type;
304
/// Semantic value stack type.
305
typedef stack<semantic_type> semantic_stack_type;
306
/// location stack type.
307
typedef stack<location_type> location_stack_type;
310
state_stack_type yystate_stack_;
311
/// The semantic value stack.
312
semantic_stack_type yysemantic_stack_;
313
/// The location stack.
314
location_stack_type yylocation_stack_;
316
/// Internal symbol numbers.
317
typedef unsigned char token_number_type;
319
/// For a state, the index in \a yytable_ of its portion.
320
static const signed char yypact_[];
321
static const signed char yypact_ninf_;
323
/// For a state, default rule to reduce.
324
/// Unless\a yytable_ specifies something else to do.
325
/// Zero means the default is an error.
326
static const unsigned char yydefact_[];
328
static const signed char yypgoto_[];
329
static const signed char yydefgoto_[];
331
/// What to do in a state.
332
/// \a yytable_[yypact_[s]]: what to do in state \a s.
333
/// - if positive, shift that token.
334
/// - if negative, reduce the rule which number is the opposite.
335
/// - if zero, do what YYDEFACT says.
336
static const signed char yytable_[];
337
static const signed char yytable_ninf_;
339
static const unsigned char yycheck_[];
341
/// For a state, its accessing symbol.
342
static const unsigned char yystos_[];
344
/// For a rule, its LHS.
345
static const unsigned char yyr1_[];
346
/// For a rule, its RHS length.
347
static const unsigned char yyr2_[];
349
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
350
/// For a symbol, its name in clear.
351
static const char* const yytname_[];
355
/// Convert the symbol name \a n to a form suitable for a diagnostic.
356
virtual std::string yytnamerr_ (const char *n);
360
/// A type to store symbol numbers and -1.
361
typedef signed char rhs_number_type;
362
/// A `-1'-separated list of the rules' RHS.
363
static const rhs_number_type yyrhs_[];
364
/// For each rule, the index of the first RHS symbol in \a yyrhs_.
365
static const unsigned char yyprhs_[];
366
/// For each rule, its source line number.
367
static const unsigned short int yyrline_[];
368
/// For each scanner token number, its symbol number.
369
static const unsigned short int yytoken_number_[];
370
/// Report on the debug stream that the rule \a r is going to be reduced.
371
virtual void yy_reduce_print_ (int r);
372
/// Print the state stack on the debug stream.
373
virtual void yystack_print_ ();
376
/// Convert a scanner token number \a t to a symbol number.
377
token_number_type yytranslate_ (int t);
379
/// \brief Reclaim the memory associated to a symbol.
380
/// \param yymsg Why this token is reclaimed.
381
/// \param yytype The symbol type.
382
/// \param yyvaluep Its semantic value.
383
/// \param yylocationp Its location.
384
inline void yydestruct_ (const char* yymsg,
386
semantic_type* yyvaluep,
387
location_type* yylocationp);
389
/// Pop \a n symbols the three stacks.
390
inline void yypop_ (unsigned int n = 1);
393
static const int yyeof_;
394
/* LAST_ -- Last index in TABLE_. */
395
static const int yylast_;
396
static const int yynnts_;
397
static const int yyempty_;
398
static const int yyfinal_;
399
static const int yyterror_;
400
static const int yyerrcode_;
401
static const int yyntokens_;
402
static const unsigned int yyuser_token_number_max_;
403
static const token_number_type yyundef_token_;
407
std::ostream* yycdebug_;
410
/* User arguments. */
412
QValueStack<ProjectAST*>& projects;
418
#endif /* ! defined PARSER_HEADER_H */