Update of /cvsroot/cpptool/rfta/src/rftaparser
In directory sc8-pr-cvs1:/tmp/cvs-serv10043/rftaparser
Modified Files:
UnparsedDeclaratorMutatorTest.cpp CPPParser.cpp
EnumBodyParserTest.cpp ExpressionOperationMutatorTest.cpp
ParseContextTest.cpp UnparsedCompoundMutatorTest.cpp
CPPParserTest.cpp DeclarationDetailsParserTest.cpp
ParserTesting.h UnparsedDeclarationListMutatorTest.cpp
ExpressionMutatorTest.cpp SourceASTNode.cpp Parser.cpp
VariableDeclMutatorTest.cpp UnparsedDeclarationMutatorTest.cpp
Log Message:
-- integrated preprocessor (replaced all NonSemanticBlanker)
Index: UnparsedDeclaratorMutatorTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclaratorMutatorTest.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** UnparsedDeclaratorMutatorTest.cpp 15 Sep 2003 09:13:31 -0000 1.2
--- UnparsedDeclaratorMutatorTest.cpp 13 Jan 2004 22:27:35 -0000 1.3
***************
*** 29,33 ****
const CppUnit::SourceLine &sourceLine )
{
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ParseContext context( sourceNode );
--- 29,34 ----
const CppUnit::SourceLine &sourceLine )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceNode );
Index: CPPParser.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/CPPParser.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CPPParser.cpp 16 Dec 2003 13:21:51 -0000 1.3
--- CPPParser.cpp 13 Jan 2004 22:27:35 -0000 1.4
***************
*** 1,6 ****
#include "stdafx.h"
#include <rfta/parser/CPPParser.h>
- #include <rfta/parser/NonSemanticBlanker.h>
#include <rfta/parser/MaxLODMutator.h>
#include <rfta/parser/DeclarationListParser.h>
--- 1,6 ----
#include "stdafx.h"
+ #include <rfta/parser/PreProcessor.h>
#include <rfta/parser/CPPParser.h>
#include <rfta/parser/MaxLODMutator.h>
#include <rfta/parser/DeclarationListParser.h>
***************
*** 9,12 ****
--- 9,14 ----
#include <rfta/parser/ASTNodeAndPropertyVisitor.h>
#include <rfta/parser/ASTNodes.h>
+ #include <rfta/parser/Source.h>
+ #include <rfta/parser/PlainTextDocument.h>
namespace Refactoring {
***************
*** 76,85 ****
CPPParser::CPPParser( const std::string &source )
{
! PPDirectiveListenerPtr pNullListener( new NullPPDirectiveListener() );
! std::string blankedSource;
! NonSemanticBlanker blanker( source, blankedSource, pNullListener );
! blanker.blank();
! sourceNode_ = SourceASTNode::create( blankedSource, source );
}
--- 78,91 ----
CPPParser::CPPParser( const std::string &source )
{
! sourceDoc_ = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! NullSourceManager manager;
! PreProcessorContext context( manager );
! PreProcessor proc( sourceDoc_, context);
!
! proc.setOption(PreProcessor::skipIncludes); // TODO: disable this if preprocessor features can handle all system headers
! std::string blankedSource = proc.process();
!
! sourceNode_ = SourceASTNode::create( blankedSource, source, sourceDoc_ );
}
***************
*** 97,101 ****
parseAll();
! FunctionImplementationVisitor visitor( position );
return visitor.findFunctionImplementation( sourceNode_ );
}
--- 103,110 ----
parseAll();
! // translate to preprocessed text position:
! SourceRange r = sourceDoc_->getRangePreProcessed(SourceRange(position,1));
!
! FunctionImplementationVisitor visitor( r.getStartIndex() );
return visitor.findFunctionImplementation( sourceNode_ );
}
***************
*** 124,127 ****
--- 133,150 ----
}
+ int
+ CPPParser::getPreProcessedPosition(int ofs)
+ {
+ // translate to preprocessed text position:
+ SourceRange r = sourceDoc_->getRangePreProcessed(SourceRange(ofs,1));
+ return r.getStartIndex();
+ }
+
+ SourceRange
+ CPPParser::getPreProcessedRange(SourceRange orignal)
+ {
+ return sourceDoc_->getRangePreProcessed(orignal);
+ }
+
} // namespace Refactoring
Index: EnumBodyParserTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/EnumBodyParserTest.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** EnumBodyParserTest.cpp 16 Dec 2003 13:22:21 -0000 1.3
--- EnumBodyParserTest.cpp 13 Jan 2004 22:27:35 -0000 1.4
***************
*** 9,12 ****
--- 9,13 ----
#include <xtl/Type.h>
#include <rfta/parser/ASTNodes.h>
+ #include <rfta/parser/PlainTextDocument.h>
#include <boost/lexical_cast.hpp>
***************
*** 24,28 ****
Xtl::Type<ParserType> )
{
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ParseContext context( sourceNode );
ParserType parser( context,
--- 25,30 ----
Xtl::Type<ParserType> )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceNode );
ParserType parser( context,
Index: ExpressionOperationMutatorTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ExpressionOperationMutatorTest.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ExpressionOperationMutatorTest.cpp 3 May 2003 17:34:55 -0000 1.4
--- ExpressionOperationMutatorTest.cpp 13 Jan 2004 22:27:35 -0000 1.5
***************
*** 45,49 ****
const CppUnit::SourceLine &sourceLine )
{
! SourceASTNodePtr sourceNode = SourceASTNode::create( expression, expression );
ParseContext context( sourceNode );
ASTNodePtr expressionNode = ASTNode::create( ASTNodeTypes::unparsedExpressionStatement,
--- 45,50 ----
const CppUnit::SourceLine &sourceLine )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( expression ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( expression, expression, sourceDoc );
ParseContext context( sourceNode );
ASTNodePtr expressionNode = ASTNode::create( ASTNodeTypes::unparsedExpressionStatement,
Index: ParseContextTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ParseContextTest.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ParseContextTest.cpp 20 Dec 2002 08:30:50 -0000 1.4
--- ParseContextTest.cpp 13 Jan 2004 22:27:35 -0000 1.5
***************
*** 7,11 ****
#include "stdafx.h"
#include "ParseContextTest.h"
!
namespace Refactoring
--- 7,12 ----
#include "stdafx.h"
#include "ParseContextTest.h"
! #include <rfta/parser/PlainTextDocument.h>
! #include <rfta/parser/Source.h>
namespace Refactoring
***************
*** 41,45 ****
{
const std::string source( ";" );
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source );
ParseContext context( sourceAST );
CPPUNIT_ASSERT( context.getSourceNode() == sourceAST );
--- 42,47 ----
{
const std::string source( ";" );
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceAST );
CPPUNIT_ASSERT( context.getSourceNode() == sourceAST );
***************
*** 53,57 ****
{
const std::string source( "{;}" );
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source );
ParseContext context( sourceAST );
context.enterParser( "Parser1", sourceAST->getBlankedSourceStart() );
--- 55,60 ----
{
const std::string source( "{;}" );
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceAST );
context.enterParser( "Parser1", sourceAST->getBlankedSourceStart() );
***************
*** 76,80 ****
{
const std::string source( "{;}" );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ParseContext context( sourceNode );
--- 79,84 ----
{
const std::string source( "{;}" );
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceNode );
Index: UnparsedCompoundMutatorTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedCompoundMutatorTest.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** UnparsedCompoundMutatorTest.cpp 20 Dec 2002 08:30:51 -0000 1.4
--- UnparsedCompoundMutatorTest.cpp 13 Jan 2004 22:27:35 -0000 1.5
***************
*** 12,15 ****
--- 12,16 ----
#include <rfta/parser/ParseContext.h>
#include <rfta/parser/SourceASTNode.h>
+ #include "TextDocumentMock.h"
***************
*** 49,53 ****
int startIndex = 2;
int length = source.length() -4;
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ASTNodePtr compoundNode = ASTNode::create(
ASTNodeTypes::unparsedCompoundStatement,
--- 50,55 ----
int startIndex = 2;
int length = source.length() -4;
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new Testing::TextDocumentMock( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ASTNodePtr compoundNode = ASTNode::create(
ASTNodeTypes::unparsedCompoundStatement,
Index: CPPParserTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/CPPParserTest.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CPPParserTest.cpp 28 May 2003 07:13:24 -0000 1.5
--- CPPParserTest.cpp 13 Jan 2004 22:27:35 -0000 1.6
***************
*** 48,53 ****
RFTA_ASSERT_NODE_TYPE( functionNode, ASTNodeTypes::functionImplementation, "function node" );
CPPUNIT_ASSERT_MESSAGE( "Failed to find function implementation node", functionNode );
! CPPUNIT_ASSERT( functionNode->getRange().contains( SourceRange( selectionIndex, 0 ) ) );
! CPPUNIT_ASSERT( functionNode->getRange() == source.getKeyedRange( functionKey_, 0 ) );
}
--- 48,53 ----
RFTA_ASSERT_NODE_TYPE( functionNode, ASTNodeTypes::functionImplementation, "function node" );
CPPUNIT_ASSERT_MESSAGE( "Failed to find function implementation node", functionNode );
! CPPUNIT_ASSERT( functionNode->getRange().contains( SourceRange( parser.getPreProcessedPosition(selectionIndex), 0 ) ) );
! CPPUNIT_ASSERT( functionNode->getRange() == parser.getPreProcessedRange(source.getKeyedRange( functionKey_, 0 ) ) );
}
Index: DeclarationDetailsParserTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParserTest.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** DeclarationDetailsParserTest.cpp 6 Sep 2003 21:41:58 -0000 1.5
--- DeclarationDetailsParserTest.cpp 13 Jan 2004 22:27:35 -0000 1.6
***************
*** 10,13 ****
--- 10,14 ----
#include "DeclarationDetailsParser.h"
#include "KeyedString.h"
+ #include <rfta/parser/PlainTextDocument.h>
***************
*** 22,26 ****
Refactoring::Testing::Identity<ParserType> )
{
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ParseContext context( sourceNode );
--- 23,28 ----
Refactoring::Testing::Identity<ParserType> )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceNode );
***************
*** 56,60 ****
Refactoring::Testing::Identity<ParserType> )
{
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ParseContext context( sourceNode );
--- 58,63 ----
Refactoring::Testing::Identity<ParserType> )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceNode );
Index: ParserTesting.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ParserTesting.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ParserTesting.h 3 May 2003 20:40:06 -0000 1.6
--- ParserTesting.h 13 Jan 2004 22:27:35 -0000 1.7
***************
*** 5,8 ****
--- 5,10 ----
#include <rfta/parser/ParserError.h>
#include <rfta/parser/SourceASTNode.h>
+ #include <rfta/parser/Source.h>
+ #include <rfta/parser/PlainTextDocument.h>
#include "UnitTesting.h"
***************
*** 134,138 ****
Identity<ParserType> )
{
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source );
ParseContext context( sourceAST );
ParserType parser( context,
--- 136,141 ----
Identity<ParserType> )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceAST );
ParserType parser( context,
***************
*** 153,157 ****
Identity<ParserType> )
{
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source );
ParseContext context( sourceAST );
ParserType parser( context,
--- 156,161 ----
Identity<ParserType> )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceAST );
ParserType parser( context,
***************
*** 179,183 ****
Identity<ParserType> )
{
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source );
ParseContext context( sourceAST );
const char *start = sourceAST->getBlankedSourceStart();
--- 183,188 ----
Identity<ParserType> )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceAST );
const char *start = sourceAST->getBlankedSourceStart();
***************
*** 208,212 ****
Identity<ParserType> )
{
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source );
ParseContext context( sourceAST );
ParserType parser( context,
--- 213,218 ----
Identity<ParserType> )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceAST );
ParserType parser( context,
***************
*** 237,241 ****
Identity<ParserType> )
{
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source );
ParseContext context( sourceAST );
const char *start = sourceAST->getBlankedSourceStart();
--- 243,248 ----
Identity<ParserType> )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceAST = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceAST );
const char *start = sourceAST->getBlankedSourceStart();
Index: UnparsedDeclarationListMutatorTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationListMutatorTest.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** UnparsedDeclarationListMutatorTest.cpp 6 Sep 2003 21:37:06 -0000 1.6
--- UnparsedDeclarationListMutatorTest.cpp 13 Jan 2004 22:27:35 -0000 1.7
***************
*** 54,58 ****
const std::string source( "namespace y { int x; float (*f)(int x); } " );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ParseContext context(sourceNode);
--- 54,59 ----
const std::string source( "namespace y { int x; float (*f)(int x); } " );
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ParseContext context(sourceNode);
***************
*** 103,107 ****
source << ";";
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
// parse declaration:
--- 104,109 ----
source << ";";
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
// parse declaration:
Index: ExpressionMutatorTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ExpressionMutatorTest.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ExpressionMutatorTest.cpp 20 Dec 2002 08:30:50 -0000 1.7
--- ExpressionMutatorTest.cpp 13 Jan 2004 22:27:35 -0000 1.8
***************
*** 11,14 ****
--- 11,15 ----
#include <rfta/parser/ParseContext.h>
#include <rfta/parser/SourceASTNode.h>
+ #include <rfta/parser/PlainTextDocument.h>
***************
*** 24,29 ****
const CppUnit::SourceLine &sourceLine )
{
! std::string expression = beforeIdentifier + identifier + afterIdentifier;
! SourceASTNodePtr sourceNode = SourceASTNode::create( expression, expression );
ParseContext context( sourceNode );
ASTNodePtr expressionNode = ASTNode::create( ASTNodeTypes::unparsedExpressionStatement,
--- 25,31 ----
const CppUnit::SourceLine &sourceLine )
{
! std::string expression = beforeIdentifier + identifier + afterIdentifier;
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( expression ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( expression, expression, sourceDoc );
ParseContext context( sourceNode );
ASTNodePtr expressionNode = ASTNode::create( ASTNodeTypes::unparsedExpressionStatement,
***************
*** 47,51 ****
const CppUnit::SourceLine &sourceLine )
{
! SourceASTNodePtr sourceNode = SourceASTNode::create( expression, expression );
ParseContext context( sourceNode );
ASTNodePtr expressionNode = ASTNode::create( ASTNodeTypes::unparsedExpressionStatement,
--- 49,54 ----
const CppUnit::SourceLine &sourceLine )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( expression ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( expression, expression, sourceDoc );
ParseContext context( sourceNode );
ASTNodePtr expressionNode = ASTNode::create( ASTNodeTypes::unparsedExpressionStatement,
***************
*** 130,134 ****
source += "value;";
int length = source.length() - start;
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ParseContext context( sourceNode );
ASTNodePtr expressionNode =
--- 133,138 ----
source += "value;";
int length = source.length() - start;
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceNode );
ASTNodePtr expressionNode =
Index: SourceASTNode.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/SourceASTNode.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** SourceASTNode.cpp 16 Dec 2003 13:29:01 -0000 1.9
--- SourceASTNode.cpp 13 Jan 2004 22:27:35 -0000 1.10
***************
*** 17,24 ****
SourceASTNodePtr
SourceASTNode::create( const std::string &blankedSource,
! const std::string &realSource )
{
SourceASTNodePtr sourceNode( new SourceASTNode( blankedSource,
! realSource ) );
sourceNode->setSourceNode( sourceNode );
--- 17,26 ----
SourceASTNodePtr
SourceASTNode::create( const std::string &blankedSource,
! const std::string &realSource,
! const SourcePtr source )
{
SourceASTNodePtr sourceNode( new SourceASTNode( blankedSource,
! realSource,
! source ) );
sourceNode->setSourceNode( sourceNode );
***************
*** 28,32 ****
SourceASTNode::SourceASTNode( const std::string &blankedSource,
! const std::string &realSource )
: ASTNode( ASTNodeTypes::source,
ASTNodeWeakPtr(),
--- 30,35 ----
SourceASTNode::SourceASTNode( const std::string &blankedSource,
! const std::string &realSource,
! const SourcePtr source )
: ASTNode( ASTNodeTypes::source,
ASTNodeWeakPtr(),
***************
*** 35,38 ****
--- 38,42 ----
, realSource_( realSource )
, blankedSourceStart_( blankedSource_.c_str() )
+ , sourceDoc_ ( source )
{
/*
***************
*** 91,94 ****
--- 95,104 ----
}
+ SourcePtr
+ SourceASTNode::getSource() const
+ {
+ return sourceDoc_;
+ }
+
} // namespace Refactoring
Index: Parser.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/Parser.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Parser.cpp 4 May 2003 18:19:45 -0000 1.13
--- Parser.cpp 13 Jan 2004 22:27:35 -0000 1.14
***************
*** 10,13 ****
--- 10,14 ----
#include <rfta/parser/ParserError.h>
#include <rfta/parser/ParserTools.h>
+ #include <rfta/parser/Source.h>
#include <xtl/CStringView.h>
#include <boost/lexical_cast.hpp>
***************
*** 76,88 ****
void
Parser::throwFailure( const ParserTools::ParseError &error )
! {
! Xtl::CStringView source( context_.getSourceNode()->getOriginalSource() );
int startLine = getLineNumberOf( start_ );
int endLine = getLineNumberOf( end_ );
int currentLine = getLineNumberOf( error.context_ );
boost::format formatter(
"%s\n"
! "- Parser lines: current = %d, start = %d, end = %d\n"
"- Current text: %s\n"
"- While analyzing:\n%s" );
--- 77,90 ----
void
Parser::throwFailure( const ParserTools::ParseError &error )
! {
int startLine = getLineNumberOf( start_ );
int endLine = getLineNumberOf( end_ );
int currentLine = getLineNumberOf( error.context_ );
+ std::string startFile = context_.getSourceNode()->getSource()->getSourceOrigin(SourceRange( getIndexOf( start_ ), 1 ) ).getIdentifier();
+ std::string endFile = context_.getSourceNode()->getSource()->getSourceOrigin(SourceRange( getIndexOf( end_ ), 1 ) ).getIdentifier();
boost::format formatter(
"%s\n"
! "- Parser lines: current = %d, start = %d (file: %s), end = %d (file: %s)\n"
"- Current text: %s\n"
"- While analyzing:\n%s" );
***************
*** 90,94 ****
std::string message =
(formatter % error.what()
! % currentLine % startLine % endLine
% Xtl::CStringView( error.context_ ).getSubString(0, 60).str()
% error.context_.getString().str() ).str();
--- 92,98 ----
std::string message =
(formatter % error.what()
! % currentLine
! % startLine % startFile.c_str()
! % endLine % endFile.c_str()
% Xtl::CStringView( error.context_ ).getSubString(0, 60).str()
% error.context_.getString().str() ).str();
***************
*** 103,109 ****
return -1;
! Xtl::CStringView source( context_.getSourceNode()->getOriginalSource() );
! const char *originalPosition = source.getStart() + getIndexOf( position );
! return std::count( source.getStart(), originalPosition, '\n' ) +1;
}
--- 107,111 ----
return -1;
! return context_.getSourceNode()->getSource()->getLineNumberOf(getIndexOf( position ));
}
Index: VariableDeclMutatorTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/VariableDeclMutatorTest.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** VariableDeclMutatorTest.cpp 21 Apr 2003 03:06:27 -0000 1.15
--- VariableDeclMutatorTest.cpp 13 Jan 2004 22:27:35 -0000 1.16
***************
*** 28,32 ****
const CppUnit::SourceLine &sourceLine )
{
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ParseContext context( sourceNode );
--- 28,33 ----
const CppUnit::SourceLine &sourceLine )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceNode );
***************
*** 56,60 ****
const CppUnit::SourceLine &sourceLine )
{
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ParseContext context( sourceNode );
--- 57,62 ----
const CppUnit::SourceLine &sourceLine )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceNode );
***************
*** 381,385 ****
int length = source.length() - 2 - startIndex;
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ParseContext context( sourceNode );
--- 383,388 ----
int length = source.length() - 2 - startIndex;
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceNode );
Index: UnparsedDeclarationMutatorTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** UnparsedDeclarationMutatorTest.cpp 24 Sep 2003 20:29:59 -0000 1.16
--- UnparsedDeclarationMutatorTest.cpp 13 Jan 2004 22:27:35 -0000 1.17
***************
*** 29,33 ****
const CppUnit::SourceLine &sourceLine )
{
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source );
ParseContext context( sourceNode );
--- 29,34 ----
const CppUnit::SourceLine &sourceLine )
{
! SourcePtr sourceDoc = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source ) ) ) );
! SourceASTNodePtr sourceNode = SourceASTNode::create( source, source, sourceDoc );
ParseContext context( sourceNode );
|