Search code examples
compiler-constructionbisonflex-lexeryacc

I got error saying '%yacc' and '%define api.value.type "union"' cannot be used together


I am working on creating a simple compiler, I need to generate a Symantec value type, I have checked that link, and I need to add this line in my parser.y file:

%define api.value.type union

to inform the bison that the tags used with the %token and %type directives are genuine types.

but I got that strange error:

parser.y: error: '%yacc' and '%define api.value.type "union"' cannot be used together

I don't understand what the "%yacc" variable and why got that error, as far as I understand, the '%define api.value.type "union"' I can use it inside the parser normally, and I can't find any information or resources about that error.


Solution

  • As noted on this page of the documentation, bison includes a yacc front end that runs bison -y. The -y option forces various yacc-compatibility settings as described here.

    Hence, the solution is to run bison rather than yacc.