summaryrefslogtreecommitdiff
path: root/sci2jsyacc.py
diff options
context:
space:
mode:
authorSunil Shetye2018-07-11 10:44:34 +0530
committerSunil Shetye2018-07-11 15:21:08 +0530
commitaabd535925f24c6203eb1a0dcc5b28d9670133de (patch)
tree73c1021fb17dfdf86f088d930311a007cb3f2120 /sci2jsyacc.py
parentdc097af448d4ed55d685c5e87c8cffb70b7fb20a (diff)
downloadsci2js-aabd535925f24c6203eb1a0dcc5b28d9670133de.tar.gz
sci2js-aabd535925f24c6203eb1a0dcc5b28d9670133de.tar.bz2
sci2js-aabd535925f24c6203eb1a0dcc5b28d9670133de.zip
show type for matrix also
Diffstat (limited to 'sci2jsyacc.py')
-rwxr-xr-xsci2jsyacc.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/sci2jsyacc.py b/sci2jsyacc.py
index 2b504049..cde74dfa 100755
--- a/sci2jsyacc.py
+++ b/sci2jsyacc.py
@@ -524,12 +524,24 @@ def p_modelvar_modelvar_expression(p):
def p_assignment_model_modelvar_assignment_modelexpression(p):
'assignment : MODEL DOT modelvar ASSIGNMENT modelexpression'
var = 'this.%s.%s' % (p[1], p[3])
- vartype = MODEL_MAP.get(p[5][1], 'ScilabDouble')
- if vartype != '':
- p[0] = '%*s%s = new %s([%s])' % (INDENT_LEVEL * INDENT_SIZE, ' ', var, vartype, p[5][0])
+ value = p[5][0]
+ vartype = p[5][1]
+ add_var_vartype(var, vartype)
+ if vartype == MATRIX_TYPE:
+ vartype = DOUBLE_TYPE
+ vartype = MODEL_MAP.get(vartype, 'ScilabDouble')
+ if vartype != '':
+ if value[0] == '[':
+ value = value[1:-1]
+ p[0] = '%*s%s = new %s(%s)' % (INDENT_LEVEL * INDENT_SIZE, ' ', var, vartype, value)
+ else:
+ p[0] = '%*s%s = %s' % (INDENT_LEVEL * INDENT_SIZE, ' ', var, value)
else:
- p[0] = '%*s%s = %s' % (INDENT_LEVEL * INDENT_SIZE, ' ', var, p[5][0])
- add_var_vartype(var, p[5][1])
+ vartype = MODEL_MAP.get(vartype, 'ScilabDouble')
+ if vartype != '':
+ p[0] = '%*s%s = new %s([%s])' % (INDENT_LEVEL * INDENT_SIZE, ' ', var, vartype, value)
+ else:
+ p[0] = '%*s%s = %s' % (INDENT_LEVEL * INDENT_SIZE, ' ', var, value)
def p_modelexpression_list_modelexpressionlist(p):
'modelexpression : LIST OPENBRACKET modelexpressionlist CLOSEBRACKET'