SOURCES: kdevelop-qmake_parser.patch (NEW) - new

arekm arekm at pld-linux.org
Fri Feb 9 13:04:31 CET 2007


Author: arekm                        Date: Fri Feb  9 12:04:31 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- new

---- Files affected:
SOURCES:
   kdevelop-qmake_parser.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/kdevelop-qmake_parser.patch
diff -u /dev/null SOURCES/kdevelop-qmake_parser.patch:1.1
--- /dev/null	Fri Feb  9 13:04:31 2007
+++ SOURCES/kdevelop-qmake_parser.patch	Fri Feb  9 13:04:25 2007
@@ -0,0 +1,5932 @@
+diff -u --exclude=.svn -Nur kdev_3.4.0.org/buildtools/lib/parsers/qmake/location.hh kdev_3.4.0/buildtools/lib/parsers/qmake/location.hh
+--- kdev_3.4.0.org/buildtools/lib/parsers/qmake/location.hh	1970-01-01 01:00:00.000000000 +0100
++++ kdev_3.4.0/buildtools/lib/parsers/qmake/location.hh	2007-02-07 20:35:17.000000000 +0100
+@@ -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.hh
++ ** Define the QMake::location class.
++ */
++
++#ifndef BISON_LOCATION_HH
++# define BISON_LOCATION_HH
++
++# include <iostream>
++# include <string>
++# include "position.hh"
++
++namespace QMake
++{
++
++  /// 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 -u --exclude=.svn -Nur kdev_3.4.0.org/buildtools/lib/parsers/qmake/Makefile.am kdev_3.4.0/buildtools/lib/parsers/qmake/Makefile.am
+--- kdev_3.4.0.org/buildtools/lib/parsers/qmake/Makefile.am	2007-02-07 21:15:37.000000000 +0100
++++ kdev_3.4.0/buildtools/lib/parsers/qmake/Makefile.am	2007-02-07 20:35:17.000000000 +0100
+@@ -10,22 +10,20 @@
+ METASOURCES = AUTO
+ lib_LTLIBRARIES = libkdevqmakeparser.la
+ libkdevqmakeparser_la_LDFLAGS = -no-undefined $(all_libraries) $(LIB_KIO)
+-libkdevqmakeparser_la_SOURCES = qmakeast.cpp qmakedriver.cpp qmake_yacc.cpp \
+-	qmakeastvisitor.cpp
++libkdevqmakeparser_la_SOURCES = qmake_lex.cpp qmake_yacc.cpp qmakeast.cpp \
++	qmakeastvisitor.cpp qmakedriver.cpp
+ 
+ kdevelopbuildtoolsincludedir = $(includedir)/kdevelop/buildtools/parsers/qmake
+ kdevelopbuildtoolsinclude_HEADERS = qmakeast.h qmakedriver.h qmakeastvisitor.h
+ 
+ parser:
+ 	cd $(srcdir) ; \
+-	bison -d qmake.yy -o qmake_yacc.cpp ; \
+-	mv -f qmake_yacc.hpp qmake_yacc.h ; \
++	bison -d qmake.yy -oqmake_yacc.cpp ; \
+ 	flex -oqmake_lex.cpp qmake.ll
+ 
+ parser_dbg:
+ 	cd $(srcdir) ; \
+-	bison -d qmake.yy -r all -k -t -o qmake_yacc.cpp ; \
+-	mv -f qmake_yacc.hpp qmake_yacc.h ; \
++	bison -d qmake.yy -r all -k -t -oqmake_yacc.cpp ; \
+ 	flex -d -oqmake_lex.cpp qmake.ll
+ 
+ EXTRA_DIST = qmake.yy qmake.ll
+@@ -35,3 +33,4 @@
+ DOXYGEN_DOCDIRPREFIX = kdevparser
+ include ../../../../Doxyfile.am
+ 
++noinst_HEADERS = qmake_lex.h
+diff -u --exclude=.svn -Nur kdev_3.4.0.org/buildtools/lib/parsers/qmake/position.hh kdev_3.4.0/buildtools/lib/parsers/qmake/position.hh
+--- kdev_3.4.0.org/buildtools/lib/parsers/qmake/position.hh	1970-01-01 01:00:00.000000000 +0100
++++ kdev_3.4.0/buildtools/lib/parsers/qmake/position.hh	2007-02-07 20:35:14.000000000 +0100
+@@ -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.hh
++ ** Define the QMake::position class.
++ */
++
++#ifndef BISON_POSITION_HH
++# define BISON_POSITION_HH
++
++# include <iostream>
++# include <string>
++
++namespace QMake
++{
++  /// 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 -u --exclude=.svn -Nur kdev_3.4.0.org/buildtools/lib/parsers/qmake/qmakedriver.cpp kdev_3.4.0/buildtools/lib/parsers/qmake/qmakedriver.cpp
+--- kdev_3.4.0.org/buildtools/lib/parsers/qmake/qmakedriver.cpp	2007-02-07 21:15:37.000000000 +0100
++++ kdev_3.4.0/buildtools/lib/parsers/qmake/qmakedriver.cpp	2007-02-07 20:49:28.000000000 +0100
+@@ -20,57 +20,67 @@
+ #include "qmakedriver.h"
+ #include "qmakeast.h"
+ 
+-#include <stdio.h>
+ #include <qvaluestack.h>
+ #include <kio/netaccess.h>
+ 
+-extern FILE *yyin, *yyout;
+-extern int yyparse();
+-extern int yydebug;
+-typedef struct yy_buffer_state *YY_BUFFER_STATE;
+-extern YY_BUFFER_STATE yy_scan_string(const char*);
+-extern void yy_delete_buffer(YY_BUFFER_STATE);
+-extern QValueStack<QMake::ProjectAST *> projects;
++#include <iostream>
++#include <fstream>
++#include <sstream>
++
++#include "qmake_lex.h"
++#include "qmake_yacc.hpp"
+ 
+ namespace QMake {
+ 
+-int Driver::parseFile(const char *fileName, ProjectAST **ast)
++int Driver::parseFile(const char *fileName, ProjectAST **ast, int debug)
+ {
+-    yyin = fopen(fileName, "r");
+-    if (yyin == 0)
++    std::ifstream inf( fileName, std::ios::in );
++    if ( !inf.is_open() )
+     {
+         *ast = 0;
+         return 1;
+     }
+ //     yydebug = 1;
+-    int ret = yyparse();
+-    *ast = projects.top();
++    Lexer l(&inf);
++    l.set_debug(debug);
++    int depth = 0;
++    QValueStack<ProjectAST*> stack;
++    Parser p(&l, stack, depth);
++    p.set_debug_level(debug);
++    int ret = p.parse();
++    *ast = stack.top();
+     (*ast)->setFileName(fileName);
+     return ret;
+ }
+ 
+-int Driver::parseFile(QString fileName, ProjectAST **ast)
++int Driver::parseFile(QString fileName, ProjectAST **ast, int debug)
+ {
+-    return parseFile(fileName.ascii(), ast);
++    return parseFile(fileName.ascii(), ast, debug);
+ }
+ 
+-int Driver::parseFile(KURL fileName, ProjectAST **ast)
++int Driver::parseFile(KURL fileName, ProjectAST **ast, int debug)
+ {
+     QString tmpFile;
+     int ret = 0;
+     if (KIO::NetAccess::download(fileName, tmpFile, 0))
+-        ret = parseFile(tmpFile, ast);
++        ret = parseFile(tmpFile, ast, debug);
+     KIO::NetAccess::removeTempFile(tmpFile);
+     return ret;
+ }
+ 
+-int Driver::parseString( const char* string, ProjectAST **ast )
++int Driver::parseString( const char* string, ProjectAST **ast, int debug )
+ {
+-    YY_BUFFER_STATE state = yy_scan_string( string );
+-    int ret = yyparse();
+-    *ast = projects.top();
++    std::istringstream ins;
++    ins.str(string);
++    Lexer l(&ins);
++    l.set_debug(debug);
++    int depth = 0;
++    QValueStack<ProjectAST*> stack;
++    Parser p(&l, stack, depth);
++    p.set_debug_level(debug);
++    int ret = p.parse();
++    *ast = stack.top();
+     (*ast)->setFileName("");
+-    yy_delete_buffer( state );
+     return ret;
+ }
+ 
+diff -u --exclude=.svn -Nur kdev_3.4.0.org/buildtools/lib/parsers/qmake/qmakedriver.h kdev_3.4.0/buildtools/lib/parsers/qmake/qmakedriver.h
+--- kdev_3.4.0.org/buildtools/lib/parsers/qmake/qmakedriver.h	2007-02-07 21:15:37.000000000 +0100
++++ kdev_3.4.0/buildtools/lib/parsers/qmake/qmakedriver.h	2007-02-07 20:35:13.000000000 +0100
+@@ -20,10 +20,8 @@
+ #ifndef QMAKEQMAKEDRIVER_H
+ #define QMAKEQMAKEDRIVER_H
+ 
+-#include "qmakeast.h"
+-
+-#include <qvaluelist.h>
+-#include <kurl.h>
++class QString;
++class KURL;
+ 
+ namespace QMake {
+ 
+@@ -45,26 +43,11 @@
+     initialize it on its own.
+     @return The result of parsing. Result is 0 on success and <> 0 on failure.
+     */
+-    static int parseFile(const char *fileName, ProjectAST **ast);
+-    static int parseFile(QString fileName, ProjectAST **ast);
+-    static int parseFile(KURL fileName, ProjectAST **ast);
+-    static int parseString(const char* string, ProjectAST **ast);
+-
+-/*    template<class Op>
+-    static void walkAST(Op &op, const ProjectAST *ast)
+-    {
+-//         op(ast);
+-        for (QValueList<QMake::AST*>::const_iterator it = ast->statements.constBegin();
+-                it != ast->statements.constEnd(); ++it)
+-        {
+-            const AST *child = *it;
+-            if (child->nodeType() == AST::ProjectAST)
+-                walkAST<Op>(op, static_cast<const QMake::ProjectAST*>(child));
+-            else
+-                op(child);
+-        }
+-    }
+-*/
++    static int parseFile(const char *fileName, ProjectAST **ast, int debug);
++    static int parseFile(QString fileName, ProjectAST **ast, int debug);
++    static int parseFile(KURL fileName, ProjectAST **ast, int debug);
++    static int parseString(const char* string, ProjectAST **ast, int debug);
++
+ };
+ 
+ }
+diff -u --exclude=.svn -Nur kdev_3.4.0.org/buildtools/lib/parsers/qmake/qmake_lex.cpp kdev_3.4.0/buildtools/lib/parsers/qmake/qmake_lex.cpp
+--- kdev_3.4.0.org/buildtools/lib/parsers/qmake/qmake_lex.cpp	2007-02-07 21:15:37.000000000 +0100
++++ kdev_3.4.0/buildtools/lib/parsers/qmake/qmake_lex.cpp	2007-02-07 20:35:11.000000000 +0100
+@@ -14,13 +14,17 @@
+ #define FLEX_BETA
+ #endif
+ 
++    /* The c++ scanner is a mess. The FlexLexer.h header file relies on the
++     * following macro. This is required in order to pass the c++-multiple-scanners
++     * test in the regression suite. We get reports that it breaks inheritance.
++     * We will address this in a future release of flex, or omit the C++ scanner
++     * altogether.
++     */
++    #define yyFlexLexer yyFlexLexer
++
+ /* First, we deal with  platform-specific or compiler-specific issues. */
+ 
+ /* begin standard C headers. */
+-#include <stdio.h>
+-#include <string.h>
+-#include <errno.h>
+-#include <stdlib.h>
+ 
+ /* end standard C headers. */
+ 
+@@ -87,6 +91,13 @@
+ 
+ #endif /* ! FLEXINT_H */
+ 
++/* begin standard C++ headers. */
++#include <iostream> 
++#include <errno.h>
++#include <cstdlib>
++#include <cstring>
++/* end standard C++ headers. */
++
+ #ifdef __cplusplus
+ 
+ /* The "const" storage-class-modifier is valid. */
+@@ -134,7 +145,7 @@
+ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+ 
+ /* Special action meaning "start processing a new file". */
+-#define YY_NEW_FILE yyrestart(yyin  )
++#define YY_NEW_FILE yyrestart( yyin  )
+ 
+ #define YY_END_OF_BUFFER_CHAR 0
+ 
+@@ -154,13 +165,24 @@
+ 
+ extern int yyleng;
+ 
+-extern FILE *yyin, *yyout;
+-
+ #define EOB_ACT_CONTINUE_SCAN 0
+ #define EOB_ACT_END_OF_FILE 1
+ #define EOB_ACT_LAST_MATCH 2
+ 
+-    #define YY_LESS_LINENO(n)
++    /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
++     *       access to the local variable yy_act. Since yyless() is a macro, it would break
++     *       existing scanners that call yyless() from OUTSIDE yylex. 
++     *       One obvious solution it to make yy_act a global. I tried that, and saw
++     *       a 5% performance hit in a non-yylineno scanner, because yy_act is
++     *       normally declared as a register variable-- so it is not worth it.
++     */
++    #define  YY_LESS_LINENO(n) \
++            do { \
++                int yyl;\
++                for ( yyl = n; yyl < yyleng; ++yyl )\
++                    if ( yytext[yyl] == '\n' )\
++                        --yylineno;\
++            }while(0)
+     
+ /* Return all but the first "n" matched characters back to the input stream. */
+ #define yyless(n) \
+@@ -192,7 +214,8 @@
+ #define YY_STRUCT_YY_BUFFER_STATE
+ struct yy_buffer_state
+ 	{
+-	FILE *yy_input_file;
++
++	std::istream* yy_input_file;
+ 
+ 	char *yy_ch_buf;		/* input buffer */
+ 	char *yy_buf_pos;		/* current position in input buffer */
+@@ -253,11 +276,6 @@
+ 	};
+ #endif /* !YY_STRUCT_YY_BUFFER_STATE */
+ 
+-/* Stack of input buffers. */
+-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+-
+ /* We provide macros for accessing buffer states in case in the
+  * future we want to put the buffer states in a more general
+  * "scanner state".
+@@ -273,39 +291,6 @@
+  */
+ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+ 
+-/* yy_hold_char holds the character lost when yytext is formed. */
+-static char yy_hold_char;
+-static int yy_n_chars;		/* number of characters read into yy_ch_buf */
+-int yyleng;
+-
+-/* Points to current character in buffer. */
+-static char *yy_c_buf_p = (char *) 0;
+-static int yy_init = 0;		/* whether we need to initialize */
+-static int yy_start = 0;	/* start state number */
+-
+-/* Flag which is used to allow yywrap()'s to do buffer switches
+- * instead of setting up a fresh yyin.  A bit of a hack ...
+- */
+-static int yy_did_buffer_switch_on_eof;
+-
+-void yyrestart (FILE *input_file  );
+-void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
+-YY_BUFFER_STATE yy_create_buffer (FILE *file,int size  );
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list