0
votes

My Parser.y file contains below code.

%defines "Parser.h"

I've compiled this file and I've got a below error.

$ bison Parser.y

Parser.y:27.10-19: syntax error, unexpected string

So I've made this line commented.

//%defines "Parser.h"

I've compiled this file and I've got no error but It didn't make output header file.

And I've changed compile option.

$ bison Parser.y --defines=Parser.h

It was successful but I don't want use option with "bison" command.

In other words, I want to use %defines option in bison file.

What should I do?

Sorry for pooooooor english.

1
post full code in order others to run your code and see the errorpinkpanther
@pinkpanther thanks for comment but it was solved. the full code is here.user2450120

1 Answers

0
votes

The %defines directive is supported in Bison 2.6.2.

Superficially, it appears that you are not using a sufficiently recent version of Bison and your version does not support %defines. However, that seems improbable; you'd have to be using a version that's a decade or more old (the first reference in the ChangeLog to %defines is dated in 2001).

Another possibility is that you've not included it at an appropriate point in the grammar file. I believe it should appear before the first %% that marks the start of the grammar proper.

You could try omitting the file name; if the source is Parser.y and you write a line %defines, the generated header is Parser.h anyway. I'm not confident this will work, but it is worth a try.