tags:

views:

55

answers:

1

On some linux machines when I compile my yacc program it works fine. However, on other machines, I noticed that none of the c statements that are interspersed with the grammar rules are ever executed, even printf. What could be the problem? I noticed that on these machines I have to take out the -ly option because it gives an error if I try to compile with it.

An example is the following:

 declaration : var_declaration
             | fun_declaration 
             | '$' {printTable();} ;

The last line, which usually works fine, will not execute.

+2  A: 

Are you sure you have Yacc installed there at all? It's weird -ly isn't needed because it's what links Yacc's libraries with your code. It can also be that Yacc is very old or simply broken on those machines.

You can try something like the following: on the problematic platform, run yacc in standalone mode on your .y file and examine the resulting code. Try to find your C statements there. To make it all simpler, start with a small toy grammar and then move to your real/large grammar.

Eli Bendersky
I tried without -ly on my machine where the code works, and it stopped working. So I think the problem is that -ly wasn't used.
Phenom