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

KDevelop QMake parser

  • buildtools
  • lib
  • parsers
  • qmake
qmakeast.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 "qmakeast.h"
21
22#include <kdebug.h>
23
24namespace TQMake {
25
26//AST
27
28AST::~AST()
29{
30 for (TQValueList<AST*>::iterator it = m_children.begin(); it != m_children.end(); ++it)
31 {
32 AST *node = *it;
33 delete node;
34 }
35 m_children.clear();
36}
37
38void AST::addChildAST(AST *node)
39{
40 m_children.append(node);
41}
42
43void AST::removeChildAST(AST *node)
44{
45 m_children.remove(node);
46}
47
48void AST::writeBack(TQString &buffer)
49{
50 for (TQValueList<AST*>::const_iterator it = m_children.constBegin();
51 it != m_children.constEnd(); ++it)
52 {
53 if (*it)
54 {
55 (*it)->writeBack(buffer);
56 }
57 }
58}
59
60TQString AST::indentation()
61{
62 TQString result;
63 for (int i = 0; i < depth(); i++)
64 result += " ";
65 return result;
66}
67
68//ProjectAST
69
70void ProjectAST::writeBack(TQString &buffer)
71{
72 bool hasActualStatements = false;
73 for (TQValueList<TQMake::AST*>::const_iterator it = m_children.begin(); it != m_children.end(); ++it)
74 {
75 if ((*it)->nodeType() != AST::IncludeAST)
76 {
77 hasActualStatements = true;
78 break;
79 }
80 }
81
82 if (isScope())
83 {
84 if( !buffer.endsWith(": ") )
85 buffer += indentation();
86 buffer += scopedID;
87 if( m_children.count() == 1 )
88 buffer += " : ";
89 else
90 buffer += " {";
91 }
92 else if (isFunctionScope())
93 {
94 if( !buffer.endsWith(": ") )
95 buffer += indentation();
96 buffer += scopedID + "(" + args + ")";
97 if( m_children.count() == 1 && hasActualStatements )
98 buffer += ": ";
99 else if( (m_children.count() > 0 && hasActualStatements) )
100 buffer += "{";
101 else
102 buffer += "";
103 }
104 else if( !buffer.endsWith(": ") )
105 buffer += indentation();
106 AST::writeBack(buffer);
107 if (isScope() && m_children.count() > 1 )
108 buffer += indentation() + "}";
109
110 if (isFunctionScope() && (hasActualStatements) && m_children.count() > 1)
111 buffer += indentation() + "}";
112}
113
114
115void ProjectAST::setLineEnding( ProjectAST::LineEnding l )
116{
117 m_lineEnding = l;
118}
119
120ProjectAST::LineEnding ProjectAST::lineEnding()
121{
122 return m_lineEnding;
123}
124
125//AssignmentAST
126
127AssignmentAST::~AssignmentAST()
128{
129}
130
131void AssignmentAST::writeBack(TQString &buffer)
132{
133 if( !buffer.endsWith(": ") )
134 buffer += indentation();
135 buffer += scopedID + " " + op;
136 if( values.first().stripWhiteSpace() != "" )
137 buffer += " ";
138 buffer += values.join("");
139}
140
141
142//NewLineAST
143
144void NewLineAST::writeBack(TQString &buffer)
145{
146 buffer += "\n";
147}
148
149
150//CommentAST
151
152void CommentAST::writeBack(TQString &buffer)
153{
154 if( !buffer.endsWith(": ") )
155 buffer += indentation();
156 buffer += comment;
157}
158
159
160//IncludeAST
161
162void IncludeAST::writeBack(TQString &/*buffer*/)
163{
164}
165
166}
TQMake::AST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition qmakeast.cpp:48
TQMake::AST::indentation
virtual TQString indentation()
Definition qmakeast.cpp:60
TQMake::AST::m_children
TQValueList< AST * > m_children
The list of child AST nodes.
Definition qmakeast.h:82
TQMake::AST::addChildAST
virtual void addChildAST(AST *node)
Adds child AST node to this node.
Definition qmakeast.cpp:38
TQMake::AST::depth
int depth() const
Definition qmakeast.h:77
TQMake::AST::removeChildAST
virtual void removeChildAST(AST *node)
Removes child AST node from this node.
Definition qmakeast.cpp:43
TQMake::AST::IncludeAST
@ IncludeAST
.pri include.
Definition qmakeast.h:50
TQMake::AST::AST
AST(NodeType nodeType)
Constructs AST with given node type.
Definition qmakeast.h:55
TQMake::AssignmentAST::op
TQString op
Operator.
Definition qmakeast.h:184
TQMake::AssignmentAST::scopedID
TQString scopedID
Scoped name of the variable.
Definition qmakeast.h:182
TQMake::AssignmentAST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition qmakeast.cpp:131
TQMake::AssignmentAST::values
TQStringList values
List of values.
Definition qmakeast.h:186
TQMake::CommentAST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition qmakeast.cpp:152
TQMake::CommentAST::comment
TQString comment
Comment text.
Definition qmakeast.h:216
TQMake::IncludeAST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition qmakeast.cpp:162
TQMake::NewLineAST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition qmakeast.cpp:144
TQMake::ProjectAST::isFunctionScope
bool isFunctionScope() const
Definition qmakeast.h:132
TQMake::ProjectAST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition qmakeast.cpp:70
TQMake::ProjectAST::isScope
bool isScope() const
Definition qmakeast.h:130
TQMake::ProjectAST::scopedID
TQString scopedID
Scoped identifier (scope name or function name).
Definition qmakeast.h:143
TQMake::ProjectAST::args
TQString args
Function arguments.
Definition qmakeast.h:145
qmakeast.h
Abstract Syntax Tree (AST) class declarations.

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.