lib/cppparser/lexer.{h,cpp} cosmetics and error detection improvement:
- Move function bodies from header file to implementation file. - Token::Token(const QString & text) - Token::Token(int type, int position, int length, const QString& txt) - Token::Token(const Token& source) - Token& Token::operator = (const Token& source) - Token::operator int () const - bool Token::operator == (const Token& token) const - bool Token::isNull() const - int Token::type() const - void Token::setType(int type) - int Token::position() const - QString Token::text() const - void Token::setStartPosition(int line, int column) - void Token::setEndPosition(int line, int column) - void Token::getStartPosition(int* line, int* column) const - void Token::getEndPosition(int* line, int* column) const - void Token::setPosition(int position) - unsigned int Token::length() const - void Token::setLength(unsigned int length) - const CHARTYPE* Lexer::offset(int offset) const - int Lexer::getOffset(const QChar* p) const - Lexer::readWhiteSpaces(bool skipNewLine, bool skipOnlyOnce) - bool Lexer::recordComments() const - void Lexer::setRecordComments(bool record) - bool Lexer::recordWhiteSpaces() const - void Lexer::setRecordWhiteSpaces(bool record) - QString Lexer::source() const - int Lexer::index() const - void Lexer::setIndex(int index) - const Token& Lexer::nextToken() - const Token& Lexer::tokenAt(int n) const - const Token& Lexer::lookAhead(int n) const - int Lexer::tokenPosition(const Token& token) const - void Lexer::nextChar() - void Lexer::nextChar(int n) - void Lexer::readIdentifier() - bool isTodo(const QString& txt, int position); static in cpp file - bool isFixme(const QString& txt, int position); static in cpp file - void Lexer::readLineComment() - void Lexer::readMultiLineComment() - void Lexer::readCharLiteral() - void Lexer::readStringLiteral() - void Lexer::readNumberLiteral() - int Lexer::findOperator3() const - int Lexer::findOperator2() const - bool Lexer::skipWordsEnabled() const - void Lexer::setSkipWordsEnabled(bool enabled) - bool Lexer::preprocessorEnabled() const - void Lexer::setPreprocessorEnabled(bool enabled) - int Lexer::currentPosition() const - const QChar Lexer::currentChar() const - QChar Lexer::peekChar(int n) const - bool Lexer::eof() const - bool Lexer::reportWarnings() const - void Lexer::setReportWarnings(bool enable) - bool Lexer::reportMessages() const - void Lexer::setReportMessages(bool enable) - void Lexer::insertCurrent(const QString& str) - At Lexer function readWhiteSpaces(bool skipNewLine=true, bool skipOnlyOnce=false) change return type from void to bool, return false on EOF. lib/cppparser/lexer.cpp - In Lexer::nextChar functions return immediately if m_ptr is beyond m_endPtr. - In Lexer::readLineComment() break out of while-loop if currentPosition() returns error. - In Lexer::readMultiLineComment() break out of while-loop if currentPosition() returns error. - In Lexer::readCharLiteral() while-loop add safety check that currentPosition() returns valid position. - In Lexer::readStringLiteral() while-loop add safety check that currentPosition() returns valid position. - In Lexer functions findOperator3, findOperator2, insertCurrent add initial check that currentPosition() returns valid position. - In Lexer function getOffset return -1 for error (argument `p' out of range of `src'). - In Lexer function nextToken, - return immediately if readWhiteSpaces() returns error; - return immediately if currentPosition() returns error. - In Lexer::tokenize() replace "for (;;)" loop by "while (currentPosition() >= 0)". - In Lexer::readArgument() return empty string if readWhiteSpaces() returns error. - In Lexer functions macroDefined, processDefine, processInclude, macroPrimary, - return 0 if readWhiteSpaces() returns error; - return 0 if currentPosition() returns error. - In Lexer::macroMultiplyDivide() replace "for (;;)" loop by "while (readWhiteSpaces(false))". - In Lexer functions macroAddSubtract, macroRelational, macroEquality, macroBoolAnd, macroBoolXor, macroBoolOr, macroLogicalAnd, macroLogicalOr return result immediately if readWhiteSpaces() returns error. - In Lexer::macroExpression() return 0 if readWhiteSpaces() returns error.
parent
af296cce
Please register or sign in to comment