[Uml-devel] KDE/kdesdk/umbrello/umbrello/codeimport/kdevcppparser
Jean Vittor
jean.vittor at free.fr
Sat Mar 29 16:16:29 UTC 2008
SVN commit 791459 by jvittor:
Remove usages of Lexer::nextChar
M +45 -56 lexer.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/kdevcppparser/lexer.cpp #791458:791459
@@ -332,10 +332,8 @@
QChar ch = m_source.currentChar();
if( ch.isNull() || ch.isSpace() ){
/* skip */
- } else if( m_source.get_startLine() && ch == '#') {
-
- m_source.nextChar(); // skip #
- m_source.parse( gr_whiteSpaces); // skip white spaces
+ } else if( m_source.get_startLine()
+ && m_source.parse( ch_p('#') >> gr_whiteSpaces).hit) {
m_source.set_startLine( false);
QString directive;
@@ -414,8 +412,7 @@
else
ellipsisArg += arg;
- if( m_source.currentChar() == ',' ){
- m_source.nextChar();
+ if( m_source.parse( ch_p(',')).hit) {
if( !ellipsis ){
++argIdx;
} else {
@@ -425,9 +422,8 @@
break;
}
}
- if( m_source.currentChar() == ')' ){
+ if( m_source.parse(ch_p(')')).hit) {
// valid macro
- m_source.nextChar();
}
} else {
Position l_newPosition( svPosition);
@@ -705,12 +701,8 @@
m_driver->removeMacro( macroName );
m.setName( macroName );
- if( m_source.currentChar() == '(' ){
+ if( m_source.parse( ch_p('(') >> gr_whiteSpaces).hit) {
m.setHasArguments( true );
- m_source.nextChar();
-
- m_source.parse( gr_whiteSpaces);
-
while( !m_source.currentChar().isNull() && m_source.currentChar() != ')' ){
m_source.parse( gr_whiteSpaces);
@@ -721,14 +713,11 @@
m.addArgument( Macro::Argument(arg) );
m_source.parse( gr_whiteSpaces);
- if( m_source.currentChar() != ',' )
+ if( !m_source.parse( ch_p(',')).hit)
break;
-
- m_source.nextChar(); // skip ','
}
-
- if( m_source.currentChar() == ')' )
- m_source.nextChar(); // skip ')'
+ bool l_status = m_source.parse(ch_p(')')).hit;
+ assert( l_status);
}
m_preprocessorEnabled = true;
@@ -886,55 +875,55 @@
int Lexer::macroPrimary()
{
m_source.parse( gr_whiteSpaces);
- int result = 0;
+ int result = 0;
switch( m_source.currentChar().unicode() ) {
- case '(':
+ case '(':
m_source.nextChar();
- result = macroExpression();
+ result = macroExpression();
if( m_source.currentChar() != ')' ){
- /// @todo report error
- return 0;
- }
+ /// @todo report error
+ return 0;
+ }
m_source.nextChar();
- return result;
+ return result;
- case '+':
- case '-':
- case '!':
- case '~':
- {
+ case '+':
+ case '-':
+ case '!':
+ case '~':
+ {
QChar tk = m_source.currentChar();
m_source.nextChar();
- int result = macroPrimary();
- if( tk == '-' ) return -result;
- else if( tk == '!' ) return !result;
- else if( tk == '~' ) return ~result;
+ int result = macroPrimary();
+ if( tk == '-' ) return -result;
+ else if( tk == '!' ) return !result;
+ else if( tk == '~' ) return ~result;
+ }
+ break;
+
+ default:
+ {
+ Token tk;
+ nextToken( tk);
+ switch( tk.type() ){
+ case Token_identifier:
+ if( tk.text() == "defined" ){
+ return macroPrimary();
}
+ /// @todo implement
+ return m_driver->hasMacro( tk.text() );
+ case Token_number_literal:
+ case Token_char_literal:
+ return toInt( tk );
+ default:
break;
+ } // end switch
- default:
- {
- Token tk;
- nextToken( tk);
- switch( tk.type() ){
- case Token_identifier:
- if( tk.text() == "defined" ){
- return macroPrimary();
- }
- /// @todo implement
- return m_driver->hasMacro( tk.text() );
- case Token_number_literal:
- case Token_char_literal:
- return toInt( tk );
- default:
- break;
- } // end switch
+ } // end default
- } // end default
+ } // end switch
- } // end switch
-
- return 0;
+ return 0;
}
int Lexer::macroMultiplyDivide()
More information about the umbrello-devel
mailing list