Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
preprocessor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
preprocessor
Commits
69abc08d
Commit
69abc08d
authored
8 years ago
by
Houtan Bastani
Browse files
Options
Downloads
Patches
Plain Diff
macroprocessor: stop with error when division by zero is encountered. closes #1278
parent
bb6ad83e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
macro/MacroBison.yy
+7
-2
7 additions, 2 deletions
macro/MacroBison.yy
macro/MacroValue.hh
+2
-1
2 additions, 1 deletion
macro/MacroValue.hh
with
9 additions
and
3 deletions
macro/MacroBison.yy
+
7
−
2
View file @
69abc08d
/*
/*
* Copyright (C) 2008-201
4
Dynare Team
* Copyright (C) 2008-201
6
Dynare Team
*
*
* This file is part of Dynare.
* This file is part of Dynare.
*
*
...
@@ -150,7 +150,12 @@ expr : INTEGER
...
@@ -150,7 +150,12 @@ expr : INTEGER
| expr TIMES expr
| expr TIMES expr
{ TYPERR_CATCH($$ = *$1 * *$3, @$); }
{ TYPERR_CATCH($$ = *$1 * *$3, @$); }
| expr DIVIDE expr
| expr DIVIDE expr
{ TYPERR_CATCH($$ = *$1 / *$3, @$); }
{
if (dynamic_cast<const IntMV *>($3) != NULL
&& ((IntMV *)$3)->get_int_value() == 0)
driver.error(@$, "Division by zero");
TYPERR_CATCH($$ = *$1 / *$3, @$);
}
| expr LESS expr
| expr LESS expr
{ TYPERR_CATCH($$ = *$1 < *$3, @$); }
{ TYPERR_CATCH($$ = *$1 < *$3, @$); }
| expr GREATER expr
| expr GREATER expr
...
...
This diff is collapsed.
Click to expand it.
macro/MacroValue.hh
+
2
−
1
View file @
69abc08d
/*
/*
* Copyright (C) 2008-201
3
Dynare Team
* Copyright (C) 2008-201
6
Dynare Team
*
*
* This file is part of Dynare.
* This file is part of Dynare.
*
*
...
@@ -158,6 +158,7 @@ public:
...
@@ -158,6 +158,7 @@ public:
If mv2 < mv1, returns an empty range (for consistency with MATLAB).
If mv2 < mv1, returns an empty range (for consistency with MATLAB).
*/
*/
static
const
MacroValue
*
new_range
(
MacroDriver
&
driver
,
const
MacroValue
*
mv1
,
const
MacroValue
*
mv2
)
throw
(
TypeError
);
static
const
MacroValue
*
new_range
(
MacroDriver
&
driver
,
const
MacroValue
*
mv1
,
const
MacroValue
*
mv2
)
throw
(
TypeError
);
inline
int
get_int_value
()
const
{
return
value
;
};
};
};
//! Represents a string value in macro language
//! Represents a string value in macro language
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment