[antlr-interest] Is there an updated version of the Whitespace article for antlr v3?

Jahagirdar, Vijayvithal Vijayvithal.Jahagirdar at lsi.com
Wed Jul 13 23:58:04 PDT 2011


I am trying to extend an existing language which only has basic data types (int, float etc.) to support complex data types (similar to struct in C).
I was planning to execute the implementation in the following manner.

1.       Write the grammer   --- Done

2.       Write a null translator whose output will be the same as the input --- Using the article at " http://www.antlr.org/article/whitespace/index.html  Preserving whitespace during translation" for reference This was written for antler 2.x and does not work with antlr 3.x. Also the files referenced in the article are no longer distributed with antlr3. Can anyone help me by pointing an equivalent reference that works with antlr3....

3.       Perform a first pass over the code to identify all struct definitions and populate a list with the same.

4.       Perform a second pass to replace all struct variable declaration's and assignments with the normal data types.
Is my approach correct? Is there a better way?

e.g. consider
struct { int a, //declare a
float b //declare b
} xyz;
xyz foo,bar; //two vars
foo.a=bar.a; //assignment
foo=bar;//another variation
f(bar);

I am planning to translate this to

//two vars
int foo_a; //declare a
float foo_b; //declare b
//two vars
int bar_a; //declare a
int bar_b; //declare b
foo_a=bar_a; //assignment

foo_a=bar_a;// another variation a
foo_b=bar_b; // another variation b
f(bar_a,bar_b)
Regards
Vijay



More information about the antlr-interest mailing list