diff options
author | Sunil Shetye | 2018-06-19 16:37:08 +0530 |
---|---|---|
committer | Sunil Shetye | 2018-06-19 16:37:08 +0530 |
commit | 449b9f0efaa3dc754efa17285f3e560989366144 (patch) | |
tree | e45b9d42d0ac96a78bd7382faeeec54c1ab572cb /sci2jsyacc.py | |
parent | 09dcb67c99c52386ec43581871db5a7a78eeaccd (diff) | |
download | sci2js-449b9f0efaa3dc754efa17285f3e560989366144.tar.gz sci2js-449b9f0efaa3dc754efa17285f3e560989366144.tar.bz2 sci2js-449b9f0efaa3dc754efa17285f3e560989366144.zip |
support variable(index)(index) on LHS
Diffstat (limited to 'sci2jsyacc.py')
-rwxr-xr-x | sci2jsyacc.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sci2jsyacc.py b/sci2jsyacc.py index a3b3f5d8..42e01654 100755 --- a/sci2jsyacc.py +++ b/sci2jsyacc.py @@ -442,17 +442,25 @@ def p_function_function(p): # define lterm # B(2:$-1) -def p_lterm_slice(p): +def p_lterm_ltermfunc_slice(p): 'lterm : ltermvar OPENBRACKET expression COLON expression CLOSEBRACKET' addtoarray(p[1]) p[0] = '%s.slice(%s-1,%s)' % (p[1], p[3], p[5]) # B(2) -def p_lterm_index(p): +def p_lterm_ltermfunc_index(p): 'lterm : ltermvar OPENBRACKET expression CLOSEBRACKET' addtoarray(p[1]) p[0] = '%s[%s-1]' % (p[1], p[3]) +# B($-2)(3) +def p_lterm_ltermfunc_index_index(p): + 'lterm : ltermvar OPENBRACKET expression CLOSEOPENBRACKET expression CLOSEBRACKET' + addtoarray(p[1]) + base = '%s[%s-1]' % (p[1], p[3]) + addtoarray(base) + p[0] = '%s[%s-1]' % (base, p[5]) + # [A,B,C] def p_lterm_ltermarraylist(p): 'lterm : OPENSQBRACKET ltermarraylist CLOSESQBRACKET' @@ -539,7 +547,7 @@ def p_term_range(p): # B($-2) # C('function parameter') -def p_term_parameter(p): +def p_term_termfunc_parameter(p): 'term : termvar OPENBRACKET expression CLOSEBRACKET' if isarray(p[1]): p[0] = '%s[%s-1]' % (p[1], p[3]) |