[antlr-interest] ANTLR3 Converting Java to C++ subset (sorta)

Randall R Schulz rschulz at sonic.net
Mon Mar 26 08:25:27 PDT 2007


Hi,

On Monday 26 March 2007 08:18, Kailey Joanette wrote:
> I was wondering how any of you would approach the problem I've been
> discussing here for a week.  I thought at first that writing out a
> whole tree structure would be much more useful than converting Java
> to C++ directly using templates.  To be fair I'm not actually
> converting Java to C++ but rather J2ME to BREW.  So I will be mapping
> a lot of J2ME library calls to our own BREW calls that we have
> written.
>
> Should I continue with the tree approach I started with, or would it
> make more sense to convert it directly?

My first intuition is that if by "convert it directly" you mean do 
everything in parser action code, that you'll find yourself severely 
constrained. It is not possible to perform proper Java semantic 
analysis in a single pass, so an intermediate representation of the 
parse (AST, parse tree, something) plus symbol tables would seem to be 
mandatory.

Perhaps you've imposed additional constraints on made addition or 
assumptions about your Java inputs that are not part of the Java 
language that will get around this (I know next to nothing about J2ME 
other than what the acronym means), but if not, I think you're going to 
have to produce the intermediate representation.


> Kailey


Randall Schulz


More information about the antlr-interest mailing list