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

StackOverflow https://stackoverflow.com/questions/19345459

  •  30-06-2022
  •  | 
  •  

Question

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/

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top