Update of /cvsroot/cpptool/rfta/include/rfta/parser
In directory sc8-pr-cvs1:/tmp/cvs-serv28898/include/rfta/parser
Added Files:
MacroReplaceListener.h MacroReplaceRegistration.h
PPDirectiveListener.h PreProcessor.h PreProcessorError.h
Log Message:
-- files of a preprocessor implementation
--- NEW FILE: MacroReplaceListener.h ---
// //////////////////////////////////////////////////////////////////////////
// Header file PPDirectiveListener.h for class PPDirectiveListener
// (c)Copyright 2003, Andre Baresel
// Created: 2003/12/13
// //////////////////////////////////////////////////////////////////////////
#include <string>
#include <boost/shared_ptr.hpp>
#include <rfta/parser/Config.h>
#include <rfta/parser/SourceRange.h>
#ifndef REFACTORING_MACROREPLACELISTENER_H_INCLUDED
#define REFACTORING_MACROREPLACELISTENER_H_INCLUDED
namespace Refactoring
{
class RFTAPARSER_API MacroReplaceListener;
typedef boost::shared_ptr<MacroReplaceListener> MacroReplaceListenerPtr;
class RFTAPARSER_API MacroReplaceListener
{
public:
/**
* is called whenever a replacement actions takes place
*/
virtual void macroReplacement( const SourceRange position,
const std::string ¯o,
const std::string &replacement ) =0;
};
class NullMacroReplaceListener: public MacroReplaceListener
{
public:
/**
* is called whenever a replacement actions takes place
*/
virtual void macroReplacement( const SourceRange position,
const std::string ¯o,
const std::string &replacement )
{
}
};
}
#endif // REFACTORING_MACROREPLACELISTENER_H_INCLUDED
--- NEW FILE: MacroReplaceRegistration.h ---
// //////////////////////////////////////////////////////////////////////////
// Header file MacroReplaceRegistration.h for class MacroReplaceRegistration
// (c)Copyright 2003, Andre Baresel
// Created: 2003/12/13
// //////////////////////////////////////////////////////////////////////////
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <rfta/parser/Config.h>
#include <rfta/parser/SourceRange.h>
#include "MacroReplaceListener.h"
#ifndef REFACTORING_MACROREPLACEREGISTRATION_H_INCLUDED
#define REFACTORING_MACROREPLACEREGISTRATION_H_INCLUDED
namespace Refactoring
{
class RFTAPARSER_API MacroReplaceRegistration: public MacroReplaceListener
{
public:
struct MacroReplacement;
/**
* is called whenever a replacement actions takes place
*/
virtual void macroReplacement( const SourceRange position,
const std::string ¯o,
const std::string &replacement );
/**
* @return number of entries in registration
*/
int getSize() const;
/**
* @return an entry of the registered replacements
* @throw std::invalid_argument if index >= size.
*/
MacroReplacement getEntry(unsigned int index) const;
/**
* does prepare the data after all replacements have been done.
*/
void finishUpData();
/**
* @return the text delta of all macro replacements before 'position')
*/
int getReplacementDeltaBefore(SourceRange position);
struct SortPredicate;
struct MacroReplacement {
SourceRange position_;
std::string macroText_;
std::string replacement_;
};
typedef boost::shared_ptr<MacroReplacement> MacroReplacementPtr;
private:
typedef std::vector<MacroReplacement> MacroReplacementList;
MacroReplacementList macroReplacements_;
};
}
#endif // REFACTORING_MACROREPLACEREGISTRATION_H_INCLUDED
--- NEW FILE: PPDirectiveListener.h ---
// //////////////////////////////////////////////////////////////////////////
// Header file PPDirectiveListener.h for class PPDirectiveListener
// (c)Copyright 2003, Andre Baresel
// Created: 2003/12/13
// //////////////////////////////////////////////////////////////////////////
#include <string>
#include <boost/shared_ptr.hpp>
#include <rfta/parser/Config.h>
#ifndef REFACTORING_PPDIRECTIVELISTENER_H_INCLUDED
#define REFACTORING_PPDIRECTIVELISTENER_H_INCLUDED
namespace Refactoring
{
class RFTAPARSER_API PPDirectiveListener;
typedef boost::shared_ptr<PPDirectiveListener> PPDirectiveListenerPtr;
class RFTAPARSER_API PPDirectiveListener
{
public:
virtual void parseDirective( const char *first,
const char *last ) =0;
};
class RFTAPARSER_API NullPPDirectiveListener : public PPDirectiveListener
{
public:
void parseDirective( const char *first,
const char *last )
{
}
};
}
#endif // REFACTORING_PPDIRECTIVELISTENER_H_INCLUDED
--- NEW FILE: PreProcessor.h ---
// //////////////////////////////////////////////////////////////////////////
// Header file PreProcessor.h for class PreProcessor
// (c)Copyright 2003, Andre Baresel
// Created: 2003/12/13
// //////////////////////////////////////////////////////////////////////////
#include <string>
#ifndef REFACTORING_PREPROCESSOR_H_INCLUDED
#define REFACTORING_PREPROCESSOR_H_INCLUDED
#include <rfta/parser/Config.h>
#include "MacroReplaceListener.h"
namespace Refactoring
{
class RFTAPARSER_API PreProcessor
{
public:
PreProcessor( const std::string &textToPreProcess);
/**
* @return preprocessed source, data of 'ppDirectiveParser' is used for preprocessing
* whenever a replacement takes place the listener will be called.
*/
std::string process(MacroReplaceListener& listener);
private:
std::string toPreProcess_;
};
}
#endif // REFACTORING_PREPROCESSOR_H_INCLUDED
--- NEW FILE: PreProcessorError.h ---
// //////////////////////////////////////////////////////////////////////////
// Header file PreProcessorError.h for class PreProcessorError
// (c)Copyright 2003, Andre Baresel.
// Created: 2003/12/14
// //////////////////////////////////////////////////////////////////////////
#ifndef RFTA_PREPROCESSORERROR_H
#define RFTA_PREPROCESSORERROR_H
#include <stdexcept>
#include <rfta/parser/Config.h>
namespace Refactoring
{
/// Exception thrown when an error occurs during preprocessing.
class RFTAPARSER_API PreProcessorError : public std::runtime_error
{
public:
PreProcessorError( const std::string &message );
/// Destructor.
virtual ~PreProcessorError() throw();
const char *what() const throw();
private:
std::string message_;
mutable std::string what_;
};
// Inlines methods for PreProcessorError:
// --------------------------------
} // namespace Refactoring
#define DO_STRINGIZE(s) #s
#define ThrowPreProcessError(text) \
throw PreProcessorError( std::string(__FILE__ ":" ) + std::string(text) );
#endif // RFTA_PREPROCESSORERROR_H
|