|
Boost : |
Subject: [boost] [wave] limited extensibility
From: Christopher Lux (christopherlux_at_[hidden])
Date: 2010-02-05 19:56:45
Hi,
i am trying to use boost.wave as a preprocessor for OpenGL Shading
Language shader files (GLSL). GLSL uses a limited C/C++ preprocessor
(no included etc.). I want to use boost.wave to handle the includes
correctly besides generally gaining a more powerful preprocessor.
Now the problem is that there a special preprocessor directives in
GLSL that the compiler itself has to handle. I am speaking of the
#version and #extension directives. I hoped boost.wave would provide
the possibility to add special directives that the client code then
can handle properly.
Currently I use the context hook as follows:
class glsl_preprocessing_hook
: public boost::wave::context_policies::default_preprocessing_hooks
{
public:
template <typename ContextT>
void
throw_exception(ContextT const &ctx, std::exception const& e) {
throw e;
}
template <typename ContextT>
void
throw_exception(ContextT const &ctx,
boost::wave::preprocess_exception const& e) {
// just ignore ill formed directives (version, exception...)
and let the glsl compiler handle these
if(e.get_errorcode() !=
boost::wave::preprocess_exception::ill_formed_directive) {
throw e;
}
}
};
This just ignores the ill formed directives, but may still let
unwanted errors through.
Would it be possible to extend boost.wave in a way to be able feed the
lexer or context regular expressions of the new custom directives?
These could be pushed into a special hook method with the appropriate
context information. I think this functionality would greatly increase
the usability for C++ like languages with custom extensions to the
preprocessor.
Regards
-chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk