Update of /cvsroot/cpptool/rfta/src/rftaparser
In directory sc8-pr-cvs1:/tmp/cvs-serv32542/src/rftaparser
Modified Files:
IfStatementParser.cpp Parser.cpp
Log Message:
* if condition node is trimed
Index: IfStatementParser.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/IfStatementParser.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** IfStatementParser.cpp 20 Dec 2002 08:30:50 -0000 1.8
--- IfStatementParser.cpp 25 Dec 2002 22:40:21 -0000 1.9
***************
*** 41,45 ****
expect( '(' );
findNextBalanced( '(', ')' );
! int conditionLength = getCurrentIndex() - conditionIndex;
ASTNodePtr statement =
--- 41,45 ----
expect( '(' );
findNextBalanced( '(', ')' );
! int conditionEndIndex = getCurrentIndex();
ASTNodePtr statement =
***************
*** 51,57 ****
ASTNodePtr conditionNode =
createASTNode( ASTNodeTypes::unparsedConditionExpression,
! statement,
! conditionIndex+1,
! conditionLength-2 );
statement->setPropertyNode( ASTNodeProperties::selectionProperty,
--- 51,57 ----
ASTNodePtr conditionNode =
createASTNode( ASTNodeTypes::unparsedConditionExpression,
! statement,
! getTrimedRangeFromIndexes( conditionIndex+1,
! conditionEndIndex-1 ) );
statement->setPropertyNode( ASTNodeProperties::selectionProperty,
Index: Parser.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/Parser.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Parser.cpp 20 Dec 2002 08:30:51 -0000 1.4
--- Parser.cpp 25 Dec 2002 22:40:21 -0000 1.5
***************
*** 258,266 ****
int length ) const
{
return ASTNode::create( type,
parentNode,
! startIndex,
! length,
context_.getSourceNode() );
}
--- 258,310 ----
int length ) const
{
+ return createASTNode( type,
+ parentNode,
+ SourceRange( startIndex, length ) );
+ }
+
+
+ ASTNodePtr
+ Parser::createASTNode( const ASTNodeType &type,
+ const ASTNodeWeakPtr &parentNode,
+ const SourceRange &sourceRange ) const
+ {
return ASTNode::create( type,
parentNode,
! sourceRange,
context_.getSourceNode() );
+ }
+
+
+ int
+ Parser::getIndexOf( const char *pos )
+ {
+ return pos - context_.getSourceNode()->getBlankedSourceStart();
+ }
+
+
+ SourceRange
+ Parser::getTrimedRange( const SourceRange &sourceRange )
+ {
+ const char *start = context_.getSourceNode()->getBlankedSourceStart()
+ + sourceRange.getStartIndex();
+ const char *last = start + sourceRange.getLength();
+
+ while ( start < last && *start == ' ' )
+ ++start;
+
+ while ( last > start && last[-1] == ' ' )
+ --last;
+
+ int newStartIndex = getIndexOf( start );
+ int newLength = getIndexOf( last ) - newStartIndex;
+ return SourceRange( newStartIndex, newLength );
+ }
+
+
+ SourceRange
+ Parser::getTrimedRangeFromIndexes( int startIndex, int endIndex )
+ {
+ return getTrimedRange( SourceRange( startIndex,
+ endIndex - startIndex ) );
}
|