Boost logo

Boost :

Subject: Re: [boost] [wave] limited extensibility
From: Christopher Lux (christopherlux_at_[hidden])
Date: 2010-02-07 11:38:15


Hi Hartmut,
thank you! That was amazing fast.

I tried the new hook and I am now able to get all the information I need.

Thank you very much for the fast help.
-chris

On Sun, Feb 7, 2010 at 5:07 PM, Hartmut Kaiser <hartmut.kaiser_at_[hidden]> wrote:
> Christopher,
>
>> that sounds perfect.
>>
>> When passing the line, i think, possible comments should be stripped
>> to prevent problems when this line is stripped from the output. The
>> on_illformed hook should also have a boolean return value signaling to
>> pass the line to the output or to strip it (similar to other hooks).
>
> Ok, I added the following preprocessing hook to Wave:
>
> ///////////////////////////////////////////////////////////////////////////
> //
> //  The function 'found_unknown_directive' is called whenever an unknown
> //  preprocessor directive was encountered.
> //
> //  The parameter 'ctx' is a reference to the context object used for
> //  instantiating the preprocessing iterators by the user.
> //
> //  The parameter 'line' holds the tokens of the entire source line
> //  containing the unknown directive.
> //
> //  The parameter 'pending' may be used to push tokens back into the input
> //  stream, which are to be used as the replacement text for the whole
> //  line containing the unknown directive.
> //
> //  The return value defines whether the given expression has been
> //  properly interpreted by the hook function or not. If this function
> //  returns 'false', the library will raise an 'ill_formed_directive'
> //  preprocess_exception. Otherwise the tokens pushed back into 'pending'
> //  are passed on to the user program.
> //
> ///////////////////////////////////////////////////////////////////////////
> template <typename Context, typename Container>
> bool found_unknown_directive(Context const& ctx, Container const& line,
>    Container& pending)
> {
>    return false;    // by default we never interpret unknown directives
> }
>
> Depending on the settings comments are either retained or stripped _before_
> invoking this hook function. For instance for a line:
>
>    #version 150 core   // some comment
>
> the parameter 'line' will contain the following tokens:
>
>    T_POUND "#"
>    T_IDENTIFIER "version"
>    T_SPACE " "
>    T_PP_NUMBER "150"
>    T_SPACE " "
>    T_IDENTIFIER "core"
>    T_NEWLINE "\n"
>
> (if comments are to be stripped), or:
>
>    T_POUND "#"
>    T_IDENTIFIER "version"
>    T_SPACE " "
>    T_PP_NUMBER "150"
>    T_SPACE " "
>    T_IDENTIFIER "core"
>    T_CPPCOMMENT "// some comment\n"
>
> if those are to be retained.
>
> A new example (custom_directives.cpp) demonstrates its usage.
>
> HTH
> Regards Hartmut
>
> ---------------
> Meet me at BoostCon
> www.boostcon.com
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk