From 4ae7b32dc09eb7acd9411a8af63a767660aa64ec Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 17 Dec 2020 20:50:19 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro (cherry picked from commit 3e3d9eda9d1dd8c67c1c27c6a9bdc68bdecfcc30) --- buildtools/lib/parsers/autotools/Makefile.am | 2 +- buildtools/lib/parsers/qmake/location.h | 145 ++++++++++ buildtools/lib/parsers/qmake/location.hh | 145 ---------- buildtools/lib/parsers/qmake/position.h | 142 +++++++++ buildtools/lib/parsers/qmake/position.hh | 142 --------- buildtools/lib/parsers/qmake/qmake.yy | 2 +- buildtools/lib/parsers/qmake/qmake_lex.h | 2 +- buildtools/lib/parsers/qmake/qmake_yacc.cpp | 6 +- buildtools/lib/parsers/qmake/qmake_yacc.h | 418 +++++++++++++++++++++++++++ buildtools/lib/parsers/qmake/qmake_yacc.hpp | 418 --------------------------- buildtools/lib/parsers/qmake/qmakedriver.cpp | 2 +- buildtools/lib/parsers/qmake/stack.h | 129 +++++++++ buildtools/lib/parsers/qmake/stack.hh | 129 --------- 13 files changed, 841 insertions(+), 841 deletions(-) create mode 100644 buildtools/lib/parsers/qmake/location.h delete mode 100644 buildtools/lib/parsers/qmake/location.hh create mode 100644 buildtools/lib/parsers/qmake/position.h delete mode 100644 buildtools/lib/parsers/qmake/position.hh create mode 100644 buildtools/lib/parsers/qmake/qmake_yacc.h delete mode 100644 buildtools/lib/parsers/qmake/qmake_yacc.hpp create mode 100644 buildtools/lib/parsers/qmake/stack.h delete mode 100644 buildtools/lib/parsers/qmake/stack.hh (limited to 'buildtools/lib/parsers') diff --git a/buildtools/lib/parsers/autotools/Makefile.am b/buildtools/lib/parsers/autotools/Makefile.am index 340d0e38..950d6571 100644 --- a/buildtools/lib/parsers/autotools/Makefile.am +++ b/buildtools/lib/parsers/autotools/Makefile.am @@ -13,7 +13,7 @@ libkdevautotoolsparser_la_SOURCES = autotoolsast.cpp autotoolsdriver.cpp autotoo parser: cd $(srcdir) ; \ bison -d autotools.yy -o autotools_yacc.cpp ; \ - mv -f autotools_yacc.hpp autotools_yacc.h ; \ + mv -f autotools_yacc.h autotools_yacc.h ; \ flex -oautotools_lex.cpp autotools.ll EXTRA_DIST = autotools.yy autotools.ll diff --git a/buildtools/lib/parsers/qmake/location.h b/buildtools/lib/parsers/qmake/location.h new file mode 100644 index 00000000..f97af783 --- /dev/null +++ b/buildtools/lib/parsers/qmake/location.h @@ -0,0 +1,145 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Locations for Bison parsers in C++ + + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file location.h + ** Define the TQMake::location class. + */ + +#ifndef BISON_LOCATION_H +# define BISON_LOCATION_H + +# include +# include +# include "position.h" + +namespace TQMake +{ + + /// Abstract a location. + class location + { + public: + + /// Construct a location. + location () + : begin (), end () + { + } + + + /// Initialization. + inline void initialize (std::string* fn) + { + begin.initialize (fn); + end = begin; + } + + /** \name Line and Column related manipulators + ** \{ */ + public: + /// Reset initial location to final location. + inline void step () + { + begin = end; + } + + /// Extend the current location to the COUNT next columns. + inline void columns (unsigned int count = 1) + { + end += count; + } + + /// Extend the current location to the COUNT next lines. + inline void lines (unsigned int count = 1) + { + end.lines (count); + } + /** \} */ + + + public: + /// Beginning of the located region. + position begin; + /// End of the located region. + position end; + }; + + /// Join two location objects to create a location. + inline const location operator+ (const location& begin, const location& end) + { + location res = begin; + res.end = end.end; + return res; + } + + /// Add two location objects. + inline const location operator+ (const location& begin, unsigned int width) + { + location res = begin; + res.columns (width); + return res; + } + + /// Add and assign a location. + inline location& operator+= (location& res, unsigned int width) + { + res.columns (width); + return res; + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param loc a reference to the location to redirect + ** + ** Avoid duplicate information. + */ + inline std::ostream& operator<< (std::ostream& ostr, const location& loc) + { + position last = loc.end - 1; + ostr << loc.begin; + if (last.filename + && (!loc.begin.filename + || *loc.begin.filename != *last.filename)) + ostr << '-' << last; + else if (loc.begin.line != last.line) + ostr << '-' << last.line << '.' << last.column; + else if (loc.begin.column != last.column) + ostr << '-' << last.column; + return ostr; + } + +} + +#endif // not BISON_LOCATION_H diff --git a/buildtools/lib/parsers/qmake/location.hh b/buildtools/lib/parsers/qmake/location.hh deleted file mode 100644 index d6247645..00000000 --- a/buildtools/lib/parsers/qmake/location.hh +++ /dev/null @@ -1,145 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Locations for Bison parsers in C++ - - Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/** - ** \file location.hh - ** Define the TQMake::location class. - */ - -#ifndef BISON_LOCATION_HH -# define BISON_LOCATION_HH - -# include -# include -# include "position.hh" - -namespace TQMake -{ - - /// Abstract a location. - class location - { - public: - - /// Construct a location. - location () - : begin (), end () - { - } - - - /// Initialization. - inline void initialize (std::string* fn) - { - begin.initialize (fn); - end = begin; - } - - /** \name Line and Column related manipulators - ** \{ */ - public: - /// Reset initial location to final location. - inline void step () - { - begin = end; - } - - /// Extend the current location to the COUNT next columns. - inline void columns (unsigned int count = 1) - { - end += count; - } - - /// Extend the current location to the COUNT next lines. - inline void lines (unsigned int count = 1) - { - end.lines (count); - } - /** \} */ - - - public: - /// Beginning of the located region. - position begin; - /// End of the located region. - position end; - }; - - /// Join two location objects to create a location. - inline const location operator+ (const location& begin, const location& end) - { - location res = begin; - res.end = end.end; - return res; - } - - /// Add two location objects. - inline const location operator+ (const location& begin, unsigned int width) - { - location res = begin; - res.columns (width); - return res; - } - - /// Add and assign a location. - inline location& operator+= (location& res, unsigned int width) - { - res.columns (width); - return res; - } - - /** \brief Intercept output stream redirection. - ** \param ostr the destination output stream - ** \param loc a reference to the location to redirect - ** - ** Avoid duplicate information. - */ - inline std::ostream& operator<< (std::ostream& ostr, const location& loc) - { - position last = loc.end - 1; - ostr << loc.begin; - if (last.filename - && (!loc.begin.filename - || *loc.begin.filename != *last.filename)) - ostr << '-' << last; - else if (loc.begin.line != last.line) - ostr << '-' << last.line << '.' << last.column; - else if (loc.begin.column != last.column) - ostr << '-' << last.column; - return ostr; - } - -} - -#endif // not BISON_LOCATION_HH diff --git a/buildtools/lib/parsers/qmake/position.h b/buildtools/lib/parsers/qmake/position.h new file mode 100644 index 00000000..9f5951f0 --- /dev/null +++ b/buildtools/lib/parsers/qmake/position.h @@ -0,0 +1,142 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Positions for Bison parsers in C++ + + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file position.h + ** Define the TQMake::position class. + */ + +#ifndef BISON_POSITION_H +# define BISON_POSITION_H + +# include +# include + +namespace TQMake +{ + /// Abstract a position. + class position + { + public: + + /// Construct a position. + position () + : filename (0), line (1), column (0) + { + } + + + /// Initialization. + inline void initialize (std::string* fn) + { + filename = fn; + line = 1; + column = 0; + } + + /** \name Line and Column related manipulators + ** \{ */ + public: + /// (line related) Advance to the COUNT next lines. + inline void lines (int count = 1) + { + column = 0; + line += count; + } + + /// (column related) Advance to the COUNT next columns. + inline void columns (int count = 1) + { + int leftmost = 0; + int current = column; + if (leftmost <= current + count) + column += count; + else + column = 0; + } + /** \} */ + + public: + /// File name to which this position refers. + std::string* filename; + /// Current line number. + unsigned int line; + /// Current column number. + unsigned int column; + }; + + /// Add and assign a position. + inline const position& + operator+= (position& res, const int width) + { + res.columns (width); + return res; + } + + /// Add two position objects. + inline const position + operator+ (const position& begin, const int width) + { + position res = begin; + return res += width; + } + + /// Add and assign a position. + inline const position& + operator-= (position& res, const int width) + { + return res += -width; + } + + /// Add two position objects. + inline const position + operator- (const position& begin, const int width) + { + return begin + -width; + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param pos a reference to the position to redirect + */ + inline std::ostream& + operator<< (std::ostream& ostr, const position& pos) + { + if (pos.filename) + ostr << *pos.filename << ':'; + return ostr << pos.line << '.' << pos.column; + } + +} +#endif // not BISON_POSITION_H diff --git a/buildtools/lib/parsers/qmake/position.hh b/buildtools/lib/parsers/qmake/position.hh deleted file mode 100644 index 6e95eb95..00000000 --- a/buildtools/lib/parsers/qmake/position.hh +++ /dev/null @@ -1,142 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Positions for Bison parsers in C++ - - Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/** - ** \file position.hh - ** Define the TQMake::position class. - */ - -#ifndef BISON_POSITION_HH -# define BISON_POSITION_HH - -# include -# include - -namespace TQMake -{ - /// Abstract a position. - class position - { - public: - - /// Construct a position. - position () - : filename (0), line (1), column (0) - { - } - - - /// Initialization. - inline void initialize (std::string* fn) - { - filename = fn; - line = 1; - column = 0; - } - - /** \name Line and Column related manipulators - ** \{ */ - public: - /// (line related) Advance to the COUNT next lines. - inline void lines (int count = 1) - { - column = 0; - line += count; - } - - /// (column related) Advance to the COUNT next columns. - inline void columns (int count = 1) - { - int leftmost = 0; - int current = column; - if (leftmost <= current + count) - column += count; - else - column = 0; - } - /** \} */ - - public: - /// File name to which this position refers. - std::string* filename; - /// Current line number. - unsigned int line; - /// Current column number. - unsigned int column; - }; - - /// Add and assign a position. - inline const position& - operator+= (position& res, const int width) - { - res.columns (width); - return res; - } - - /// Add two position objects. - inline const position - operator+ (const position& begin, const int width) - { - position res = begin; - return res += width; - } - - /// Add and assign a position. - inline const position& - operator-= (position& res, const int width) - { - return res += -width; - } - - /// Add two position objects. - inline const position - operator- (const position& begin, const int width) - { - return begin + -width; - } - - /** \brief Intercept output stream redirection. - ** \param ostr the destination output stream - ** \param pos a reference to the position to redirect - */ - inline std::ostream& - operator<< (std::ostream& ostr, const position& pos) - { - if (pos.filename) - ostr << *pos.filename << ':'; - return ostr << pos.line << '.' << pos.column; - } - -} -#endif // not BISON_POSITION_HH diff --git a/buildtools/lib/parsers/qmake/qmake.yy b/buildtools/lib/parsers/qmake/qmake.yy index 3cc0b79d..2c3e866d 100644 --- a/buildtools/lib/parsers/qmake/qmake.yy +++ b/buildtools/lib/parsers/qmake/qmake.yy @@ -109,7 +109,7 @@ Don't forget to uncomment "yydebug = 1" line in qmakedriver.cpp. */ %} -%skeleton "lalr1.cc" +%skeleton "lalr1.cpp" %define "parser_class_name" "Parser" %name-prefix="QMake" %parse-param { QMake::Lexer* lexer } diff --git a/buildtools/lib/parsers/qmake/qmake_lex.h b/buildtools/lib/parsers/qmake/qmake_lex.h index 25aa402d..4bed35dd 100644 --- a/buildtools/lib/parsers/qmake/qmake_lex.h +++ b/buildtools/lib/parsers/qmake/qmake_lex.h @@ -20,7 +20,7 @@ #ifndef TQMAKE_LEX_H #define TQMAKE_LEX_H -#include "qmake_yacc.hpp" +#include "qmake_yacc.h" #include #ifndef DONT_INCLUDE_FLEXLEXER diff --git a/buildtools/lib/parsers/qmake/qmake_yacc.cpp b/buildtools/lib/parsers/qmake/qmake_yacc.cpp index f9dea804..25ae0e85 100644 --- a/buildtools/lib/parsers/qmake/qmake_yacc.cpp +++ b/buildtools/lib/parsers/qmake/qmake_yacc.cpp @@ -35,12 +35,12 @@ // Take the name prefix into account. #define yylex TQMakelex -#include "qmake_yacc.hpp" +#include "qmake_yacc.h" /* User implementation prologue. */ -/* Line 317 of lalr1.cc. */ +/* Line 317 of lalr1.cpp. */ #line 45 "tqmake_yacc.cpp" #ifndef YY_ @@ -751,7 +751,7 @@ namespace TQMake break; - /* Line 675 of lalr1.cc. */ + /* Line 675 of lalr1.cpp. */ #line 756 "tqmake_yacc.cpp" default: break; } diff --git a/buildtools/lib/parsers/qmake/qmake_yacc.h b/buildtools/lib/parsers/qmake/qmake_yacc.h new file mode 100644 index 00000000..4c4e3042 --- /dev/null +++ b/buildtools/lib/parsers/qmake/qmake_yacc.h @@ -0,0 +1,418 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison LALR(1) parsers in C++ + + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C++ LALR(1) parser skeleton written by Akim Demaille. */ + +#ifndef PARSER_HEADER_H +# define PARSER_HEADER_H + +#include +#include +#include "stack.h" + +namespace TQMake +{ + class position; + class location; +} + +/* First part of user declarations. */ +#line 1 "qmake.yy" + +/*************************************************************************** + * Copyright (C) 2005 by Alexander Dymo * + * adymo@kdevelop.org * + * Copyright (C) 2006 by Andreas Pakulat * + * apaku@gmx.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 2 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +/** +@file qmake.yy +TQMake Parser + +Simple LALR parser which builds the syntax tree (see @ref TQMake::AST). + +@todo Recognize comments after statements like: +SOURCES = foo #regognize me + +@fixme Parser fails on files that do not end with a newline +@fixme 1 shift/reduce conflict in "line_body" rule +*/ + +#include +#include "qmakeast.h" +#include + +#define YYSTYPE_IS_DECLARED + +namespace TQMake +{ + class Lexer; + +/** +The yylval type. +*/ +struct Result { + Result(): node(0) {} + + /**Type of semantic value for simple grammar rules.*/ + TQString value; + /**Type of semantic value for grammar rules which are parts of AST.*/ + AST *node; + /**Type of semantic value for "multiline_values" grammar rule. + Each line of multiline value is stored as a string in the list. + + For example we have in .pro file: + @code + SOURCE = foo1.cpp \ + foo2.cpp \ + foo3.cpp foo4.cpp + @endcode + The string list will be populated with three strings: +
+    foo1.cpp
+    foo2.cpp
+    foo3.cpp foo4.cpp
+    
+ */ + TQStringList values; + TQString indent; +}; + +#define YYSTYPE Result +typedef Result YYSTYPE; +} + +extern int TQMakelex( TQMake::Result* yylval, TQMake::Lexer* lexer ); + +/** +The stack to store ProjectAST pointers when a new child +ProjectAST is created and filled with statements. + +Parser creates root ProjectAST for a .pro file, pushes it onto the stack and starts +adding statements. Each statement is added as a child StatementAST to the ProjectAST +currently on the top in the stack. + +When a scope or function scope statement is parsed, the child ProjectAST is created +and pushed onto the stack. Therefore all statements which belong to the scope +or function scope are added as childs to their direct parent (scope or function scope). +*/ +//TQValueStack projects; + +/** +The current depth of AST node is stored here. +AST depth is important to know because automatic indentation can +be easily implemented (the parser itself looses all information +about indentation). +*/ +// int depth = 0; + +/* +To debug this parser, put the line below into the next bison file section. +Don't forget to uncomment "yydebug = 1" line in qmakedriver.cpp. +%debug +*/ + + +/* Line 35 of lalr1.cpp. */ +#line 165 "qmake_yacc.h" + +#include "location.h" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 1 +#endif + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ +do { \ + if (N) \ + { \ + (Current).begin = (Rhs)[1].begin; \ + (Current).end = (Rhs)[N].end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = (Rhs)[0].end; \ + } \ +} while (false) +#endif + +namespace TQMake +{ + + /// A Bison parser. + class Parser + { + public: + /// Symbol semantic values. +#ifndef YYSTYPE + typedef int semantic_type; +#else + typedef YYSTYPE semantic_type; +#endif + /// Symbol locations. + typedef location location_type; + /// Tokens. + struct token + { + /* Tokens. */ + enum yytokentype { + ID_SIMPLE = 258, + EQ = 259, + PLUSEQ = 260, + MINUSEQ = 261, + STAREQ = 262, + TILDEEQ = 263, + LBRACE = 264, + RBRACE = 265, + COLON = 266, + NEWLINE = 267, + COMMENT = 268, + CONT = 269, + COMMENT_CONT = 270, + RCURLY = 271, + LCURLY = 272, + ID_ARGS = 273, + QUOTED_VARIABLE_VALUE = 274, + VARIABLE_VALUE = 275, + LIST_WS = 276, + ENDOFFILE = 277 + }; + + }; + /// Token type. + typedef token::yytokentype token_type; + + /// Build a parser object. + Parser (TQMake::Lexer* lexer_yyarg, TQValueStack& projects_yyarg, int depth_yyarg); + virtual ~Parser (); + + /// Parse. + /// \returns 0 iff parsing succeeded. + virtual int parse (); + + /// The current debugging stream. + std::ostream& debug_stream () const; + /// Set the current debugging stream. + void set_debug_stream (std::ostream &); + + /// Type for debugging levels. + typedef int debug_level_type; + /// The current debugging level. + debug_level_type debug_level () const; + /// Set the current debugging level. + void set_debug_level (debug_level_type l); + + private: + /// Report a syntax error. + /// \param loc where the syntax error is found. + /// \param msg a description of the syntax error. + virtual void error (const location_type& loc, const std::string& msg); + + /// Generate an error message. + /// \param state the state where the error occurred. + /// \param tok the look-ahead token. + virtual std::string yysyntax_error_ (int yystate); + +#if YYDEBUG + /// \brief Report a symbol value on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); + /// \brief Report a symbol on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); +#endif /* ! YYDEBUG */ + + + /// State numbers. + typedef int state_type; + /// State stack type. + typedef stack state_stack_type; + /// Semantic value stack type. + typedef stack semantic_stack_type; + /// location stack type. + typedef stack location_stack_type; + + /// The state stack. + state_stack_type yystate_stack_; + /// The semantic value stack. + semantic_stack_type yysemantic_stack_; + /// The location stack. + location_stack_type yylocation_stack_; + + /// Internal symbol numbers. + typedef unsigned char token_number_type; + /* Tables. */ + /// For a state, the index in \a yytable_ of its portion. + static const signed char yypact_[]; + static const signed char yypact_ninf_; + + /// For a state, default rule to reduce. + /// Unless\a yytable_ specifies something else to do. + /// Zero means the default is an error. + static const unsigned char yydefact_[]; + + static const signed char yypgoto_[]; + static const signed char yydefgoto_[]; + + /// What to do in a state. + /// \a yytable_[yypact_[s]]: what to do in state \a s. + /// - if positive, shift that token. + /// - if negative, reduce the rule which number is the opposite. + /// - if zero, do what YYDEFACT says. + static const signed char yytable_[]; + static const signed char yytable_ninf_; + + static const unsigned char yycheck_[]; + + /// For a state, its accessing symbol. + static const unsigned char yystos_[]; + + /// For a rule, its LHS. + static const unsigned char yyr1_[]; + /// For a rule, its RHS length. + static const unsigned char yyr2_[]; + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE + /// For a symbol, its name in clear. + static const char* const yytname_[]; +#endif + +#if YYERROR_VERBOSE + /// Convert the symbol name \a n to a form suitable for a diagnostic. + virtual std::string yytnamerr_ (const char *n); +#endif + +#if YYDEBUG + /// A type to store symbol numbers and -1. + typedef signed char rhs_number_type; + /// A `-1'-separated list of the rules' RHS. + static const rhs_number_type yyrhs_[]; + /// For each rule, the index of the first RHS symbol in \a yyrhs_. + static const unsigned char yyprhs_[]; + /// For each rule, its source line number. + static const unsigned short int yyrline_[]; + /// For each scanner token number, its symbol number. + static const unsigned short int yytoken_number_[]; + /// Report on the debug stream that the rule \a r is going to be reduced. + virtual void yy_reduce_print_ (int r); + /// Print the state stack on the debug stream. + virtual void yystack_print_ (); +#endif + + /// Convert a scanner token number \a t to a symbol number. + token_number_type yytranslate_ (int t); + + /// \brief Reclaim the memory associated to a symbol. + /// \param yymsg Why this token is reclaimed. + /// \param yytype The symbol type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + inline void yydestruct_ (const char* yymsg, + int yytype, + semantic_type* yyvaluep, + location_type* yylocationp); + + /// Pop \a n symbols the three stacks. + inline void yypop_ (unsigned int n = 1); + + /* Constants. */ + static const int yyeof_; + /* LAST_ -- Last index in TABLE_. */ + static const int yylast_; + static const int yynnts_; + static const int yyempty_; + static const int yyfinal_; + static const int yyterror_; + static const int yyerrcode_; + static const int yyntokens_; + static const unsigned int yyuser_token_number_max_; + static const token_number_type yyundef_token_; + + /* Debugging. */ + int yydebug_; + std::ostream* yycdebug_; + + + /* User arguments. */ + TQMake::Lexer* lexer; + TQValueStack& projects; + int depth; + }; +} + + +#endif /* ! defined PARSER_HEADER_H */ diff --git a/buildtools/lib/parsers/qmake/qmake_yacc.hpp b/buildtools/lib/parsers/qmake/qmake_yacc.hpp deleted file mode 100644 index fd130e65..00000000 --- a/buildtools/lib/parsers/qmake/qmake_yacc.hpp +++ /dev/null @@ -1,418 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Skeleton interface for Bison LALR(1) parsers in C++ - - Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C++ LALR(1) parser skeleton written by Akim Demaille. */ - -#ifndef PARSER_HEADER_H -# define PARSER_HEADER_H - -#include -#include -#include "stack.hh" - -namespace TQMake -{ - class position; - class location; -} - -/* First part of user declarations. */ -#line 1 "qmake.yy" - -/*************************************************************************** - * Copyright (C) 2005 by Alexander Dymo * - * adymo@kdevelop.org * - * Copyright (C) 2006 by Andreas Pakulat * - * apaku@gmx.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License as * - * published by the Free Software Foundation; either version 2 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -/** -@file qmake.yy -TQMake Parser - -Simple LALR parser which builds the syntax tree (see @ref TQMake::AST). - -@todo Recognize comments after statements like: -SOURCES = foo #regognize me - -@fixme Parser fails on files that do not end with a newline -@fixme 1 shift/reduce conflict in "line_body" rule -*/ - -#include -#include "qmakeast.h" -#include - -#define YYSTYPE_IS_DECLARED - -namespace TQMake -{ - class Lexer; - -/** -The yylval type. -*/ -struct Result { - Result(): node(0) {} - - /**Type of semantic value for simple grammar rules.*/ - TQString value; - /**Type of semantic value for grammar rules which are parts of AST.*/ - AST *node; - /**Type of semantic value for "multiline_values" grammar rule. - Each line of multiline value is stored as a string in the list. - - For example we have in .pro file: - @code - SOURCE = foo1.cpp \ - foo2.cpp \ - foo3.cpp foo4.cpp - @endcode - The string list will be populated with three strings: -
-    foo1.cpp
-    foo2.cpp
-    foo3.cpp foo4.cpp
-    
- */ - TQStringList values; - TQString indent; -}; - -#define YYSTYPE Result -typedef Result YYSTYPE; -} - -extern int TQMakelex( TQMake::Result* yylval, TQMake::Lexer* lexer ); - -/** -The stack to store ProjectAST pointers when a new child -ProjectAST is created and filled with statements. - -Parser creates root ProjectAST for a .pro file, pushes it onto the stack and starts -adding statements. Each statement is added as a child StatementAST to the ProjectAST -currently on the top in the stack. - -When a scope or function scope statement is parsed, the child ProjectAST is created -and pushed onto the stack. Therefore all statements which belong to the scope -or function scope are added as childs to their direct parent (scope or function scope). -*/ -//TQValueStack projects; - -/** -The current depth of AST node is stored here. -AST depth is important to know because automatic indentation can -be easily implemented (the parser itself looses all information -about indentation). -*/ -// int depth = 0; - -/* -To debug this parser, put the line below into the next bison file section. -Don't forget to uncomment "yydebug = 1" line in qmakedriver.cpp. -%debug -*/ - - -/* Line 35 of lalr1.cc. */ -#line 165 "qmake_yacc.hpp" - -#include "location.hh" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 1 -#endif - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ -do { \ - if (N) \ - { \ - (Current).begin = (Rhs)[1].begin; \ - (Current).end = (Rhs)[N].end; \ - } \ - else \ - { \ - (Current).begin = (Current).end = (Rhs)[0].end; \ - } \ -} while (false) -#endif - -namespace TQMake -{ - - /// A Bison parser. - class Parser - { - public: - /// Symbol semantic values. -#ifndef YYSTYPE - typedef int semantic_type; -#else - typedef YYSTYPE semantic_type; -#endif - /// Symbol locations. - typedef location location_type; - /// Tokens. - struct token - { - /* Tokens. */ - enum yytokentype { - ID_SIMPLE = 258, - EQ = 259, - PLUSEQ = 260, - MINUSEQ = 261, - STAREQ = 262, - TILDEEQ = 263, - LBRACE = 264, - RBRACE = 265, - COLON = 266, - NEWLINE = 267, - COMMENT = 268, - CONT = 269, - COMMENT_CONT = 270, - RCURLY = 271, - LCURLY = 272, - ID_ARGS = 273, - QUOTED_VARIABLE_VALUE = 274, - VARIABLE_VALUE = 275, - LIST_WS = 276, - ENDOFFILE = 277 - }; - - }; - /// Token type. - typedef token::yytokentype token_type; - - /// Build a parser object. - Parser (TQMake::Lexer* lexer_yyarg, TQValueStack& projects_yyarg, int depth_yyarg); - virtual ~Parser (); - - /// Parse. - /// \returns 0 iff parsing succeeded. - virtual int parse (); - - /// The current debugging stream. - std::ostream& debug_stream () const; - /// Set the current debugging stream. - void set_debug_stream (std::ostream &); - - /// Type for debugging levels. - typedef int debug_level_type; - /// The current debugging level. - debug_level_type debug_level () const; - /// Set the current debugging level. - void set_debug_level (debug_level_type l); - - private: - /// Report a syntax error. - /// \param loc where the syntax error is found. - /// \param msg a description of the syntax error. - virtual void error (const location_type& loc, const std::string& msg); - - /// Generate an error message. - /// \param state the state where the error occurred. - /// \param tok the look-ahead token. - virtual std::string yysyntax_error_ (int yystate); - -#if YYDEBUG - /// \brief Report a symbol value on the debug stream. - /// \param yytype The token type. - /// \param yyvaluep Its semantic value. - /// \param yylocationp Its location. - virtual void yy_symbol_value_print_ (int yytype, - const semantic_type* yyvaluep, - const location_type* yylocationp); - /// \brief Report a symbol on the debug stream. - /// \param yytype The token type. - /// \param yyvaluep Its semantic value. - /// \param yylocationp Its location. - virtual void yy_symbol_print_ (int yytype, - const semantic_type* yyvaluep, - const location_type* yylocationp); -#endif /* ! YYDEBUG */ - - - /// State numbers. - typedef int state_type; - /// State stack type. - typedef stack state_stack_type; - /// Semantic value stack type. - typedef stack semantic_stack_type; - /// location stack type. - typedef stack location_stack_type; - - /// The state stack. - state_stack_type yystate_stack_; - /// The semantic value stack. - semantic_stack_type yysemantic_stack_; - /// The location stack. - location_stack_type yylocation_stack_; - - /// Internal symbol numbers. - typedef unsigned char token_number_type; - /* Tables. */ - /// For a state, the index in \a yytable_ of its portion. - static const signed char yypact_[]; - static const signed char yypact_ninf_; - - /// For a state, default rule to reduce. - /// Unless\a yytable_ specifies something else to do. - /// Zero means the default is an error. - static const unsigned char yydefact_[]; - - static const signed char yypgoto_[]; - static const signed char yydefgoto_[]; - - /// What to do in a state. - /// \a yytable_[yypact_[s]]: what to do in state \a s. - /// - if positive, shift that token. - /// - if negative, reduce the rule which number is the opposite. - /// - if zero, do what YYDEFACT says. - static const signed char yytable_[]; - static const signed char yytable_ninf_; - - static const unsigned char yycheck_[]; - - /// For a state, its accessing symbol. - static const unsigned char yystos_[]; - - /// For a rule, its LHS. - static const unsigned char yyr1_[]; - /// For a rule, its RHS length. - static const unsigned char yyr2_[]; - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE - /// For a symbol, its name in clear. - static const char* const yytname_[]; -#endif - -#if YYERROR_VERBOSE - /// Convert the symbol name \a n to a form suitable for a diagnostic. - virtual std::string yytnamerr_ (const char *n); -#endif - -#if YYDEBUG - /// A type to store symbol numbers and -1. - typedef signed char rhs_number_type; - /// A `-1'-separated list of the rules' RHS. - static const rhs_number_type yyrhs_[]; - /// For each rule, the index of the first RHS symbol in \a yyrhs_. - static const unsigned char yyprhs_[]; - /// For each rule, its source line number. - static const unsigned short int yyrline_[]; - /// For each scanner token number, its symbol number. - static const unsigned short int yytoken_number_[]; - /// Report on the debug stream that the rule \a r is going to be reduced. - virtual void yy_reduce_print_ (int r); - /// Print the state stack on the debug stream. - virtual void yystack_print_ (); -#endif - - /// Convert a scanner token number \a t to a symbol number. - token_number_type yytranslate_ (int t); - - /// \brief Reclaim the memory associated to a symbol. - /// \param yymsg Why this token is reclaimed. - /// \param yytype The symbol type. - /// \param yyvaluep Its semantic value. - /// \param yylocationp Its location. - inline void yydestruct_ (const char* yymsg, - int yytype, - semantic_type* yyvaluep, - location_type* yylocationp); - - /// Pop \a n symbols the three stacks. - inline void yypop_ (unsigned int n = 1); - - /* Constants. */ - static const int yyeof_; - /* LAST_ -- Last index in TABLE_. */ - static const int yylast_; - static const int yynnts_; - static const int yyempty_; - static const int yyfinal_; - static const int yyterror_; - static const int yyerrcode_; - static const int yyntokens_; - static const unsigned int yyuser_token_number_max_; - static const token_number_type yyundef_token_; - - /* Debugging. */ - int yydebug_; - std::ostream* yycdebug_; - - - /* User arguments. */ - TQMake::Lexer* lexer; - TQValueStack& projects; - int depth; - }; -} - - -#endif /* ! defined PARSER_HEADER_H */ diff --git a/buildtools/lib/parsers/qmake/qmakedriver.cpp b/buildtools/lib/parsers/qmake/qmakedriver.cpp index 40fd9bd9..8b9b722a 100644 --- a/buildtools/lib/parsers/qmake/qmakedriver.cpp +++ b/buildtools/lib/parsers/qmake/qmakedriver.cpp @@ -28,7 +28,7 @@ #include #include "qmake_lex.h" -#include "qmake_yacc.hpp" +#include "qmake_yacc.h" namespace TQMake { diff --git a/buildtools/lib/parsers/qmake/stack.h b/buildtools/lib/parsers/qmake/stack.h new file mode 100644 index 00000000..1c18d4d0 --- /dev/null +++ b/buildtools/lib/parsers/qmake/stack.h @@ -0,0 +1,129 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Stack handling for Bison parsers in C++ + + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef BISON_STACK_H +# define BISON_STACK_H + +#include + +namespace TQMake +{ + template > + class stack + { + public: + + // Hide our reversed order. + typedef typename S::reverse_iterator iterator; + typedef typename S::const_reverse_iterator const_iterator; + + stack () : seq_ () + { + } + + stack (unsigned int n) : seq_ (n) + { + } + + inline + T& + operator [] (unsigned int i) + { + return seq_[i]; + } + + inline + const T& + operator [] (unsigned int i) const + { + return seq_[i]; + } + + inline + void + push (const T& t) + { + seq_.push_front (t); + } + + inline + void + pop (unsigned int n = 1) + { + for (; n; --n) + seq_.pop_front (); + } + + inline + unsigned int + height () const + { + return seq_.size (); + } + + inline const_iterator begin () const { return seq_.rbegin (); } + inline const_iterator end () const { return seq_.rend (); } + + private: + + S seq_; + }; + + /// Present a slice of the top of a stack. + template > + class slice + { + public: + + slice (const S& stack, + unsigned int range) : stack_ (stack), + range_ (range) + { + } + + inline + const T& + operator [] (unsigned int i) const + { + return stack_[range_ - i]; + } + + private: + + const S& stack_; + unsigned int range_; + }; +} + +#endif // not BISON_STACK_H diff --git a/buildtools/lib/parsers/qmake/stack.hh b/buildtools/lib/parsers/qmake/stack.hh deleted file mode 100644 index dfc6c67e..00000000 --- a/buildtools/lib/parsers/qmake/stack.hh +++ /dev/null @@ -1,129 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Stack handling for Bison parsers in C++ - - Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -#ifndef BISON_STACK_HH -# define BISON_STACK_HH - -#include - -namespace TQMake -{ - template > - class stack - { - public: - - // Hide our reversed order. - typedef typename S::reverse_iterator iterator; - typedef typename S::const_reverse_iterator const_iterator; - - stack () : seq_ () - { - } - - stack (unsigned int n) : seq_ (n) - { - } - - inline - T& - operator [] (unsigned int i) - { - return seq_[i]; - } - - inline - const T& - operator [] (unsigned int i) const - { - return seq_[i]; - } - - inline - void - push (const T& t) - { - seq_.push_front (t); - } - - inline - void - pop (unsigned int n = 1) - { - for (; n; --n) - seq_.pop_front (); - } - - inline - unsigned int - height () const - { - return seq_.size (); - } - - inline const_iterator begin () const { return seq_.rbegin (); } - inline const_iterator end () const { return seq_.rend (); } - - private: - - S seq_; - }; - - /// Present a slice of the top of a stack. - template > - class slice - { - public: - - slice (const S& stack, - unsigned int range) : stack_ (stack), - range_ (range) - { - } - - inline - const T& - operator [] (unsigned int i) const - { - return stack_[range_ - i]; - } - - private: - - const S& stack_; - unsigned int range_; - }; -} - -#endif // not BISON_STACK_HH -- cgit v1.2.1