[Mumps2Py:] [37] collapse an expression which consists of a sign(+|-) on a number.

[ Thread Index | Date Index | More lists.mumps2py.org/discuss Archives ]


Revision: 37
Author:   pgallot
Date:     2008-01-21 19:48:09 +0000 (Mon, 21 Jan 2008)

Log Message:
-----------
collapse an expression which consists of a sign(+|-) on a number.

Modified Paths:
--------------
    trunk/mumps2py/mumps2tok.py


Modified: trunk/mumps2py/mumps2tok.py
===================================================================
--- trunk/mumps2py/mumps2tok.py	2008-01-21 19:36:05 UTC (rev 36)
+++ trunk/mumps2py/mumps2tok.py	2008-01-21 19:48:09 UTC (rev 37)
@@ -368,7 +368,13 @@
         if not pattern_match:
             raise ParseError(mumps_module, line, "No Pattern match", pos )
 
-    if len(token.expr_list)==1:
+    if len(token.expr_list)==2:
+        (left_tok, right_tok) = token.expr_list
+        if right_tok.is_num() and left_tok.toktype in (OPADD, OPSUB):
+            if left_tok.toktype == OPSUB:
+                right_tok.val = "-" + right_tok.val
+            token = right_tok
+    elif len(token.expr_list)==1:
         token = token.expr_list[0]
     else:
         token.end = pos


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/