Greetings!

On Thu, 2010-04-15 at 22:08 +0000, Gouasmi Thouraya wrote:
> Please can someone help me,I want make a transfer between two languages and I 
> want to use ANTLR .   
> Please
> can you tell me where I must put the rules of transformation between
> the two grammars? For the second grammar, do I have to put it? If yes,
> where I must to put it?  

I am sorry but I am not sure I understand your question.

Are you trying to translate an input, in source language A, into an
output, in target language B. For example, are trying to do something
similar to translating C++ into C; or another example translating OCAML
to Scheme?

If so, maybe the below may help. If not, this message will be useless.

So if you want to translate input given in source language A and produce
output in target language B using ANTLR to orchestrate, you *REALLY*
need to read one or both of Dr. Parr's books (I believe the
www.antlr.org website has links to these publications, ask if you are
unable to locate them).

I believe the basic outline of the translation process is as follows:

1) create a grammar to parse (and lex) the source language A. this
grammar should produce an appropriate Abstract Syntax Tree (AST) in
order to support subsequent processing.

2) if your input is not certified as valid for language A, you will need
to develop appropriate tree walking phase(s) to validate the source AST.
E.G. if necessary, perform appropriate semantic analysis of the AST to
ensure that the input truly conforms to source language A.

3) develop a family of StringTemplates that, given an individual AST
node, will produce the desired text of the target language B (probably
by appropriately gluing together other StringTemplate results passed as
parameters).

4) write a tree walker grammar that will orchestrate calls upon the
StringTemplate library from step 3) above. each rule in this tree walker
passes the requisite intermediate strings to the proper template and
accumulates the resultant strings into a single String comprising the
entire resultant target language B program.

5) output the String resultant from step 4) to a file. 


and you really should read one of Dr. Parr's books in order to get a
better answer.

Hope this helps....
   -jbb



List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to