[antlr-interest] Rewriting the input.

Fredrik Ohrstrom oehrstroem at gmail.com
Wed Nov 7 03:20:08 PST 2007


You should probably use the TokenRewriteStream
to output an identical copy of the input stream.

Your parser then applies stream rewriting commands
on the stream/endstream data only.

It doesn't hurt if you can express both the inside
and outside of your stream/endstream data with a
single grammar. But if that is difficult or unnecessary
complicated, you can simply hide the outside with the
lexer. I.e. the lexer hides all input until it receives a
stream token and goes back to hiding when it receives
an endstream token.

//Fredrik

2007/11/7, craig at palantir.co.za <craig at palantir.co.za>:
> Hi,
>
> Is it easy to output the input stream, but replace delimited sections of the
> input as they are sent out.
> I wish to pipe input to output except for pieces of the input delimited with
> 'stream' and 'endstream', which require special processing before being sent
> out. In essence I would require a sub-parser to handle the sections of input
> inside the delimiters.
>
> Is this easy to do?
> I only see samples (in the book) where the input stream is known. I wish to
> ignore (well, output) everything not in delimiters without altering it.
>
> Regards
> Craig.
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
>


More information about the antlr-interest mailing list