[antlr-interest] question about antlr

Patrick Hofman patrick.hofman at invantive.com
Thu May 26 06:35:19 PDT 2011


Hi all,

I have bought the ANTLR book in order to learn ANTLR better, but I still don't get how to fix one thing. I hope you can help me with that.

I have a grammar that is used to parse our custom formula format to an Excel formula. So when filling an Excel worksheet the string entered is something like '$C{D,.,.,.+1}' which means 'one cell right from the current cell'. You will understand that eventually we will get something like '$C{D,.,.,.+1} + $C{D,.,.,.+2}', so add up the value of the first cell right and the second cell right (in Excel when we are at A1 this results in '=B1 + B2'.

The problem is this: In the grammar I cannot find a way to 'eat up' the text between two 'eca_kolom_expressie' strings (the '$C{...}' part).

I already tried 'EXCEL_FRAGMENT' in a hundred ways, but none of them seemed to work. ('TILDE (options {greedy=false;} : .) TILDE' seems to work, but when removing the TILDEs it stops working)

I have included the grammar. Can you point me in the right direction?

Regards,

Patrick Hofman
Senior Consultant
Invantive B.V.


More information about the antlr-interest mailing list