[antlr-interest] Enriching an AST with additional nodes with infos from existing nodes
Heiko Folkerts
heiko.folkerts at david-software.de
Fri May 27 02:48:58 PDT 2011
Hi,
The subject sounds more complicated than my problem is:
I have an AST that results from a quite simple language. Now we want to transform that language to C++-code using ANTLR and string templates as proposed in the books.
Since our language ist not static (keywords are stored in a database and not directly in the parser) transformation should be done by enriching the AST with the coresponding code fragments for a statement in the source language. A C++-Function will retrieve the translation from the database.
Q1: Is this a good way to go in this case?
Since the AST creation is done in a C++ application we cannot use database access when running the transformation using string templates. The transformation is made by a seperate program and the AST is handed over as a string.
Q2: If enriching the AST with the code translation for every statement is the way to go: Should the additional node (that for the code) created by an arbitrary action or is there a better way?
To make things a bit clearer here is a short example:
Input language:
Motor einschalten
Fahrzeug beschleunigen
Target language:
Simulator.Engine(EngineOn);
Simulator.Speed_up();
Regards
Heiko
Mit freundlichem Gruß
Heiko Folkerts
--
_______________________________________________________
DAVID Software GmbH · Wendenring 1 · 38114 Braunschweig
Tel.: +49 531 24379-14
Fax.: +49 531 24379-79
E-Mail: mailto:heiko.folkerts at david-software.de
WWW: http://www.david-software.de
Eintragung: Amtsgericht Braunschweig, HRB 3167
Geschäftsführer: Frank Ptok
_______________________________________________________
More information about the antlr-interest
mailing list