[antlr-interest] Another problem in C grammar

Kamil Burzynski nopik at data.pl
Tue Apr 8 04:16:55 PDT 2008


Hello,

 I have just hit on the problem of example C grammar. It is using isTypedef 
boolean hack to build type list. While it is working quite good, it do 
define too much. Namely, I got such sample input:

typedef void (*a)( int b, int c );
typedef union _d d;
union _d
{
  int b;
};

Parser fails on it. Before failing, it outputs, that type 'b' and type 'c' 
were defined. Which is obviously wrong (they do not define types). And 
since 'b' is type, 'int b' cannot be inside of union declaration, so fail.
The isTypedef boolean is being read just after IDENTIFIER, which is 
unfortunately overkill - as in single typedef declaration there are many 
identifiers possible ;( I had not found solution yet, though it should be 
easy to find it (and problem is definitely solvable :D).


-- 
Best regards from
Kamil Burzynski



More information about the antlr-interest mailing list