[antlr-interest] Building an interpreter
rdclark at gmail.com
Sat Apr 26 19:04:40 PDT 2008
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.
More information about the antlr-interest