Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stéphane Adjemian
dynare
Commits
65823417
Commit
65823417
authored
15 years ago
by
Houtan Bastani
Browse files
Options
Downloads
Patches
Plain Diff
enable multi-line native matlab statements
parent
a0cd4b33
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
preprocessor/DynareFlex.ll
+34
-22
34 additions, 22 deletions
preprocessor/DynareFlex.ll
preprocessor/ParsingDriver.cc
+9
-3
9 additions, 3 deletions
preprocessor/ParsingDriver.cc
preprocessor/ParsingDriver.hh
+3
-1
3 additions, 1 deletion
preprocessor/ParsingDriver.hh
with
46 additions
and
26 deletions
preprocessor/DynareFlex.ll
+
34
−
22
View file @
65823417
...
@@ -44,6 +44,7 @@ int comment_caller, line_caller;
...
@@ -44,6 +44,7 @@ int comment_caller, line_caller;
this
flag
is
set
to
1
,
when
command
finished
it
is
set
to
0
this
flag
is
set
to
1
,
when
command
finished
it
is
set
to
0
*
/
*
/
int
sigma_e
=
0
;
int
sigma_e
=
0
;
string
eofbuff
;
%
}
%
}
%option
c
++
%option
c
++
...
@@ -52,11 +53,12 @@ int sigma_e = 0;
...
@@ -52,11 +53,12 @@ int sigma_e = 0;
%option
case-insensitive
noyywrap
nounput
batch
debug
never-interactive
%option
case-insensitive
noyywrap
nounput
batch
debug
never-interactive
/
*
NB:
if
new
start
conditions
are
defined
,
add
them
in
the
line
for
[
\n
]
+
*
/
/
*
NB:
if
new
start
conditions
are
defined
,
add
them
in
the
line
for
[
\n
]
+
and
<<
EOF
>>
*
/
%x
COMMENT
%x
COMMENT
%x
DYNARE_STATEMENT
%x
DYNARE_STATEMENT
%x
DYNARE_BLOCK
%x
DYNARE_BLOCK
%x
NATIVE
%x
NATIVE
%x
NATIVE_COMMENT
%x
LINE1
%x
LINE1
%x
LINE2
%x
LINE2
%x
LINE3
%x
LINE3
...
@@ -569,29 +571,39 @@ int sigma_e = 0;
...
@@ -569,29 +571,39 @@ int sigma_e = 0;
/* Add the native statement */
/* Add the native statement */
<NATIVE>{
<NATIVE>{
[^/%*\n]* |
[^/%*\n\.]* |
\.{1,2} |
"
*
" |
"
*
" |
"
/
" { yymore(); }
"
/
" { yymore(); eofbuff = string(yytext); }
\.{3,}[[:space:]]*\n { driver.add_native_remove_charset(yytext, "
\n
"); }
\n {
\n {
if (strlen(yytext) > 1)
driver.add_native_remove_charset(yytext, "
\n
");
driver.add_native_remove_charset(yytext, "
\n
");
BEGIN INITIAL;
BEGIN INITIAL;
}
}
"
%".*
{
<<EOF>>
{
driver.add_native
_remove_charset(yytext, "%"
);
driver.add_native
(eofbuff
);
BEGIN INITIAL
;
yyterminate()
;
}
}
"
//
".* {
\.{3,}[[:space:]]*"
%".*\n |
driver.add_native_remove_charset(yytext, "
//
");
"%"[^\n]* { driver.add_native_remove_charset(yytext, "%"); }
BEGIN INITIAL;
\.{3,}[[:space:]]*"
//
".*\n |
"
//
"[^\n]* { driver.add_native_remove_charset(yytext, "
//
"); }
\.{3,}[[:space:]]*"
/
*
" {
driver.add_native_remove_charset(yytext, "
/
*
");
BEGIN NATIVE_COMMENT;
}
}
"
/
*
" {
"
/
*
" {
driver.add_native_remove_charset(yytext, "
/
*
");
driver.add_native_remove_charset(yytext, "
/
*
");
comment_caller =
INITIAL
;
comment_caller =
NATIVE
;
BEGIN COMMENT;
BEGIN COMMENT;
}
}
}
}
<*><<EOF>> { yyterminate(); }
<NATIVE_COMMENT>"
*
/
"[[:space:]]*\n { BEGIN NATIVE; }
<NATIVE_COMMENT>.
<INITIAL,DYNARE_STATEMENT,DYNARE_BLOCK,COMMENT,LINE1,LINE2,LINE3,NATIVE_COMMENT><<EOF>> { yyterminate(); }
<*>. { driver.error(*yylloc, "
character
unrecognized
by
lexer
"); }
<*>. { driver.error(*yylloc, "
character
unrecognized
by
lexer
"); }
%%
%%
...
...
This diff is collapsed.
Click to expand it.
preprocessor/ParsingDriver.cc
+
9
−
3
View file @
65823417
...
@@ -1840,14 +1840,20 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in
...
@@ -1840,14 +1840,20 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in
}
}
void
void
ParsingDriver
::
add_native_remove_charset
(
const
char
*
s
,
const
char
*
token
)
ParsingDriver
::
add_native
(
const
string
&
s
)
{
mod_file
->
addStatement
(
new
NativeStatement
(
s
));
}
void
ParsingDriver
::
add_native_remove_charset
(
const
char
*
s
,
const
string
&
token
)
{
{
string
str
=
string
(
s
);
string
str
=
string
(
s
);
string
tok
=
string
(
token
);
size_t
found
=
str
.
find
(
token
);
size_t
found
=
str
.
find
(
token
);
assert
(
found
!=
string
::
npos
);
assert
(
found
!=
string
::
npos
);
mod_file
->
addStatement
(
new
NativeStatement
(
str
.
substr
(
0
,
found
)));
str
.
resize
(
found
);
add_native
(
str
);
}
}
void
void
...
...
This diff is collapsed.
Click to expand it.
preprocessor/ParsingDriver.hh
+
3
−
1
View file @
65823417
...
@@ -489,8 +489,10 @@ public:
...
@@ -489,8 +489,10 @@ public:
void
add_external_function_arg
(
NodeID
arg
);
void
add_external_function_arg
(
NodeID
arg
);
//! Adds an external function call node
//! Adds an external function call node
NodeID
add_model_var_or_external_function
(
string
*
function_name
,
bool
in_model_block
);
NodeID
add_model_var_or_external_function
(
string
*
function_name
,
bool
in_model_block
);
//! Adds a native statement
void
add_native
(
const
string
&
s
);
//! Adds a native statement, first removing the set of characters passed in token (and everything after)
//! Adds a native statement, first removing the set of characters passed in token (and everything after)
void
add_native_remove_charset
(
const
char
*
s
,
const
char
*
token
);
void
add_native_remove_charset
(
const
char
*
s
,
const
string
&
token
);
//! Resets data_tree and model_tree pointers to default (i.e. mod_file->expressions_tree)
//! Resets data_tree and model_tree pointers to default (i.e. mod_file->expressions_tree)
void
reset_data_tree
();
void
reset_data_tree
();
//! Begin a steady_state_model block
//! Begin a steady_state_model block
...
...
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