title: Bison/Flex declaration mess... how what should I include/declare where?
body: <p>I'm using Bison and Flex to make a reentrant scanner/parser pair but can't wrap my head around where everything is to be included and declared.</p>
  
  <p>First of all, I'm using reentrant Flex so I need to pass the <code>yyscan_t</code> scanner type first to Bison by declaring <code>%parse-param {yyscan_t scanner}</code> and then make Bison pass this to Flex by declaring <code>%lex-param {yyscan_t scanner}</code>. But <code>yyscan_t</code> is not declared by Bison so I must include the Flex generated scanner header file (which I named scanner.flex.h) in my Bison file. But since my Flex file includes my Bison header, and my Bison header now includes the Flex header, I get circular includes which messes up stuff in unpredictable ways!</p>
  
  <p>And let's say I want to add in location tracking with <code>%locations</code> in my Bison file and <code>%bison-locations</code>in my Flex file. Now I need to change the declaration of my yyerror and my yylex (it seems I have to define yylex AGAIN even though it's defined in the Flex generated header but I cannot include that, remember?) functions in my Bison file to include the YYLTYPE pointer. But what now? It seems that the default YYLTYPE declaration is placed AFTER the prologue is inserted and thus I cannot use this default YYLTYPE in the declaration of my yyerror and my yylex.</p>
  
  <p>I realize that there are a lot of workarounds to these problems... but how are you supposed to do it properly? It totally escapes me and this just leaves my head a mess...</p>