diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:56:07 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:56:07 +0000 |
commit | d6f8bbb45b267065a6907e71ff9c98bb6d161241 (patch) | |
tree | d109539636691d7b03036ca1c0ed29dbae6577cf /languages/perl/perlparser.cpp | |
parent | 3331a47a9cad24795c7440ee8107143ce444ef34 (diff) | |
download | tdevelop-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 'languages/perl/perlparser.cpp')
-rw-r--r-- | languages/perl/perlparser.cpp | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/languages/perl/perlparser.cpp b/languages/perl/perlparser.cpp index a6a5a834..ad0b5de2 100644 --- a/languages/perl/perlparser.cpp +++ b/languages/perl/perlparser.cpp @@ -18,11 +18,11 @@ #include "perlparser.h" #include <kdebug.h> -#include <qfile.h> -#include <qregexp.h> -#include <qfileinfo.h> +#include <tqfile.h> +#include <tqregexp.h> +#include <tqfileinfo.h> -perlparser::perlparser(KDevCore* core,CodeModel* model, QString interpreter) { +perlparser::perlparser(KDevCore* core,CodeModel* model, TQString interpreter) { m_core = core; m_model = model; m_interpreter=interpreter; @@ -34,7 +34,7 @@ perlparser::perlparser(KDevCore* core,CodeModel* model, QString interpreter) { perlparser::~perlparser(){ } -const QStringList perlparser::UseFiles() +const TQStringList perlparser::UseFiles() { return m_usefiles; } @@ -43,13 +43,13 @@ void perlparser::initialParse() { m_usefiles.clear(); } -void perlparser::parse(const QString &fileName){ - QFile f(fileName); +void perlparser::parse(const TQString &fileName){ + TQFile f(fileName); if (!f.open(IO_ReadOnly)) return; - QTextStream stream(&f); - QStringList list; - QString rawline; + TQTextStream stream(&f); + TQStringList list; + TQString rawline; while (!stream.eof()) { rawline = stream.readLine(); list.append(rawline.stripWhiteSpace().local8Bit()); @@ -63,23 +63,23 @@ void perlparser::parse(const QString &fileName){ m_model->addFile( m_file ); } -void perlparser::parseLines(QStringList* lines,const QString &fileName) +void perlparser::parseLines(TQStringList* lines,const TQString &fileName) { - QRegExp packagere("^[ \t]*package[ \t]+([+A-Za-z0-9_:]*).*\\;"); - QRegExp basere("^[ \t]*use[ \t]+base[ \t]*\\(\'*\"*([A-Za-z0-9_:]*)"); - QRegExp libre("^[ \t]*use[ \t]+lib[ \t]*\\(\'*\"*([A-Za-z0-9_:]*)"); - QRegExp usere("^[ \t]*use[ \t]+([+A-Za-z0-9_:]*).*\\;"); - QRegExp isare("^[ \t]*@ISA[ \t=qw\\(\'\"]*([A-Za-z0-9_: ]*)"); - QRegExp globalre("^[ \t]*our[ \t]+\\(*([ \t,$%@*+A-Za-z0-9_]*)\\)*.*"); - QRegExp myre("^[ \t]*my[ \t]+\\(*([ \t,$%@*+A-Za-z0-9_]*)\\)*.*"); - QRegExp subre("^[ \t]*sub[ \t]+([A-Za-z0-9_]+)([A-Za-z0-9_]|([ \t]*[{])?)$"); - QRegExp blessre("bless[ \t]*[\\( ]*([,$%@*+A-Za-z0-9_]*).*;"); - QRegExp namere("^[ \t]*([$%@*])([A-Za-z0-9_]*).*$"); - QRegExp privatere("^_([A-Za-z0-9_]*)"); - QRegExp startpod("^=[a-z0-9]+ [a-z0-9]*"); - QRegExp cutpod("^=cut"); - - QString line; + TQRegExp packagere("^[ \t]*package[ \t]+([+A-Za-z0-9_:]*).*\\;"); + TQRegExp basere("^[ \t]*use[ \t]+base[ \t]*\\(\'*\"*([A-Za-z0-9_:]*)"); + TQRegExp libre("^[ \t]*use[ \t]+lib[ \t]*\\(\'*\"*([A-Za-z0-9_:]*)"); + TQRegExp usere("^[ \t]*use[ \t]+([+A-Za-z0-9_:]*).*\\;"); + TQRegExp isare("^[ \t]*@ISA[ \t=qw\\(\'\"]*([A-Za-z0-9_: ]*)"); + TQRegExp globalre("^[ \t]*our[ \t]+\\(*([ \t,$%@*+A-Za-z0-9_]*)\\)*.*"); + TQRegExp myre("^[ \t]*my[ \t]+\\(*([ \t,$%@*+A-Za-z0-9_]*)\\)*.*"); + TQRegExp subre("^[ \t]*sub[ \t]+([A-Za-z0-9_]+)([A-Za-z0-9_]|([ \t]*[{])?)$"); + TQRegExp blessre("bless[ \t]*[\\( ]*([,$%@*+A-Za-z0-9_]*).*;"); + TQRegExp namere("^[ \t]*([$%@*])([A-Za-z0-9_]*).*$"); + TQRegExp privatere("^_([A-Za-z0-9_]*)"); + TQRegExp startpod("^=[a-z0-9]+ [a-z0-9]*"); + TQRegExp cutpod("^=cut"); + + TQString line; //clear all "last" know things m_lastsub=""; @@ -98,7 +98,7 @@ void perlparser::parseLines(QStringList* lines,const QString &fileName) bool endpod = false; //check if we are parsing a script or module - QFileInfo fi(fileName); + TQFileInfo fi(fileName); bool inscript =(fi.extension() == "pl"); kdDebug(9016) << "inscript : " << inscript << "," << fi.extension() << endl; @@ -106,7 +106,7 @@ void perlparser::parseLines(QStringList* lines,const QString &fileName) addScript(fileName,lineNo,fi.fileName()); } - for ( QStringList::Iterator it = lines->begin(); it != lines->end(); ++it ) { + for ( TQStringList::Iterator it = lines->begin(); it != lines->end(); ++it ) { ++lineNo; line = (*it).local8Bit(); //empty line ? @@ -121,7 +121,7 @@ void perlparser::parseLines(QStringList* lines,const QString &fileName) //sub matching if (subre.search(line)>=0){ - QString subname=subre.cap(1); + TQString subname=subre.cap(1); kdDebug(9016) << "subre match [" << subname << "]" << endl; bool prive = privatere.search(subname) >= 0; kdDebug(9016) << "prive match [" << prive << "]" << endl; @@ -136,12 +136,12 @@ void perlparser::parseLines(QStringList* lines,const QString &fileName) //our matching if (globalre.search(line)>=0) { //splitup multible ours - QString varlist=globalre.cap(1); + TQString varlist=globalre.cap(1); kdDebug(9016) << "globalre match [" << varlist <<"]" << endl; - QStringList vars=QStringList::split(",",varlist); - for ( QStringList::Iterator it = vars.begin(); it != vars.end(); ++it ) { + TQStringList vars=TQStringList::split(",",varlist); + for ( TQStringList::Iterator it = vars.begin(); it != vars.end(); ++it ) { if (namere.search(*it)>=0) { - QString var = namere.cap(2); + TQString var = namere.cap(2); kdDebug(9016) << "namere match [" << var << "]" << endl; if (m_lastpackage) { addAttributetoPackage(fileName,lineNo,var); } else { addAttributetoScript(fileName,lineNo,var); } @@ -161,7 +161,7 @@ void perlparser::parseLines(QStringList* lines,const QString &fileName) //base matching if ((basere.search(line)>=0) && (!m_inscript)) { - QString parent = basere.cap(1); + TQString parent = basere.cap(1); //create child & parent classes kdDebug(9016) << "basere match [" << parent << "]" << endl; addClass(fileName,lineNo); @@ -169,7 +169,7 @@ void perlparser::parseLines(QStringList* lines,const QString &fileName) continue; } else { if (libre.search(line)>=0) { - QString path = libre.cap(1); + TQString path = libre.cap(1); //add lib to INC path list kdDebug(9016) << "libre match [" << path << "]" << endl; m_INClist.append(path); @@ -177,7 +177,7 @@ void perlparser::parseLines(QStringList* lines,const QString &fileName) } else { if (usere.search(line)>=0) { //add lib to use list for later parsing - QString lib = usere.cap(1); + TQString lib = usere.cap(1); kdDebug(9016) << "usere match [" << lib << "]" << endl; addUseLib(lib); continue; @@ -186,7 +186,7 @@ void perlparser::parseLines(QStringList* lines,const QString &fileName) } //base if ((isare.search(line)>=0) && (!m_inscript)) { - QString parent = isare.cap(1); + TQString parent = isare.cap(1); //create child & parent classes kdDebug(9016) << "isare match [" << parent << "]" << endl; addClass(fileName,lineNo); @@ -195,7 +195,7 @@ void perlparser::parseLines(QStringList* lines,const QString &fileName) } //isa if ((packagere.search(line)>=0) && (!m_inscript)) { - QString package=packagere.cap(1); + TQString package=packagere.cap(1); kdDebug(9016) << "packagere match [" << package << "]" << endl; addPackage(fileName,lineNo,package); continue; @@ -204,7 +204,7 @@ void perlparser::parseLines(QStringList* lines,const QString &fileName) } // for lines loop } -void perlparser::addPackage(const QString& fileName ,int lineNr , const QString& name) +void perlparser::addPackage(const TQString& fileName ,int lineNr , const TQString& name) { kdDebug(9016) << "AddPackage [" << name << "]" << endl; NamespaceDom package = m_model->create<NamespaceModel>(); @@ -234,7 +234,7 @@ void perlparser::addPackage(const QString& fileName ,int lineNr , const QString& } -void perlparser::addScript(const QString& fileName ,int lineNr ,const QString& name) +void perlparser::addScript(const TQString& fileName ,int lineNr ,const TQString& name) { kdDebug(9016) << "addScript [" << name << "]" << endl; @@ -269,7 +269,7 @@ void perlparser::addScript(const QString& fileName ,int lineNr ,const QString& n } -void perlparser::addAttributetoPackage(const QString& fileName ,int lineNr ,const QString& name) +void perlparser::addAttributetoPackage(const TQString& fileName ,int lineNr ,const TQString& name) { kdDebug(9016) << "addAttributetoPackage [" << name << "]" << endl; VariableDom var = m_model->create<VariableModel>(); @@ -286,7 +286,7 @@ void perlparser::addAttributetoPackage(const QString& fileName ,int lineNr ,cons m_lastattr=name; } -void perlparser::addAttributetoScript(const QString& fileName ,int lineNr ,const QString& name) +void perlparser::addAttributetoScript(const TQString& fileName ,int lineNr ,const TQString& name) { kdDebug(9016) << "addAttributetoScript [" << name << "]" << endl; VariableDom var = m_model->create<VariableModel>(); @@ -301,7 +301,7 @@ void perlparser::addAttributetoScript(const QString& fileName ,int lineNr ,const } } -void perlparser::addClass(const QString& fileName ,int lineNr) +void perlparser::addClass(const TQString& fileName ,int lineNr) { kdDebug(9016) << "addClass [ " << m_lastpackagename << " ]" << endl; if (m_lastpackage->hasClass(m_lastpackagename)) { @@ -318,7 +318,7 @@ void perlparser::addClass(const QString& fileName ,int lineNr) } } -void perlparser::addConstructor(const QString& fileName ,int lineNr ,const QString& name) +void perlparser::addConstructor(const TQString& fileName ,int lineNr ,const TQString& name) { kdDebug(9016) << "set Constructor["<< name << "]" << endl; @@ -344,7 +344,7 @@ void perlparser::addConstructor(const QString& fileName ,int lineNr ,const QStri m_lastclass->setStartPosition(lineNr,0); } -void perlparser::addGlobalSub(const QString& fileName ,int lineNr ,const QString& name ,bool privatesub) +void perlparser::addGlobalSub(const TQString& fileName ,int lineNr ,const TQString& name ,bool privatesub) { kdDebug(9016) << "addGlobalSub[ " << name << "]" << endl; @@ -367,7 +367,7 @@ void perlparser::addGlobalSub(const QString& fileName ,int lineNr ,const QString m_lastsub=name; } -void perlparser::addScriptSub(const QString& fileName ,int lineNr ,const QString& name ,bool privatesub) +void perlparser::addScriptSub(const TQString& fileName ,int lineNr ,const TQString& name ,bool privatesub) { kdDebug(9016) << "addScriptSub[ " << name << "]" << endl; @@ -385,7 +385,7 @@ void perlparser::addScriptSub(const QString& fileName ,int lineNr ,const QString m_lastsub=name; } -void perlparser::addClassMethod(const QString& fileName ,int lineNr ,const QString& name ,bool privatesub) +void perlparser::addClassMethod(const TQString& fileName ,int lineNr ,const TQString& name ,bool privatesub) { kdDebug(9016) << "addClassMethod[ " << name << "]" << endl; FunctionDom method = m_model->create<FunctionModel>(); @@ -406,7 +406,7 @@ void perlparser::addClassMethod(const QString& fileName ,int lineNr ,const QStri m_lastsub=name; } -void perlparser::addPackageSub(const QString& fileName ,int lineNr ,const QString& name ,bool privatesub) +void perlparser::addPackageSub(const TQString& fileName ,int lineNr ,const TQString& name ,bool privatesub) { kdDebug(9016) << "addPackageSub[ " << name << "]" << endl; FunctionDom method = m_model->create<FunctionModel>(); @@ -424,7 +424,7 @@ void perlparser::addPackageSub(const QString& fileName ,int lineNr ,const QStrin m_lastsub=name; } -void perlparser::addParentClass(const QString& parent) +void perlparser::addParentClass(const TQString& parent) { kdDebug(9016) << "addParentClass[ " << parent << "]" << endl; if (m_lastclass) { @@ -434,7 +434,7 @@ void perlparser::addParentClass(const QString& parent) } } -void perlparser::addUseLib(const QString& lib) +void perlparser::addUseLib(const TQString& lib) { if (!m_model->hasFile(lib)) { if (m_usefiles.findIndex(lib) == -1) { @@ -450,12 +450,12 @@ void perlparser::getPerlINC() { m_INClist.clear(); - QString cmd = "/usr/bin/perl -e\" print join('|',@INC);\""; - QString result; + TQString cmd = "/usr/bin/perl -e\" print join('|',@INC);\""; + TQString result; FILE *fd = popen(cmd.local8Bit().data(), "r"); char buffer[4090]; - QByteArray array; + TQByteArray array; while (!feof(fd)) { int n = fread(buffer, 1, 2048, fd); @@ -464,26 +464,26 @@ void perlparser::getPerlINC() { return; } array.setRawData(buffer, n); - result=QString::QString(array); + result=TQString::TQString(array); array.resetRawData(buffer, n); } pclose(fd); //get INC list so we can use it to parse "use" modules - m_INClist = QStringList::split(QString("|"),result); + m_INClist = TQStringList::split(TQString("|"),result); kdDebug(9016) << "INC " << m_INClist.size() << " "<< result << endl; } -QString perlparser::findLib( const QString& lib) +TQString perlparser::findLib( const TQString& lib) { - QString result; + TQString result; - QString file=lib; - file.replace( QRegExp("::"), QString("/")); + TQString file=lib; + file.replace( TQRegExp("::"), TQString("/")); //find the correct path by using the INC list - QStringList::Iterator inc = m_INClist.begin(); + TQStringList::Iterator inc = m_INClist.begin(); while((inc != m_INClist.end()) && (result.isEmpty()) ) { - QFileInfo fi((*inc) + "/" + file + ".pm"); + TQFileInfo fi((*inc) + "/" + file + ".pm"); if ( fi.exists() ) { result = (*inc) + "/" + file + ".pm"; } |