Commit 1afd46b8 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Refactor bison files using new prologue syntax.

parent 10c4b8a0
......@@ -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
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment