summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Shetye2018-06-19 15:53:17 +0530
committerSunil Shetye2018-06-19 15:53:17 +0530
commite52c0df736cfe020cb54e265b93119107497fbf5 (patch)
tree1a5267eb0d85e040ea4e168d00a50739de8b01f2
parent044f5fad7f84b7d4def0b0abb278c1303102e03d (diff)
downloadsci2js-e52c0df736cfe020cb54e265b93119107497fbf5.tar.gz
sci2js-e52c0df736cfe020cb54e265b93119107497fbf5.tar.bz2
sci2js-e52c0df736cfe020cb54e265b93119107497fbf5.zip
support variable(index)(index)(slice)
-rw-r--r--js/Misc/DSUPER.js2
-rwxr-xr-xsci2jsyacc.py18
2 files changed, 17 insertions, 3 deletions
diff --git a/js/Misc/DSUPER.js b/js/Misc/DSUPER.js
index b54edea1..c6f36f7c 100644
--- a/js/Misc/DSUPER.js
+++ b/js/Misc/DSUPER.js
@@ -1,3 +1,3 @@
-Syntax error in input LexToken(COLON,':',1,1446)
+Syntax error in input LexToken(PREVAR,'%scicos_context',1,1636)
/* autogenerated from "macros/Misc/DSUPER.sci" */
None
diff --git a/sci2jsyacc.py b/sci2jsyacc.py
index ac1ef9ed..420af69a 100755
--- a/sci2jsyacc.py
+++ b/sci2jsyacc.py
@@ -547,7 +547,7 @@ def p_term_parameter(p):
p[0] = '%s(%s)' % (p[1], p[3])
# B($-2)('function parameter')
-def p_term_termfunc_parameter(p):
+def p_term_termfunc_parameter_parameter(p):
'term : termvar OPENBRACKET expression CLOSEOPENBRACKET expression CLOSEBRACKET'
if isarray(p[1]):
base = '%s[%s-1]' % (p[1], p[3])
@@ -559,7 +559,7 @@ def p_term_termfunc_parameter(p):
p[0] = '%s(%s)' % (base, p[5])
# B($-2)('function parameter')(3)
-def p_term_termfunc_parameter_parameter(p):
+def p_term_termfunc_parameter_parameter_parameter(p):
'term : termvar OPENBRACKET expression CLOSEOPENBRACKET expression CLOSEOPENBRACKET expression CLOSEBRACKET'
if isarray(p[1]):
base = '%s[%s-1]' % (p[1], p[3])
@@ -574,6 +574,20 @@ def p_term_termfunc_parameter_parameter(p):
else:
p[0] = '%s(%s)' % (base, p[7])
+# B($-2)('function parameter')(3:4)
+def p_term_termfunc_parameter_parameter_slice(p):
+ 'term : termvar OPENBRACKET expression CLOSEOPENBRACKET expression CLOSEOPENBRACKET expression COLON expression CLOSEBRACKET'
+ if isarray(p[1]):
+ base = '%s[%s-1]' % (p[1], p[3])
+ else:
+ base = '%s(%s)' % (p[1], p[3])
+ if isarray(base):
+ base = '%s[%s-1]' % (base, p[5])
+ else:
+ base = '%s(%s)' % (base, p[5])
+ addtoarray(base)
+ p[0] = '%s.slice(%s-1,%s)' % (base, p[7], p[9])
+
# part(x,1:10)
def p_term_part_parameter_range(p):
'term : PART OPENBRACKET expression COMMA expression COLON expression CLOSEBRACKET'