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

Robert renyedi at yahoo.com
Thu Feb 14 06:49:27 PST 2002


You're welcome.

In general, you have to follow the same steps as in a case of a compiler:
parsing, tree construction and code generation. In this case the code
generation is made in target language that is of a higher level that the
source language.

You can do these steps using one or more tools as well as by hand.

When using ANTLR you have another automation option: the tree traverse.

But remember: you have to make the rules for the translation.

Robert

----- Original Message -----
From: "pietschoutteten" <pietschoutteten at yahoo.com>
To: <antlr-interest at yahoogroups.com>
Sent: Thursday, February 14, 2002 4:41 PM
Subject: [antlr-interest] Re: Translating PASCAL (or C) into JAVA


> Thank you Robert.
>
> I know that one can never translate some source for 100% and I am
> aware of the problems you've mentioned, they are the problem. There
> is always a part that have to be made by hand.
> But my question is
> how can I translate PASCAL into JAVA with ANTLR?
>
> Thanks
> Piet
>
>
> --- In antlr-interest at y..., "Robert" <renyedi at y...> wrote:
> > Hi
> >
> > It is possible to translate Pascal or C into Java, but not for the
> whole
> > language. There is a 80-90% part of the language that should be
> translated
> > relatively straightforward.
> >
> > However, when it comes about pointers and pointer related constructs
> > problems arise (this is especially a problem in case of C). And
> let's not
> > forget about the source language's libraries for which you may not
> have the
> > source code and you should make an emulation. This is the hard part.
> >
> > Robert
> >
> > ----- Original Message -----
> > From: "pietschoutteten" <pietschoutteten at y...>
> > To: <antlr-interest at y...>
> > Sent: Thursday, February 14, 2002 3:18 PM
> > 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/
> > >
> >
> >
> > _________________________________________________________
> > Do You Yahoo!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


 

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



More information about the antlr-interest mailing list