diff options
Diffstat (limited to 'microbe/parser.cpp')
-rw-r--r-- | microbe/parser.cpp | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/microbe/parser.cpp b/microbe/parser.cpp index 15335e0..0bf3fea 100644 --- a/microbe/parser.cpp +++ b/microbe/parser.cpp @@ -28,9 +28,9 @@ #include <assert.h> #include <kdebug.h> #include <klocale.h> -#include <qfile.h> -#include <qregexp.h> -#include <qstring.h> +#include <tqfile.h> +#include <tqregexp.h> +#include <tqstring.h> #include <iostream> using namespace std; @@ -199,11 +199,11 @@ Code * Parser::parse( const SourceLineList & lines ) { m_currentSourceLine = (*sit).content; - QString line = (*sit).text(); + TQString line = (*sit).text(); - QString command; // e.g. "delay", "for", "subroutine", "increment", etc + TQString command; // e.g. "delay", "for", "subroutine", "increment", etc { - int spacepos = line.find(' '); + int spacepos = line.tqfind(' '); if ( spacepos >= 0 ) command = line.left( spacepos ); else @@ -212,13 +212,13 @@ Code * Parser::parse( const SourceLineList & lines ) OutputFieldMap fieldMap; if ( (*sit).content.line() >= 0 ) - m_code->append( new Instr_sourceCode( QString("#MSRC\t%1; %2\t%3").arg( (*sit).content.line() + 1 ).arg( (*sit).content.url() ).arg( (*sit).content.text() ) )); + m_code->append( new Instr_sourceCode( TQString("#MSRC\t%1; %2\t%3").tqarg( (*sit).content.line() + 1 ).tqarg( (*sit).content.url() ).tqarg( (*sit).content.text() ) )); bool showBracesInSource = (*sit).hasBracedCode(); if ( showBracesInSource ) m_code->append(new Instr_sourceCode("{")); // Use the first token in the line to look up the statement type - DefinitionMap::Iterator dmit = m_definitionMap.find(command); + DefinitionMap::Iterator dmit = m_definitionMap.tqfind(command); if(dmit == m_definitionMap.end()) { if( !processAssignment( (*sit).text() ) ) @@ -226,7 +226,7 @@ Code * Parser::parse( const SourceLineList & lines ) // Not an assignement, maybe a label if( (*sit).isLabel() ) { - QString label = (*sit).text().left( (*sit).text().length() - 1 ); + TQString label = (*sit).text().left( (*sit).text().length() - 1 ); ///TODO sanity check label name and then do error like "Bad label" m_pPic->Slabel( label ); } @@ -257,7 +257,7 @@ Code * Parser::parse( const SourceLineList & lines ) if( errorInLine || finishLine) break; Field field = (*sdit); - QString token; + TQString token; bool saveToken = false; bool saveBraced = false; @@ -269,7 +269,7 @@ Code * Parser::parse( const SourceLineList & lines ) case (Field::Variable): case (Field::Name): { - newPosition = line.find( ' ', position ); + newPosition = line.tqfind( ' ', position ); if(position == newPosition) { newPosition = -1; @@ -303,12 +303,12 @@ Code * Parser::parse( const SourceLineList & lines ) { nextField = (*it); if(nextField.type() == Field::FixedString) - newPosition = line.find(QRegExp("\\b" + nextField.string() + "\\b")); + newPosition = line.tqfind(TQRegExp("\\b" + nextField.string() + "\\b")); // Although code is not neccessarily braced, after an expression it is the only // sensilbe way to have it. else if(nextField.type() == Field::Code) { - newPosition = line.find("{"); + newPosition = line.tqfind("{"); if(newPosition == -1) newPosition = line.length() + 1; } else if(nextField.type() == Field::Newline) @@ -367,7 +367,7 @@ Code * Parser::parse( const SourceLineList & lines ) case (Field::FixedString): { // Is the string found, and is it starting in the right place? - int stringPosition = line.find(QRegExp("\\b"+field.string()+"\\b")); + int stringPosition = line.tqfind(TQRegExp("\\b"+field.string()+"\\b")); if( stringPosition != position || stringPosition == -1 ) { if( !field.compulsory() ) @@ -402,7 +402,7 @@ Code * Parser::parse( const SourceLineList & lines ) if( nextField.type() == Field::FixedString ) { nextStatement = *(++StatementList::Iterator(sit)); - newPosition = nextStatement.text().find(QRegExp("\\b" + nextField.string() + "\\b")); + newPosition = nextStatement.text().tqfind(TQRegExp("\\b" + nextField.string() + "\\b")); if(newPosition != 0) { // If the next field is optional just carry on as nothing happened, @@ -458,15 +458,15 @@ Code * Parser::parse( const SourceLineList & lines ) return m_code; } -bool Parser::processAssignment(const QString &line) +bool Parser::processAssignment(const TQString &line) { - QStringList tokens = Statement::tokenise(line); + TQStringList tokens = Statement::tokenise(line); // Have to have at least 3 tokens for an assignment; if ( tokens.size() < 3 ) return false; - QString firstToken = tokens[0]; + TQString firstToken = tokens[0]; firstToken = mb->alias(firstToken); // Well firstly we look to see if it is a known variable. @@ -476,7 +476,7 @@ bool Parser::processAssignment(const QString &line) // Look for port variables first. - if ( firstToken.contains(".") ) + if ( firstToken.tqcontains(".") ) { PortPin portPin = m_pPic->toPortPin( firstToken ); @@ -487,7 +487,7 @@ bool Parser::processAssignment(const QString &line) if ( tokens[1] != "=" ) mistake( Microbe::UnassignedPin ); - QString state = tokens[2]; + TQString state = tokens[2]; if( state == "high" ) m_pPic->Ssetlh( portPin, true ); else if( state == "low" ) @@ -502,14 +502,14 @@ bool Parser::processAssignment(const QString &line) if ( tokens[1] != "=" ) mistake( Microbe::UnassignedPort, tokens[1] ); - Expression( m_pPic, mb, m_currentSourceLine, false ).compileExpression(line.mid(line.find("=")+1)); + Expression( m_pPic, mb, m_currentSourceLine, false ).compileExpression(line.mid(line.tqfind("=")+1)); m_pPic->saveResultToVar( firstToken ); } else if ( m_pPic->isValidTris( firstToken ) ) { if( tokens[1] == "=" ) { - Expression( m_pPic, mb, m_currentSourceLine, false ).compileExpression(line.mid(line.find("=")+1)); + Expression( m_pPic, mb, m_currentSourceLine, false ).compileExpression(line.mid(line.tqfind("=")+1)); m_pPic->Stristate(firstToken); } } @@ -529,7 +529,7 @@ bool Parser::processAssignment(const QString &line) // hasn't been defined yet. mb->addVariable( Variable( Variable::charType, firstToken ) ); - Expression( m_pPic, mb, m_currentSourceLine, false ).compileExpression(line.mid(line.find("=")+1)); + Expression( m_pPic, mb, m_currentSourceLine, false ).compileExpression(line.mid(line.tqfind("=")+1)); Variable v = mb->variable( firstToken ); switch ( v.type() ) @@ -588,7 +588,7 @@ SourceLineList Parser::getBracedCode( SourceLineList::const_iterator * it, Sourc } -void Parser::processStatement( const QString & name, const OutputFieldMap & fieldMap ) +void Parser::processStatement( const TQString & name, const OutputFieldMap & fieldMap ) { // Name is guaranteed to be something known, the calling // code has taken care of that. Also fieldMap is guaranteed to contain @@ -625,7 +625,7 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel } else if( name == "interrupt" ) { - QString interrupt = fieldMap["label"].string(); + TQString interrupt = fieldMap["label"].string(); if(!m_bPassedEnd) { @@ -653,7 +653,7 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel } else if( name == "for" ) { - QString step = fieldMap["stepExpression"].string(); + TQString step = fieldMap["stepExpression"].string(); bool stepPositive; if( fieldMap["stepExpression"].found() ) @@ -676,8 +676,8 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel stepPositive = true; } - QString variable = fieldMap["initExpression"].string().mid(0,fieldMap["initExpression"].string().find("=")).stripWhiteSpace(); - QString endExpr = variable+ " <= " + fieldMap["toExpression"].string().stripWhiteSpace(); + TQString variable = fieldMap["initExpression"].string().mid(0,fieldMap["initExpression"].string().tqfind("=")).stripWhiteSpace(); + TQString endExpr = variable+ " <= " + fieldMap["toExpression"].string().stripWhiteSpace(); if( fieldMap["stepExpression"].found() ) { @@ -698,8 +698,8 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel // The alias should be the key since two aliases could // point to the same name. - QString alias = fieldMap["alias"].string().stripWhiteSpace(); - QString dest = fieldMap["dest"].string().stripWhiteSpace(); + TQString alias = fieldMap["alias"].string().stripWhiteSpace(); + TQString dest = fieldMap["dest"].string().stripWhiteSpace(); // Check to see whether or not we've already aliased it... // if ( mb->alias(alias) != alias ) @@ -709,7 +709,7 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel } else if( name == "increment" ) { - QString variableName = fieldMap["variable"].string(); + TQString variableName = fieldMap["variable"].string(); if ( !mb->isVariableKnown( variableName ) ) mistake( Microbe::UnknownVariable ); @@ -720,7 +720,7 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel } else if( name == "decrement" ) { - QString variableName = fieldMap["variable"].string(); + TQString variableName = fieldMap["variable"].string(); if ( !mb->isVariableKnown( variableName ) ) mistake( Microbe::UnknownVariable ); @@ -731,7 +731,7 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel } else if( name == "rotateleft" ) { - QString variableName = fieldMap["variable"].string(); + TQString variableName = fieldMap["variable"].string(); if ( !mb->isVariableKnown( variableName ) ) mistake( Microbe::UnknownVariable ); @@ -742,7 +742,7 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel } else if( name == "rotateright" ) { - QString variableName = fieldMap["variable"].string(); + TQString variableName = fieldMap["variable"].string(); if ( !mb->isVariableKnown( variableName ) ) mistake( Microbe::UnknownVariable ); @@ -760,7 +760,7 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel // This is one of the rare occasions that the number will be bigger than a byte, // so suppressNumberTooBig must be used bool isConstant; - QString delay = processConstant(fieldMap["expression"].string(),&isConstant,true); + TQString delay = processConstant(fieldMap["expression"].string(),&isConstant,true); if (!isConstant) mistake( Microbe::NonConstantDelay ); // else m_pPic->Sdelay( fieldMap["expression"].string(), ""); @@ -776,8 +776,8 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel } else if ( name == "keypad" || name == "sevenseg" ) { - QStringList pins = QStringList::split( ' ', fieldMap["pinlist"].string() ); - QString variableName = fieldMap["name"].string(); + TQStringList pins = TQStringList::split( ' ', fieldMap["pinlist"].string() ); + TQString variableName = fieldMap["name"].string(); if ( mb->isVariableKnown( variableName ) ) { @@ -787,8 +787,8 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel PortPinList pinList; - QStringList::iterator end = pins.end(); - for ( QStringList::iterator it = pins.begin(); it != end; ++it ) + TQStringList::iterator end = pins.end(); + for ( TQStringList::iterator it = pins.begin(); it != end; ++it ) { PortPin portPin = m_pPic->toPortPin(*it); if ( portPin.pin() == -1 ) @@ -822,22 +822,22 @@ void Parser::processStatement( const QString & name, const OutputFieldMap & fiel } -void Parser::mistake( Microbe::MistakeType type, const QString & context ) +void Parser::mistake( Microbe::MistakeType type, const TQString & context ) { mb->compileError( type, context, m_currentSourceLine ); } // static function -QStringList Statement::tokenise(const QString &line) +TQStringList Statement::tokenise(const TQString &line) { - QStringList result; - QString current; + TQStringList result; + TQString current; int count = 0; for(int i = 0; i < int(line.length()); i++) { - QChar nextChar = line[i]; + TQChar nextChar = line[i]; if( nextChar.isSpace() ) { if( count > 0 ) @@ -903,7 +903,7 @@ int Parser::doArithmetic(int lvalue, int rvalue, Expression::Operation op) return -1; } -bool Parser::isLiteral( const QString &text ) +bool Parser::isLiteral( const TQString &text ) { bool ok; literalToInt( text, & ok ); @@ -922,7 +922,7 @@ Literal's in form: Everything else is non-literal... */ -int Parser::literalToInt( const QString &literal, bool * ok ) +int Parser::literalToInt( const TQString &literal, bool * ok ) { bool temp; if ( !ok ) @@ -948,14 +948,14 @@ int Parser::literalToInt( const QString &literal, bool * ok ) return *ok ? value : -1; } - // otherwise, let QString try and convert it + // otherwise, let TQString try and convert it // base 0 == automatic base guessing value = literal.toInt( ok, 0 ); return *ok ? value : -1; } -void Parser::compileConditionalExpression( const QString & expression, Code * ifCode, Code * elseCode ) const +void Parser::compileConditionalExpression( const TQString & expression, Code * ifCode, Code * elseCode ) const { ///HACK ///TODO this is a little improper, I don't think we should be using the pic that called us... @@ -963,7 +963,7 @@ void Parser::compileConditionalExpression( const QString & expression, Code * if } -QString Parser::processConstant(const QString &expression, bool * isConstant, bool suppressNumberTooBig) const +TQString Parser::processConstant(const TQString &expression, bool * isConstant, bool suppressNumberTooBig) const { return Expression( m_pPic, mb, m_currentSourceLine, suppressNumberTooBig ).processConstant(expression, isConstant); } @@ -979,7 +979,7 @@ Field::Field() } -Field::Field( Type type, const QString & key ) +Field::Field( Type type, const TQString & key ) { m_type = type; m_compulsory = false; @@ -987,7 +987,7 @@ Field::Field( Type type, const QString & key ) } -Field::Field( Type type, const QString & key, const QString & string, bool compulsory ) +Field::Field( Type type, const TQString & key, const TQString & string, bool compulsory ) { m_type = type; m_compulsory = compulsory; @@ -1011,7 +1011,7 @@ OutputField::OutputField( const SourceLineList & bracedCode ) m_found = true; } -OutputField::OutputField( const QString & string/*, int lineNumber*/ ) +OutputField::OutputField( const TQString & string/*, int lineNumber*/ ) { m_string = string; m_found = true; @@ -1027,17 +1027,17 @@ OutputField::OutputField( const QString & string/*, int lineNumber*/ ) { // only cope with 'sane' strings a.t.m. // e.g. include "filename.extenstion" - QString filename = (*sit).content.mid( (*sit).content.find("\"") ).stripWhiteSpace(); + TQString filename = (*sit).content.mid( (*sit).content.tqfind("\"") ).stripWhiteSpace(); // don't strip whitespace from within quotes as you // can have filenames composed entirely of spaces (kind of weird)... // remove quotes. filename = filename.mid(1); filename = filename.mid(0,filename.length()-1); - QFile includeFile(filename); + TQFile includeFile(filename); if( includeFile.open(IO_ReadOnly) ) { - QTextStream stream( &includeFile ); - QStringList includeCode; + TQTextStream stream( &includeFile ); + TQStringList includeCode; while( !stream.atEnd() ) { includeCode += stream.readLine(); |