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
913bc2f8
Commit
913bc2f8
authored
Sep 24, 2018
by
Sébastien Villemot
Browse files
Macro-processor, comprehension: fix error message, add comments
parent
3e5c8dd8
Pipeline
#53
passed with stage
in 1 minute and 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/macro/MacroDriver.cc
View file @
913bc2f8
...
...
@@ -323,7 +323,7 @@ MacroDriver::possibly_add_comprehension_element(vector<MacroValuePtr> &v, MacroV
{
auto
ival
=
dynamic_pointer_cast
<
IntMV
>
(
test_expr
);
if
(
!
ival
)
throw
MacroValue
::
TypeError
(
"In a comprehension, the expression after the
'if'
must evaluate to an integer"
);
throw
MacroValue
::
TypeError
(
"In a comprehension, the expression after the
semicolon
must evaluate to an integer"
);
if
(
ival
->
value
)
{
assert
(
!
comprehension_stack
.
empty
());
...
...
src/macro/MacroDriver.hh
View file @
913bc2f8
...
...
@@ -129,11 +129,17 @@ private:
//! Set to true while parsing an IF statement (only the statement, not the body)
bool
reading_if_statement
;
//! Set to true while parsing the comprehension in a new buffer
bool
is_comprehension_context
{
false
};
//! Counter for the current comprehension
int
comprehension_iter_nb
{
0
};
//! The lexer start condition (EXPR or STMT) before entering the comprehension
int
comprehension_start_condition
;
//! Number of nested comprehensions, used during the construction of the new lexer buffer
int
nested_comprehension_nb
{
0
};
//! Temporary stores for the new lexer buffer
string
comprehension_clause
,
comprehension_clause_tmp
;
//! Stores for the location of the comprehension clause
Macro
::
parser
::
location_type
comprehension_clause_loc
,
comprehension_clause_loc_tmp
;
//! Output the @#line declaration
...
...
@@ -266,9 +272,13 @@ public:
in that case it destroys the pointer given to init_loop() */
bool
iter_loop
()
noexcept
(
false
);
//! Initializes the evaluation of a comprehension
void
init_comprehension
(
const
vector
<
string
>
&
names
,
MacroValuePtr
value
);
//! Iterates during the evaluation of the comprehension
void
iter_comprehension
();
//! Helper to construct the value corresponding to the comprehension
void
possibly_add_comprehension_element
(
vector
<
MacroValuePtr
>
&
v
,
MacroValuePtr
test_expr
)
const
;
//! Returns the size of the set over which the current comprehension iterates
int
get_comprehension_iter_nb
()
const
;
//! Begins an @#if statement
...
...
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