[antlr-interest] How to use ANTLR to find function pointers

Paul Keir paul at paulkeir.com
Wed Jul 18 03:24:04 PDT 2007


ANTLR has a very useful C example grammar. Within it, the parameters of 
a function pointer are one of a number of things which will be caught at 
line 223 of the rule 'direct_declarator'.

// File  C.g
// Line# 223

|    '(' declarator ')'

If you add a Java print statement after this, you will print out 
function pointer parameters and more besides. i.e:

|    '(' declarator ')' { System.out.println($declarator.text); }


This is only a start, sadly function pointers are not _specifically_ 
identified in the few C grammars I have seen.

Paul


More information about the antlr-interest mailing list