help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Can't compile bison/flex output


From: Hans Aberg
Subject: RE: Can't compile bison/flex output
Date: Mon, 19 Feb 2001 12:13:32 +0100

[Please keep the cc to the help-bison list.]
At 22:09 -0600 2001/02/18, Richard Garand wrote:
>Here's some errors:
>"undefined reference to yylval"
>"undefined reference to address@hidden"
>"yyin undeclared"
>"parse error before ')'"
>"stdio.h:52: 'FILE' used prior to declaration"

-- You should have posted these errors directly:

The parser that Bison writes contains a line
  YYSTYPE yylval;
and you must declare YYSTYPE somewhere, for example (under C++)
  class my_type {
  public:
    Foo foo;
    Bar bar;
    ...
  };

  #define YYSTYPE my_type

Then you can use the fields yylval.foo, yylval.bar, etc.

There are variations of this -- the Bison %union option, see the Bison
manual -- but I would suggest you to not try it, before you have gotten the

>How do you compile your parsers? I don't care if I can't use gcc, I just
>want it to compile.

The problem isn't with GCC -- clearly GCC is Gnu, as is Bison, so you are
probably best off with it. You have simply not written correct code. Try
starting with some small example you surely know works, and then expand on
it.

Otherwise I use Metrowerks CodeWarrior IDE (integrated development
environment)  for MacOS, for which I first made Flex & Bsion compiler
plugins; I then compile the output as C++ using separate headers (the Flex
sources not directly included from the Bison sources).

  Hans Aberg





reply via email to

[Prev in Thread] Current Thread [Next in Thread]