[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bison + Flex on C++ don't work
From: |
Akim Demaille |
Subject: |
Re: Bison + Flex on C++ don't work |
Date: |
Wed, 8 May 2019 17:59:39 +0200 |
> Le 6 mai 2019 à 02:37, Joao Pedro Abreu De Souza <address@hidden> a écrit :
>
> Hi folks. My friend Nicholas and I are trying to make a compiler for a
> simpler language(just expressions by now) with flex and bison using C++.
Hi guys,
You departed from the original example by using Flex's C++ output.
It changes many things.
I think that your problem is that you specified, in driver.hh:
> // Give Flex the prototype of yylex we want ...
> #define YY_DECL \
> yy::parser::symbol_type yylex(driver &drv)
> // ... and declare it for the parser's sake.
> YY_DECL;
which is a bad because you are asking Flex to define the yylex
*function* instead of the yyFlexLexer::yylex *member function*.
As a result, none of the yyFlexLexer member variables will be
found in yylex.
Fix your definition of YY_DECL into something like
> #define YY_DECL \
> yy::parser::symbol_type yyFlexLexer yylex(driver &drv)
If you really want to use C++ output with Flex, you might find
some inspiration here:
https://gitlab.lrde.epita.fr/vcsn/vcsn/tree/master/lib/vcsn/dot
Cheers.