[antlr-interest] tree recognition during multiple passes
Anakreon
anakreonmejdi at yahoo.gr
Wed May 12 01:55:52 PDT 2004
excel_robot wrote:
> Hi Guys,
> I'm using Antlr to develop a source to source translator.
> I have read a good bit of the doc and articles and they all seem to
> suggest the following
> 1)lex your input into tokens
> 2)recognize the tokens in your grammar and build a source AST
> 3)recognize and morph your source AST to a target AST using multiple
> passes
> 4)generate your output from the target AST
>
I have developed a source to source translator too. It translates ASP pages
(text + JavaScript + VbScript) into PHP.
Because 2 languages are involved the steps I use are more and of greater
complexity. However, I do not have multiple passes.
Here are my steps
1)lex your input into tokens. A StreamSelector is used to join multiple
languages used in the same ASP page. The vb lexer will do some name
transformation so case sensitiveness of identifiers can be guarantied.
2)recognize the tokens in your grammar and build a source AST. Also find for
each identifier it's type(if it's possible) and recognize functions and classes
declared in the page.
3)recognize and morph your source AST to a target AST. Informations collected
from parsing are used here (functions, classes, identifiers...).
4)generate your output from the target AST. I use an other tree parser for this
who does not produce AST.
This was my approach.
Anakreon
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list