Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

antlr 3.5.1 generates code for C runtime with undeclared indentifier: _empty. any fix available?

Tags:

antlr3

It seems that antlr-3.5.1-complete.jar and antlr-3.5.1-complete-no-st3.jar generates code targeting C runtime that has a lot of the "_empty" identifier in the DFA that is not defined anywhere.

antlr-3.4 generates the code using dfa31_T_empty which should be the correct id.

I could probably fix this by defining _empty as NULL but that's a hack.

Is there any antlr-3.5.2 or so available that fixes this error?

Cheers, Adrian Pop/

like image 463
Adrian Pop Avatar asked Oct 03 '22 17:10

Adrian Pop


1 Answers

I have encountered this error too. The simplest and cleanest solution indeed seems to be to add this to your grammar:

@header
{
   #define _empty NULL
}

The other solution is to add this define to your compiler macro list (/D _empty=null seems to work in both GCC and MSVC).

like image 83
Matěj Zábský Avatar answered Oct 12 '22 11:10

Matěj Zábský