diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index 4b63badbff98c4b9bf91315b65a20992fcb864ce..3f8b24c3bfa3ff8e7e6689db332be86c5023dc92 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -18,41 +18,19 @@ */ %skeleton "lalr1.cc" -%require "2.3" +%require "2.4" %defines -/* Prologue: - In Bison <= 2.3, it is inserted in both the .cc and .hh files. - In Bison >= 2.3a, it is inserted only in the .cc file. - Since Bison 2.4, the new %code directives provide a cleaner way of dealing - with the prologue. -*/ -%{ +%code top { using namespace std; class ParsingDriver; +} +%code requires { #include "ExprNode.hh" #include "CodeInterpreter.hh" - -/* Little hack: we redefine the macro which computes the locations, because - we need to access the location from within the parsing driver for error - and warning messages. */ -#define YYLLOC_DEFAULT(Current, Rhs, N) \ - do { \ - if (N) \ - { \ - (Current).begin = YYRHSLOC(Rhs, 1).begin; \ - (Current).end = YYRHSLOC(Rhs, N).end; \ - } \ - else \ - { \ - (Current).begin = (Current).end = YYRHSLOC(Rhs, 0).end; \ - } \ - driver.location = (Current); \ - } while(false) - -%} +} %name-prefix "Dynare" @@ -79,7 +57,24 @@ class ParsingDriver; PriorDistributions prior_distributions_val; }; -%{ +%code { +/* Little hack: we redefine the macro which computes the locations, because + we need to access the location from within the parsing driver for error + and warning messages. */ +#define YYLLOC_DEFAULT(Current, Rhs, N) \ + do { \ + if (N) \ + { \ + (Current).begin = YYRHSLOC(Rhs, 1).begin; \ + (Current).end = YYRHSLOC(Rhs, N).end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = YYRHSLOC(Rhs, 0).end; \ + } \ + driver.location = (Current); \ + } while(false) + #include "ParsingDriver.hh" /* this "connects" the bison parser in the driver to the flex scanner class @@ -87,7 +82,7 @@ class ParsingDriver; * current lexer object of the driver context. */ #undef yylex #define yylex driver.lexer->lex -%} +} %token AIM_SOLVER ANALYTIC_DERIVATION AR AUTOCORR %token BAYESIAN_IRF BETA_PDF BLOCK USE_CALIBRATION diff --git a/preprocessor/macro/MacroBison.yy b/preprocessor/macro/MacroBison.yy index 260bc77de9c25c43d43b3e8662633eb65572ed44..ea838ad35c5e9bc88d64c2c426a1530fd318ca12 100644 --- a/preprocessor/macro/MacroBison.yy +++ b/preprocessor/macro/MacroBison.yy @@ -18,22 +18,14 @@ */ %skeleton "lalr1.cc" -%require "2.3" +%require "2.4" %defines -/* Prologue: - In Bison <= 2.3, it is inserted in both the .cc and .hh files. - In Bison >= 2.3a, it is inserted only in the .cc file. - Since Bison 2.4, the new %code directives provide a cleaner way of dealing - with the prologue. -*/ -%{ +%code top { using namespace std; -#include "MacroValue.hh" - class MacroDriver; -%} +} %name-prefix "Macro" @@ -51,6 +43,10 @@ class MacroDriver; %debug %error-verbose +%code requires { +#include "MacroValue.hh" +} + %union { string *string_val; @@ -58,7 +54,7 @@ class MacroDriver; const MacroValue *mv; }; -%{ +%code { #include <cstdlib> // Pour atoi() #include "MacroDriver.hh" @@ -77,7 +73,7 @@ class MacroDriver; driver.error(loc, e.message); \ } -%} +} %token DEFINE LINE FOR IN IF ELSE ENDIF ECHO_DIR ERROR IFDEF IFNDEF %token LPAREN RPAREN LBRACKET RBRACKET EQUAL EOL LENGTH