summaryrefslogtreecommitdiffstats
path: root/lib/cppparser/lexer.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:56:07 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:56:07 +0000
commitd6f8bbb45b267065a6907e71ff9c98bb6d161241 (patch)
treed109539636691d7b03036ca1c0ed29dbae6577cf /lib/cppparser/lexer.cpp
parent3331a47a9cad24795c7440ee8107143ce444ef34 (diff)
downloadtdevelop-d6f8bbb45b267065a6907e71ff9c98bb6d161241.tar.gz
tdevelop-d6f8bbb45b267065a6907e71ff9c98bb6d161241.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1157658 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lib/cppparser/lexer.cpp')
-rw-r--r--lib/cppparser/lexer.cpp90
1 files changed, 45 insertions, 45 deletions
diff --git a/lib/cppparser/lexer.cpp b/lib/cppparser/lexer.cpp
index 3f2ec712..97fe0dc0 100644
--- a/lib/cppparser/lexer.cpp
+++ b/lib/cppparser/lexer.cpp
@@ -23,12 +23,12 @@
#include <kdebug.h>
#include <klocale.h>
-#include <qregexp.h>
-#include <qmap.h>
-#include <qvaluelist.h>
+#include <tqregexp.h>
+#include <tqmap.h>
+#include <tqvaluelist.h>
#if defined( KDEVELOP_BGPARSER )
-#include <qthread.h>
+#include <tqthread.h>
class KDevTread: public QThread
{
@@ -53,8 +53,8 @@ using namespace std;
struct LexerData
{
- typedef QMap<QString, QString> Scope;
- typedef QValueList<Scope> StaticChain;
+ typedef TQMap<TQString, TQString> Scope;
+ typedef TQValueList<Scope> StaticChain;
StaticChain staticChain;
@@ -69,13 +69,13 @@ struct LexerData
staticChain.pop_front();
}
- void bind( const QString& name, const QString& value )
+ void bind( const TQString& name, const TQString& value )
{
Q_ASSERT( staticChain.size() > 0 );
staticChain.front().insert( name, value );
}
- bool hasBind( const QString& name ) const
+ bool hasBind( const TQString& name ) const
{
StaticChain::ConstIterator it = staticChain.begin();
while( it != staticChain.end() ){
@@ -89,7 +89,7 @@ struct LexerData
return false;
}
- QString apply( const QString& name ) const
+ TQString apply( const TQString& name ) const
{
StaticChain::ConstIterator it = staticChain.begin();
while( it != staticChain.end() ){
@@ -100,7 +100,7 @@ struct LexerData
return scope[ name ];
}
- return QString::null;
+ return TQString::null;
}
};
@@ -126,7 +126,7 @@ Lexer::~Lexer()
delete( d );
}
-void Lexer::setSource( const QString& source )
+void Lexer::setSource( const TQString& source )
{
reset();
m_source = source;
@@ -136,7 +136,7 @@ void Lexer::setSource( const QString& source )
if( !source.isEmpty() ) {
m_currentChar = m_source[0];
} else {
- m_currentChar = QChar::null;
+ m_currentChar = TQChar::null;
}
tokenize();
@@ -152,7 +152,7 @@ void Lexer::reset()
m_index = 0;
m_size = 0;
m_tokens.clear();
- m_source = QString::null;
+ m_source = TQString::null;
m_ptr = 0;
m_endPtr = 0;
m_startLine = false;
@@ -169,12 +169,12 @@ void Lexer::reset()
// ### should all be done with a "long" type IMO
int Lexer::toInt( const Token& token )
{
- QString s = token.text();
+ TQString s = token.text();
if( token.type() == Token_number_literal ){
// hex literal ?
if( s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
return s.mid( 2 ).toInt( 0, 16 );
- QString n;
+ TQString n;
int i = 0;
while( i < int(s.length()) && s[i].isDigit() )
n += s[i++];
@@ -220,8 +220,8 @@ void Lexer::nextToken( Token& tk, bool stopOnNewline )
int startLine = m_currentLine;
int startColumn = m_currentColumn;
- QChar ch = currentChar();
- QChar ch1 = peekChar();
+ TQChar ch = currentChar();
+ TQChar ch1 = peekChar();
if( ch.isNull() || ch.isSpace() ){
/* skip */
@@ -233,7 +233,7 @@ void Lexer::nextToken( Token& tk, bool stopOnNewline )
int start = currentPosition();
readIdentifier(); // read the directive
- QString directive = m_source.mid( start, currentPosition() - start );
+ TQString directive = m_source.mid( start, currentPosition() - start );
handleDirective( directive );
} else if( m_startLine && m_skipping[ m_ifLevel ] ){
@@ -301,7 +301,7 @@ void Lexer::nextToken( Token& tk, bool stopOnNewline )
Macro m = m_driver->macro( ide );
m_driver->usingMacro( m );
- QString ellipsisArg;
+ TQString ellipsisArg;
if( m.hasArguments() ){
int endIde = currentPosition();
@@ -314,11 +314,11 @@ void Lexer::nextToken( Token& tk, bool stopOnNewline )
while( currentChar() && argIdx<argCount ){
readWhiteSpaces();
- QString argName = m.argumentList()[ argIdx ];
+ TQString argName = m.argumentList()[ argIdx ];
bool ellipsis = argName == "...";
- QString arg = readArgument();
+ TQString arg = readArgument();
if( !ellipsis )
d->bind( argName, arg );
@@ -363,7 +363,7 @@ void Lexer::nextToken( Token& tk, bool stopOnNewline )
// tokenize the macro body
- QString textToInsert;
+ TQString textToInsert;
setEndPtr( offset( currentPosition() + m.body().length() ) );
@@ -383,24 +383,24 @@ void Lexer::nextToken( Token& tk, bool stopOnNewline )
if( tok == Token_eof )
break;
- QString tokText = tok.text();
+ TQString tokText = tok.text();
HashedString str = (tok == Token_identifier && d->hasBind(tokText)) ? d->apply( tokText ) : tokText;
if( str == ide ){
//Problem p( i18n("unsafe use of macro '%1', macro is ignored").arg(ide.str()), m_currentLine, m_currentColumn, Problem::Level_Warning );
//m_driver->addProblem( m_driver->currentFileName(), p );
m_driver->removeMacro( ide );
- // str = QString::null;
+ // str = TQString::null;
}
if( stringify ) {
- textToInsert.append( QString::fromLatin1("\"") + str.str() + QString::fromLatin1("\" ") );
+ textToInsert.append( TQString::fromLatin1("\"") + str.str() + TQString::fromLatin1("\" ") );
} else if( merge ){
textToInsert.truncate( textToInsert.length() - 1 );
- textToInsert.append( str.str() + QString::fromLatin1(" ") );
+ textToInsert.append( str.str() + TQString::fromLatin1(" ") );
} else if( tok == Token_ellipsis && d->hasBind("...") ){
textToInsert.append( ellipsisArg );
} else {
- textToInsert.append( str.str() + QString::fromLatin1(" ") );
+ textToInsert.append( str.str() + TQString::fromLatin1(" ") );
}
}
@@ -419,7 +419,7 @@ void Lexer::nextToken( Token& tk, bool stopOnNewline )
tk.setStartPosition( startLine, startColumn );
tk.setEndPosition( m_currentLine, m_currentColumn );
} else if( m_skipWordsEnabled ){
- __gnu_cxx::hash_map< HashedString, QPair<SkipType, QString> >::iterator pos = m_words.find( ide );
+ __gnu_cxx::hash_map< HashedString, QPair<SkipType, TQString> >::iterator pos = m_words.find( ide );
if( pos != m_words.end() ){
if( (*pos).second.first == SkipWordAndArguments ){
readWhiteSpaces();
@@ -430,7 +430,7 @@ void Lexer::nextToken( Token& tk, bool stopOnNewline )
#if defined( KDEVELOP_BGPARSER )
qthread_yield();
#endif
- insertCurrent( QString(" ") + (*pos).second.second + QString(" ") );
+ insertCurrent( TQString(" ") + (*pos).second.second + TQString(" ") );
}
} else if( /*qt_rx.exactMatch(ide) ||*/
ide.str().endsWith("EXPORT") ||
@@ -512,7 +512,7 @@ void Lexer::resetSkipWords()
m_words.clear();
}
-void Lexer::addSkipWord( const QString& word, SkipType skipType, const QString& str )
+void Lexer::addSkipWord( const TQString& word, SkipType skipType, const TQString& str )
{
m_words[ word ] = qMakePair( skipType, str );
}
@@ -541,17 +541,17 @@ void Lexer::skip( int l, int r )
m_currentColumn = svCurrentColumn;
}
-QString Lexer::readArgument()
+TQString Lexer::readArgument()
{
int count = 0;
- QString arg;
+ TQString arg;
readWhiteSpaces();
while( currentChar() ){
readWhiteSpaces();
- QChar ch = currentChar();
+ TQChar ch = currentChar();
if( ch.isNull() || (!count && (ch == ',' || ch == ')')) )
break;
@@ -572,7 +572,7 @@ QString Lexer::readArgument()
return arg.stripWhiteSpace();
}
-void Lexer::handleDirective( const QString& directive )
+void Lexer::handleDirective( const TQString& directive )
{
m_inPreproc = true;
@@ -651,7 +651,7 @@ void Lexer::processDefine( Macro& m )
int startMacroName = currentPosition();
readIdentifier();
- QString macroName = m_source.mid( startMacroName, int(currentPosition()-startMacroName) );
+ TQString macroName = m_source.mid( startMacroName, int(currentPosition()-startMacroName) );
m.setName( macroName );
if( currentChar() == '(' ){
@@ -670,7 +670,7 @@ void Lexer::processDefine( Macro& m )
else
readIdentifier();
- QString arg = m_source.mid( startArg, int(currentPosition()-startArg) );
+ TQString arg = m_source.mid( startArg, int(currentPosition()-startArg) );
m.addArgument( Macro::Argument(arg) );
@@ -687,7 +687,7 @@ void Lexer::processDefine( Macro& m )
setPreprocessorEnabled( true );
- QString body;
+ TQString body;
while( currentChar() && currentChar() != '\n' ){
if( currentChar().isSpace() ){
@@ -700,7 +700,7 @@ void Lexer::processDefine( Macro& m )
//Do not ignore c-style comments, those may be useful in the body, and ignoring them using this check causes problems
if( tk.type() != -1 && (tk.type() != Token_comment || ( tk.text().length() >= 2 && tk.text()[1] == '*') ) ){
- QString s = tk.text();
+ TQString s = tk.text();
body += s;
}
}
@@ -792,16 +792,16 @@ void Lexer::processInclude()
readWhiteSpaces( false );
if( currentChar() ){
- QChar ch = currentChar();
+ TQChar ch = currentChar();
if( ch == '"' || ch == '<' ){
nextChar();
- QChar ch2 = ch == QChar('"') ? QChar('"') : QChar('>');
+ TQChar ch2 = ch == TQChar('"') ? TQChar('"') : TQChar('>');
int startWord = currentPosition();
while( currentChar() && currentChar() != ch2 )
nextChar();
if( currentChar() ){
- QString word = m_source.mid( startWord, int(currentPosition()-startWord) );
+ TQString word = m_source.mid( startWord, int(currentPosition()-startWord) );
m_driver->addDependence( m_driver->currentFileName(),
Dependence(word, ch == '"' ? Dep_Local : Dep_Global) );
nextChar();
@@ -815,7 +815,7 @@ void Lexer::processUndef()
readWhiteSpaces();
int startWord = currentPosition();
readIdentifier();
- QString word = m_source.mid( startWord, currentPosition() - startWord );
+ TQString word = m_source.mid( startWord, currentPosition() - startWord );
Macro m( word, "" );
m.setFileName( m_driver->currentFileName() );
@@ -845,7 +845,7 @@ int Lexer::macroPrimary()
case '!':
case '~':
{
- QChar tk = currentChar();
+ TQChar tk = currentChar();
nextChar();
int result = macroPrimary();
if( tk == '-' ) return -result;
@@ -1003,7 +1003,7 @@ int Lexer::macroLogicalAnd()
nextChar( 2 );
int start = currentPosition();
result = macroBoolOr() && result;
- QString s = m_source.mid( start, currentPosition() - start );
+ TQString s = m_source.mid( start, currentPosition() - start );
}
return result;
}
@@ -1026,7 +1026,7 @@ int Lexer::macroExpression()
}
// *IMPORTANT*
-// please, don't include lexer.moc here, because Lexer isn't a QObject class!!
+// please, don't include lexer.moc here, because Lexer isn't a TQObject class!!
// if you have problem while recompiling try to remove cppsupport/.deps,
// cppsupport/Makefile.in and rerun automake/autoconf