Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dynare
preprocessor
Commits
4d95aa8d
Commit
4d95aa8d
authored
Dec 30, 2013
by
Stéphane Adjemian
Browse files
Merge branch 'master' into sim1-with-variable-dimension
parents
57936ef8
e0f66212
Changes
4
Hide whitespace changes
Inline
Side-by-side
DynareBison.yy
View file @
4d95aa8d
...
...
@@ -18,43 +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.3
a
,
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
.
*/
%{
using
namespace
std
;
%
code
top
{
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
=
(
Rhs
)[
1
].
begin
;
\
(
Current
).
end
=
(
Rhs
)[
N
].
end
;
\
}
\
else
\
{
\
(
Current
).
begin
=
(
Current
).
end
=
(
Rhs
)[
0
].
end
;
\
}
\
driver
.
location
=
(
Current
);
\
}
while
(
false
)
%}
%
name
-
prefix
=
"Dynare"
%
name
-
prefix
"Dynare"
%
parse
-
param
{
ParsingDriver
&
driver
}
%
lex
-
param
{
ParsingDriver
&
driver
}
...
...
@@ -79,7 +55,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 +80,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
...
...
ExprNode.hh
View file @
4d95aa8d
...
...
@@ -20,13 +20,13 @@
#ifndef _EXPR_NODE_HH
#define _EXPR_NODE_HH
using
namespace
std
;
#include
<set>
#include
<map>
#include
<vector>
#include
<ostream>
using
namespace
std
;
#include
"SymbolTable.hh"
#include
"CodeInterpreter.hh"
#include
"ExternalFunctionsTable.hh"
...
...
macro/MacroBison.yy
View file @
4d95aa8d
...
...
@@ -18,24 +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.
*/
%{
using namespace std;
#include "MacroValue.hh"
%code top {
class MacroDriver;
%
}
}
%name-prefix
=
"Macro"
%name-prefix
"Macro"
%parse-param { MacroDriver &driver }
%parse-param { ostream &out }
...
...
@@ -51,6 +41,10 @@ class MacroDriver;
%debug
%error-verbose
%code requires {
#include "MacroValue.hh"
}
%union
{
string *string_val;
...
...
@@ -58,7 +52,7 @@ class MacroDriver;
const MacroValue *mv;
};
%{
%
code
{
#include <cstdlib> // Pour atoi()
#include "MacroDriver.hh"
...
...
@@ -77,7 +71,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
...
...
macro/MacroValue.hh
View file @
4d95aa8d
...
...
@@ -20,12 +20,12 @@
#ifndef _MACRO_VALUE_HH
#define _MACRO_VALUE_HH
using
namespace
std
;
#include
<string>
#include
<vector>
#include
<sstream>
using
namespace
std
;
class
MacroDriver
;
//! Base class for representing values in macro language
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment