Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3396 handle properly complex init of variables in 06 file #3397

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@ def read_06inz_c_file(self):
# Find functions of type MODEL_NAME_eqFunction_N and variable assignment expressions
# Regular expression to recognize a line of type var = rhs
ptrn_assign_var = re.compile(r'^[ ]*data->localData(?P<var>\S*)[ ]*\/\* (?P<varName>[\w\$\.()\[\],]*) [\w(),\.]+ \*\/[ ]*=[ ]*(?P<rhs>[^;]+);')
ptrn_assign_var_complex = re.compile(r'^[ ]*data->modelData->(?P<var>\S*)\.attribute[ ]*\/\* (?P<varName>[ \w\$\.()\[\],]*) [\w(),\.\[\]]+ \*\/.start[ ]*=[^;]*;$')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure you are using the group name 'var' from this regex, am I correct?

ptrn_param = re.compile(r'^[ ]*data->simulationInfo->(?P<var>\S*)[ ]*\/\* (?P<varName>[ \w\$\.()\[\],]*) PARAM \*\/[ ]*=[ ]*(?P<rhs>[^;]+);')
for init_file in self._06inz_c_file:
with open(init_file, 'r') as f:
Expand All @@ -1039,6 +1040,14 @@ def read_06inz_c_file(self):
(list_body, depend) = replace_dynamic_indexing(list_body)

for line in list_body:
#Sometime a complex init ends up in 06...
#data->modelData->realVarsData[...].attribute.start = data->simulationInfo->realParameter[..];
#data->localData[0]->realVars[...] = data->modelData->realVarsData[...].attribute.start;
if ptrn_assign_var_complex.search(line) is not None:
match = re.search(ptrn_assign_var_complex, line)
var = str(match.group('varName'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming seems a bit confusing : the python variable named var is filled with the data extracted from the regex group named "varName" whereas in the same regex there is another group named "var" which seems to be unused. Is my understanding correct?

self.var_init_val[ var ] = list_body
break
if ptrn_assign_var.search(line) is not None:
match = re.search(ptrn_assign_var, line)
var = str(match.group('varName'))
Expand Down