[antlr-interest] Translating PASCAL (or C) into JAVA

mzukowski at bco.com mzukowski at bco.com
Thu Feb 14 06:54:27 PST 2002


The approach I took with my AREV to VB translator was to parse AREV into an
AST and symbol table.  But my master tree grammar also included all of the
VB node types as well.  For output I had a VB-only tree emitter.  In between
there were 8 passes which did the actual transformations via tree
transformations in a tree parser.  Each of those passes was an antlr
"subclass" of the master grammar.  An example translation--the AREV case
statement needed to be translated into a VB if-else series, so I had a rule
that would override the AREV case rule from the master grammar which would
build a new tree in the proper VB if-else form.

Monty

> -----Original Message-----
> From: pietschoutteten [mailto:pietschoutteten at yahoo.com]
> Sent: Thursday, February 14, 2002 5:19 AM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Translating PASCAL (or C) into JAVA
> 
> 
> Hello all,
> 
> I'm new to the mailing list and I'm 'playing' with ANTLR since a few 
> days. The ideas behind ANTLR are magnificant and I find it a very 
> intelligent system, a real contribution to Computer Science.
> 
> Now I have a simple question.
> 
> I must find a system to translate Pascal files into JAVA. (can be C 
> into JAVA aswell)
> Can that be done with ANTLR?
> Is there a quick solution to do that (perhaps starting from the 
> Pascal example?)
> 
> I have testet the Pascal grammer (antlr-2.7.1\java\examples\pascal) 
> and the GNU C parser from the website.
> 
> ANTLR produces me the JAVA-files PascalLexer.java PascalParser.java 
> and PascalTokenTypes.java
> and I can build these together and test it with the example P_0_1.pas
> I also tested it with the grammer from Sinan (message 2398 Re: Ter, 
> Would you mind looking at ....) which builds me an AST.
> 
> My problem is that I want to translate this P_0_1.pas into JAVA code!
> 
> Is that possible?
> 
> I also searched in the FAQ and the Messages list and read a lot of 
> discussions, but none of them goes into translating source-code into 
> JAVA. And I searched in the ANTLR Reference Manual, which is detailed 
> AND interesting, but I first have to know if my PASCAL to JAVA 
> translation is possible and how.
> If so, I'm sure I will become a dedicated ANTLR-user.
> 
> Thank you in advance to help this newcomer.
> Piet Schoutteten
> 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> 
> 
> 

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list