[antlr-interest] Multiple-target parsers, and extending without overriding
Gavin Lambert
antlr at mirality.co.nz
Sat Jan 8 13:41:42 PST 2011
At 13:06 8/01/2011, Geoffrey Romer wrote:
>But that seems like it's not always possible. So far as I can
tell,
>there's no way to keep syntactic or semantic predicates outside
the
>grammar (now would it be very desirable if you could). Keeping
rule
>arguments and return values outside the grammar is a
contradiction
>in terms. I can't even find a way to skip whitespace without
>writing code in the target language. Am I missing something?
One way to do it depends on how compatible the two languages are,
particularly with method call syntax (for example, C++ and Java
have compatible method call syntax). If this is the case then you
can just write every predicate as a call to a method (left
undefined in the grammar), and then either subclass or superclass
the resulting parser class to provide the actual
implementation. (You can do something similar with C, but you'd
have to call global functions, and possibly alter the parameters a
little.)
More information about the antlr-interest
mailing list