[antlr-interest] Multiplication and pointers in C-style language

Gavin Lambert antlr at mirality.co.nz
Wed Apr 9 02:39:26 PDT 2008


At 19:01 9/04/2008, David Olsson wrote:
>Actually, I have been looking quite a lot at the C example but as 
>a novice when it comes to ANTLR and constructing languages I 
>don't really see how and why it works. Perhaps I should rephrase 
>my question; can anyone explain how and why the ANSI C example 
>grammar works with the multiplication and pointer situation 
>described below? :-)

I'm not sure if the example shows it (I haven't looked at it in a 
while), but this sort of problem requires semantic 
disambiguation.  Specifically, you need to examine the first 
identifier token and figure out whether it's a type or a 
variable.  You should be able to do this since both types and 
variables are required to be declared before they are used.



More information about the antlr-interest mailing list