• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop QMake parser
 

KDevelop QMake parser

  • buildtools
  • lib
  • parsers
  • qmake
qmakedriver.cpp
1/***************************************************************************
2 * Copyright (C) 2005 by Alexander Dymo *
3 * adymo@kdevelop.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Library General Public License as *
7 * published by the Free Software Foundation; either version 2 of the *
8 * License, or (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Library General Public *
16 * License along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20#include "qmakedriver.h"
21#include "qmakeast.h"
22
23#include <tqvaluestack.h>
24#include <tdeio/netaccess.h>
25
26#include <iostream>
27#include <fstream>
28#include <sstream>
29
30#include "qmake_lex.h"
31#include "qmake_yacc.h"
32
33namespace TQMake {
34
35int Driver::parseFile(const char *fileName, ProjectAST **ast, int debug)
36{
37 std::ifstream inf( fileName, std::ios::in );
38 if ( !inf.is_open() )
39 {
40 *ast = 0;
41 return 1;
42 }
43// yydebug = 1;
44 Lexer l(&inf);
45 l.set_debug(debug);
46 int depth = 0;
47 TQValueStack<ProjectAST*> stack;
48 Parser p(&l, stack, depth);
49 p.set_debug_level(debug);
50 int ret = p.parse();
51 *ast = stack.top();
52 (*ast)->setFileName(fileName);
53 switch( l.lineending() )
54 {
55 case TQMake::Lexer::Windows:
56 (*ast)->setLineEnding(TQMake::ProjectAST::Windows);
57 break;
58 case TQMake::Lexer::MacOS:
59 (*ast)->setLineEnding(TQMake::ProjectAST::MacOS);
60 break;
61 case TQMake::Lexer::Unix:
62 default:
63 (*ast)->setLineEnding(TQMake::ProjectAST::Unix);
64 break;
65 }
66 return ret;
67}
68
69int Driver::parseFile(TQString fileName, ProjectAST **ast, int debug)
70{
71 return parseFile(fileName.ascii(), ast, debug);
72}
73
74int Driver::parseFile(KURL fileName, ProjectAST **ast, int debug)
75{
76 TQString tmpFile;
77 int ret = 0;
78 if (TDEIO::NetAccess::download(fileName, tmpFile, 0))
79 ret = parseFile(tmpFile, ast, debug);
80 TDEIO::NetAccess::removeTempFile(tmpFile);
81 return ret;
82}
83
84int Driver::parseString( const char* string, ProjectAST **ast, int debug )
85{
86 std::istringstream ins;
87 ins.str(string);
88 Lexer l(&ins);
89 l.set_debug(debug);
90 int depth = 0;
91 TQValueStack<ProjectAST*> stack;
92 Parser p(&l, stack, depth);
93 p.set_debug_level(debug);
94 int ret = p.parse();
95 *ast = stack.top();
96 (*ast)->setFileName("");
97 switch( l.lineending() )
98 {
99 case TQMake::Lexer::Windows:
100 (*ast)->setLineEnding(TQMake::ProjectAST::Windows);
101 break;
102 case TQMake::Lexer::MacOS:
103 (*ast)->setLineEnding(TQMake::ProjectAST::MacOS);
104 break;
105 case TQMake::Lexer::Unix:
106 default:
107 (*ast)->setLineEnding(TQMake::ProjectAST::Unix);
108 break;
109 }
110 return ret;
111}
112
113}
TQMake::Driver::parseFile
static int parseFile(const char *fileName, ProjectAST **ast, int debug)
Parses the file fileName and stores the resulting ProjectAST root into ast.
Definition qmakedriver.cpp:35
TQMake::Parser
A Bison parser.
Definition qmake_yacc.h:210
TQMake::Parser::parse
virtual int parse()
Parse.
Definition qmake_yacc.cpp:244
TQMake::Parser::set_debug_level
void set_debug_level(debug_level_type l)
Set the current debugging level.
Definition qmake_yacc.cpp:237
TQMake::ProjectAST
Project AST node.
Definition qmakeast.h:106
qmakeast.h
Abstract Syntax Tree (AST) class declarations.
qmakedriver.h
Driver for a qmake parser.

KDevelop QMake parser

Skip menu "KDevelop QMake parser"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

KDevelop QMake parser

Skip menu "KDevelop QMake parser"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop QMake parser by doxygen 1.15.0
This website is maintained by Timothy Pearson.