• 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 
24 namespace TQMake {
25 
26 //AST
27 
28 AST::~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 
38 void AST::addChildAST(AST *node)
39 {
40  m_children.append(node);
41 }
42 
43 void AST::removeChildAST(AST *node)
44 {
45  m_children.remove(node);
46 }
47 
48 void 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 
60 TQString AST::indentation()
61 {
62  TQString result;
63  for (int i = 0; i < depth(); i++)
64  result += " ";
65  return result;
66 }
67 
68 //ProjectAST
69 
70 void 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 
115 void ProjectAST::setLineEnding( ProjectAST::LineEnding l )
116 {
117  m_lineEnding = l;
118 }
119 
120 ProjectAST::LineEnding ProjectAST::lineEnding()
121 {
122  return m_lineEnding;
123 }
124 
125 //AssignmentAST
126 
127 AssignmentAST::~AssignmentAST()
128 {
129 }
130 
131 void 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 
144 void NewLineAST::writeBack(TQString &buffer)
145 {
146  buffer += "\n";
147 }
148 
149 
150 //CommentAST
151 
152 void CommentAST::writeBack(TQString &buffer)
153 {
154  if( !buffer.endsWith(": ") )
155  buffer += indentation();
156  buffer += comment;
157 }
158 
159 
160 //IncludeAST
161 
162 void IncludeAST::writeBack(TQString &/*buffer*/)
163 {
164 }
165 
166 }
167 
168 // kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
169 
170 
TQMake::AST::indentation
virtual TQString indentation()
Definition: qmakeast.cpp:60
TQMake::AST::removeChildAST
virtual void removeChildAST(AST *node)
Removes child AST node from this node.
Definition: qmakeast.cpp:43
TQMake::AST::IncludeAST
.pri include.
Definition: qmakeast.h:50
TQMake::AssignmentAST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition: qmakeast.cpp:131
TQMake
Definition: location.hh:47
TQMake::AST::m_children
TQValueList< AST * > m_children
The list of child AST nodes.
Definition: qmakeast.h:82
TQMake::IncludeAST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition: qmakeast.cpp:162
TQMake::AST::addChildAST
virtual void addChildAST(AST *node)
Adds child AST node to this node.
Definition: qmakeast.cpp:38
TQMake::AST::AST
AST(NodeType nodeType)
Constructs AST with given node type.
Definition: qmakeast.h:55
TQMake::AST::depth
int depth() const
Definition: qmakeast.h:77
qmakeast.h
Abstract Syntax Tree (AST) class declarations.
TQMake::ProjectAST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition: qmakeast.cpp:70
TQMake::AST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition: qmakeast.cpp:48
TQMake::AST
AST node.
Definition: qmakeast.h:42
TQMake::CommentAST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition: qmakeast.cpp:152
TQMake::NewLineAST::writeBack
virtual void writeBack(TQString &buffer)
Writes information stored in the AST into the buffer.
Definition: qmakeast.cpp:144

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.8.13
This website is maintained by Timothy Pearson.