[antlr-interest] Building an interpreter
dcmailbag-antlr at yahoo.com
dcmailbag-antlr at yahoo.com
Tue Apr 29 03:50:58 PDT 2008
Thank you, Richard.
I understnad the concept of altering the input stream - I have done it many
times with lex.
My hope had been that antlr had this capability already built-in as I have
found the need to be (relatively) common when building interpreters.
--- Richard Clark <rdclark at gmail.com> wrote:
> On Thu, Apr 24, 2008 at 3:01 PM, <dcmailbag-antlr at yahoo.com> wrote:
>
> > The problem with the interpreter examples seen is that they require the
> > input stream to the interpreter being constructed be the same stream as
> the
> > input to the parser building the interpreter (the token and node streams
> are
> > derived from the input stream).
>
> I'd tackle this by writing an input adaptor that lets you switch its
> input stream or works from multiple input streams in a row. You could
> easily pick up the source for ANTLRInputStream and alter it.
>
> The only tricky part is knowing when to signal EOF to the parser. If
> you had a "definition" stream and a "execution" stream, EOF on the
> first could tell the input adaptor to switch to the second and EOF on
> the second would be passed through to the parser.
>
> I hope this gives you enough to go on.
>
> ...Richard
>
More information about the antlr-interest
mailing list