I use Bison and Flex to create a pair of reenter / analyzer, but I canβt wrap my head around where everything should be included and declared.
First of all, I use reentrant Flex, so I need to first pass the yyscan_t scanner yyscan_t to Bison by declaring %parse-param {yyscan_t scanner} , and then make Bison pass this Flex by declaring %lex-param {yyscan_t scanner} . But yyscan_t not declared by Bison, so I have to include the Flex scanner header file (which I named scanner.flex.h) in the Bison file. But since my Flex file includes my Bison header, and my Bison header now includes the Flex header, I get a circular set that randomly messes up the stuff!
And let me say that I want to add location tracking using %locations to my Bison file and %bison-locations to my Flex file. Now I need to change the declaration of my yyerror and my yylex (it seems I need to define yylex AGAIN, although it is defined in the Flex header, but I canβt include it, remember?) In my Bison file, to include the YYLTYPE pointer, But now what? It seems that the default YYLTYPE declaration is AFTER the prolog has been entered, and therefore I cannot use this default YYLTYPE in the declaration of my yyerror and my yylex.
I understand that there are many workarounds for these problems ... but how should you do it right? It completely eludes me, and it just leaves my head a mess ...
Emil Eriksson
source share