> On 2 Oct 2016, at 05:14, Juan Ceasar <juan.d.cea...@gmail.com> wrote:
> I’m writing a Bison parser and, being relatively new to this, I’m confused > about how to tie my scanner (for flex) together with my bison (version 3.04 > so I can use C++) parser. There is a calculator example in the Bison distribution, and also in the manual, you might check out. It also shows how to use locations for error reporting. > And so I’m a little confused, I could of course declare LBRACE and so forth > as tokens in the parser.y, Yes, all tokens are declared in the gramma file, which is .yy for C++, which defines the token names that the lexer will use. These are macro names for C, but in a enum for C++, so if one has declared say %token LP "(") the lexer rules end with return token::LP; > But then, how does that tie in with the flex scanner?? Then the lexer must read these by: %{ /* -*- C++ -*- */ ... #include "parser.hh" ... %} The C++ calculator example also includes a file "driver.hh". _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison