%{
#ifdef abc
.
.
. // C declarations
.
%}
.
. // Yacc Declaration
.
%%
.
. //expected inputs and corresponding actins
.
%%
#endif
Although this code compiles for me even then I strongly feel #ifdef abc is not placed correctly. Is this type of code valid for Yacc.
I have very little experience in YACC.
Thanks
The code between
%{and%}is put verbatim at the top of the generated C source file, while the code after the rules is also put verbatim but at the end of the generated file.So the answer to your question is: Yes, it’s correct in both Yacc and the generated source. However, from a readability point of view, the Yacc-code might be considered dubious.