[Mumps2Py:] [46] variables are now using sub-classed Tokens, and fixed a logic error in parse_expr.

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


Revision: 46
Author:   pgallot
Date:     2008-01-23 21:17:54 +0000 (Wed, 23 Jan 2008)

Log Message:
-----------
variables are now using sub-classed Tokens, and fixed a logic error in parse_expr.

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


Modified: trunk/mumps2py/mumps2tok.py
===================================================================
--- trunk/mumps2py/mumps2tok.py	2008-01-23 21:15:57 UTC (rev 45)
+++ trunk/mumps2py/mumps2tok.py	2008-01-23 21:17:54 UTC (rev 46)
@@ -271,9 +271,9 @@
     def consume_var(mobj):
         """ parses a Mumps variable"""
         if mobj.group("globalvar"):
-            token = Token(GLOBALVAR, mobj.start())
+            token = VarToken(GLOBALVAR, mobj.start())
         else:
-            token = Token(LOCALVAR, mobj.start())
+            token = VarToken(LOCALVAR, mobj.start())
         if mobj.group("pbr"):
             token.pass_by_reference = True 
         token.varname = mobj.group("var")
@@ -368,6 +368,7 @@
         if not pattern_match:
             raise ParseError(mumps_module, line, "No Pattern match", pos )
 
+    token.end = pos
     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):
@@ -376,8 +377,6 @@
             token = right_tok
     elif len(token.expr_list)==1:
         token = token.expr_list[0]
-    else:
-        token.end = pos
     return token
 
 def parse_command(mumps_module, line, startpos=0):
@@ -934,7 +933,7 @@
             if mumps_module.end != -1 and fileinput.lineno() > mumps_module.end:
                 break
 
-            #print "%d :%s" % (fileinput.lineno(),line),
+            #print "%d :%s" % (fileinput.lineno(), line),
             pattern_match = False
             pos = 0
             for (pattern, parser, dscr) in pattern_list:


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