Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dynare
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
122
Issues
122
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dynare
dynare
Commits
8d9de2d5
Commit
8d9de2d5
authored
Dec 01, 2017
by
Houtan Bastani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
macroprocessor: add @#echomacrovars command. #1564
parent
93a0351a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
2 deletions
+51
-2
preprocessor/macro/MacroDriver.cc
preprocessor/macro/MacroDriver.cc
+10
-0
preprocessor/macro/MacroDriver.hh
preprocessor/macro/MacroDriver.hh
+3
-0
preprocessor/macro/MacroFlex.ll
preprocessor/macro/MacroFlex.ll
+3
-1
preprocessor/macro/MacroValue.cc
preprocessor/macro/MacroValue.cc
+13
-1
preprocessor/macro/MacroValue.hh
preprocessor/macro/MacroValue.hh
+22
-0
No files found.
preprocessor/macro/MacroDriver.cc
View file @
8d9de2d5
...
...
@@ -205,3 +205,13 @@ MacroDriver::error(const Macro::parser::location_type &l, const MacroValue *valu
error
(
l
,
sval
->
value
);
}
void
MacroDriver
::
printvars
(
const
Macro
::
parser
::
location_type
&
l
)
const
{
cout
<<
"Macroprocessor: Printing macro variable values at line "
<<
l
<<
endl
;
for
(
map
<
string
,
const
MacroValue
*>::
const_iterator
it
=
env
.
begin
();
it
!=
env
.
end
();
it
++
)
cout
<<
"|- "
<<
it
->
first
<<
" = "
<<
it
->
second
->
print
()
<<
endl
;
cout
<<
endl
;
}
preprocessor/macro/MacroDriver.hh
View file @
8d9de2d5
...
...
@@ -197,6 +197,9 @@ public:
//! Error handler
void
error
(
const
Macro
::
parser
::
location_type
&
l
,
const
string
&
m
)
const
;
//! Print variables
void
printvars
(
const
Macro
::
parser
::
location_type
&
l
)
const
;
//! Set a variable
void
set_variable
(
const
string
&
name
,
const
MacroValue
*
value
);
...
...
preprocessor/macro/MacroFlex.ll
View file @
8d9de2d5
/
*
*
Copyright
(
C
)
2008-201
6
Dynare
Team
*
Copyright
(
C
)
2008-201
7
Dynare
Team
*
*
This
file
is
part
of
Dynare
.
*
...
...
@@ -236,6 +236,8 @@ CONT \\\\
<
STMT
>
line
{
return
token:
:LINE
; }
<
STMT
>
define
{
return
token:
:DEFINE
; }
<
STMT
>
echomacrovars
{
SPC
}*{
EOL
}
{
driver
.
printvars
(*
yylloc
)
; BEGIN(INITIAL); }
<
STMT
>
for
{
reading_for_statement
=
true
; return token::FOR; }
<
STMT
>
endfor
{
driver
.
error
(*
yylloc
,
"@#endfor is not matched by a @#for statement"
)
; }
...
...
preprocessor/macro/MacroValue.cc
View file @
8d9de2d5
/*
* Copyright (C) 2008-201
4
Dynare Team
* Copyright (C) 2008-201
7
Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -280,6 +280,12 @@ IntMV::toString() const
return
ss
.
str
();
}
string
IntMV
::
print
()
const
{
return
toString
();
}
const
MacroValue
*
IntMV
::
toArray
()
const
{
...
...
@@ -398,6 +404,12 @@ StringMV::toString() const
return
value
;
}
string
StringMV
::
print
()
const
{
return
toString
();
}
const
MacroValue
*
StringMV
::
toArray
()
const
{
...
...
preprocessor/macro/MacroValue.hh
View file @
8d9de2d5
...
...
@@ -91,6 +91,8 @@ public:
virtual
const
MacroValue
*
operator
[](
const
MacroValue
&
mv
)
const
throw
(
TypeError
,
OutOfBoundsError
);
//! Converts value to string
virtual
string
toString
()
const
=
0
;
//! Converts value to be printed
virtual
string
print
()
const
=
0
;
//! Converts value to array form
virtual
const
MacroValue
*
toArray
()
const
=
0
;
//! Gets length
...
...
@@ -147,6 +149,7 @@ public:
//! Computes logical negation
virtual
const
MacroValue
*
operator
!
()
const
throw
(
TypeError
);
virtual
string
toString
()
const
;
virtual
string
print
()
const
;
//! Converts value to array form
/*! Returns an integer array containing a single value */
virtual
const
MacroValue
*
toArray
()
const
;
...
...
@@ -187,6 +190,7 @@ public:
virtual
const
MacroValue
*
operator
[](
const
MacroValue
&
mv
)
const
throw
(
TypeError
,
OutOfBoundsError
);
//! Returns underlying string value
virtual
string
toString
()
const
;
virtual
string
print
()
const
;
//! Converts value to array form
/*! Returns a string array containing a single value */
virtual
const
MacroValue
*
toArray
()
const
;
...
...
@@ -226,6 +230,7 @@ public:
virtual
const
MacroValue
*
operator
[](
const
MacroValue
&
mv
)
const
throw
(
TypeError
,
OutOfBoundsError
);
//! Returns a string containing the concatenation of string representations of elements
virtual
string
toString
()
const
;
virtual
string
print
()
const
;
//! Returns itself
virtual
const
MacroValue
*
toArray
()
const
;
//! Gets length
...
...
@@ -335,6 +340,23 @@ ArrayMV<T>::toString() const
return
ss
.
str
();
}
template
<
typename
T
>
string
ArrayMV
<
T
>::
print
()
const
{
ostringstream
ss
;
ss
<<
"["
;
for
(
typename
vector
<
T
>::
const_iterator
it
=
values
.
begin
();
it
!=
values
.
end
();
it
++
)
{
if
(
it
!=
values
.
begin
())
ss
<<
", "
;
ss
<<
*
it
;
}
ss
<<
"]"
;
return
ss
.
str
();
}
template
<
typename
T
>
const
MacroValue
*
ArrayMV
<
T
>::
toArray
()
const
...
...
Write
Preview
Markdown
is supported
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