I am using ANTLR4 and the canonical grammar for C as found here:
https://github.com/antlr/grammars-v4/tree/master/c
I am not modifying the grammar in any way. I am finding that the parsing is failing on typedef
statements that occur outside of functions. The simplest example I can give:
PASSES:
main()
{
typedef unsigned int UINT;
return 0;
}
FAILS:
typedef unsigned int UINT;
main()
{
return 0;
}
The error message is:
line 1:0 no viable alternative at input 'typedef'
I am not aware of any rule in C that says typedefs must appear inside functions. Is this a bug in the ANTLR C grammar, or am I doing something wrong?