From 42d166e272783a70784acb521aee32e86c0e1082 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?=
 <sebastien.villemot@sciencespo.fr>
Date: Mon, 14 Mar 2016 16:28:24 +0100
Subject: [PATCH] Fix compatibility with Flex 2.6.

In Flex 2.6, the C++ scanner changed. yyout is now a reference (and no
longer a pointer).
---
 DynareFlex.ll      |  8 +++++++-
 macro/MacroFlex.ll | 21 ++++++++++++++++++---
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/DynareFlex.ll b/DynareFlex.ll
index 0bb45809..dedf87dc 100644
--- a/DynareFlex.ll
+++ b/DynareFlex.ll
@@ -238,7 +238,13 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
                            unput('d');
                            free( yycopy );
                          }
-<DYNARE_STATEMENT>${DATE} { yylloc->step(); *yyout << yytext + 1; }
+<DYNARE_STATEMENT>${DATE} { yylloc->step();
+#if (YY_FLEX_MAJOR_VERSION > 2) || (YY_FLEX_MAJOR_VERSION == 2 && YY_FLEX_MINOR_VERSION >= 6)
+                            yyout << yytext + 1;
+#else
+                            *yyout << yytext + 1;
+#endif
+                          }
 <DYNARE_STATEMENT>dates  {dates_parens_nb=0; BEGIN DATES_STATEMENT; yylval->string_val = new string("dates");}
 <DYNARE_STATEMENT>file                  {return token::FILE;}
 <DYNARE_STATEMENT>datafile 		{return token::DATAFILE;}
diff --git a/macro/MacroFlex.ll b/macro/MacroFlex.ll
index 9e694eb4..e25a9ea4 100644
--- a/macro/MacroFlex.ll
+++ b/macro/MacroFlex.ll
@@ -188,7 +188,11 @@ CONT \\\\
                                 }
                               else
                                 {
+#if (YY_FLEX_MAJOR_VERSION > 2) || (YY_FLEX_MAJOR_VERSION == 2 && YY_FLEX_MINOR_VERSION >= 6)
+                                  yyout << endl;
+#else
                                   *yyout << endl;
+#endif
                                   BEGIN(INITIAL);
                                 }
                               return token::EOL;
@@ -383,7 +387,13 @@ CONT \\\\
                             }
 
  /* We don't use echo, because under Cygwin it will add an extra \r */
-<INITIAL>{EOL}              { yylloc->lines(1); yylloc->step(); *yyout << endl; }
+<INITIAL>{EOL}              { yylloc->lines(1); yylloc->step();
+#if (YY_FLEX_MAJOR_VERSION > 2) || (YY_FLEX_MAJOR_VERSION == 2 && YY_FLEX_MINOR_VERSION >= 6)
+                              yyout << endl;
+#else
+                              *yyout << endl;
+#endif
+                            }
 
  /* Copy everything else to output */
 <INITIAL>.                  { yylloc->step(); ECHO; }
@@ -401,8 +411,13 @@ void
 MacroFlex::output_line(Macro::parser::location_type *yylloc) const
 {
   if (!no_line_macro)
-    *yyout << endl << "@#line \"" << *yylloc->begin.filename << "\" "
-           << yylloc->begin.line << endl;
+#if (YY_FLEX_MAJOR_VERSION > 2) || (YY_FLEX_MAJOR_VERSION == 2 && YY_FLEX_MINOR_VERSION >= 6)
+    const_cast<ostream&>(yyout)
+#else
+    *yyout
+#endif
+     << endl << "@#line \"" << *yylloc->begin.filename << "\" "
+     << yylloc->begin.line << endl;
 }
 
 void
-- 
GitLab