[Mumps2Py:] [103] operator-parsing clean-up.

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


Revision: 103
Author:   pgallot
Date:     2008-02-13 20:59:28 +0000 (Wed, 13 Feb 2008)

Log Message:
-----------
operator-parsing clean-up.

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


Modified: trunk/mumps2py/mumps2tok.py
===================================================================
--- trunk/mumps2py/mumps2tok.py	2008-02-13 20:36:17 UTC (rev 102)
+++ trunk/mumps2py/mumps2tok.py	2008-02-13 20:59:28 UTC (rev 103)
@@ -98,13 +98,11 @@
             token.indirect = indirect
             pos = indirect.end
         if not MUMPS_RE_DICT["cmdEnd"].match(line, pos) and line[pos] == '+':
-            pos = pos + 1
-            offset = parse_expr(routine, line, pos, r"(\^|[ ),:]|\s*$)")
+            offset = parse_expr(routine, line, pos + 1, r"(\^|[ ),:]|\s*$)")
             token.offset = offset
             pos = offset.end
         if not MUMPS_RE_DICT["cmdEnd"].match(line, pos) and line[pos] == '^':
-            pos = pos + 1
-            routine = parse_expr(routine, line, pos, r"([ ,)(:]|\s*$)")
+            routine = parse_expr(routine, line, pos + 1, r"([ ,)(:]|\s*$)")
             token.routine = routine
             pos = routine.end
     else:
@@ -114,8 +112,7 @@
             token.label = m_name.group()
             pos = m_name.end()
         if not MUMPS_RE_DICT["cmdEnd"].match(line, pos) and line[pos] == '+':
-            pos = pos + 1
-            offset = parse_expr(routine, line, pos, r"(\^|[ ):,]|\s*$)")
+            offset = parse_expr(routine, line, pos + 1, r"(\^|[ ):,]|\s*$)")
             token.offset = offset
             pos = offset.end
         if not MUMPS_RE_DICT["cmdEnd"].match(line, pos) and line[pos] == '^':
@@ -176,29 +173,29 @@
     #if __debug__: print "parse_expr %d [%s]" % (startpos, line[startpos:])
     
     def consume_pattern(lineno, line, pos):
-        """ parses a mumps-style pattern-matchine pattern"""
+        """ parses a mumps-style pattern-matching pattern"""
         atom_list = []
         m_pat = MUMPS_RE_DICT["patAtom"]
         atom = m_pat.match(line, pos)
         while atom:
-            sub_token = Token(OPPATATOM, atom.start())
+            sub_token = AtomToken(atom.start())
             if atom.group("rpcount"):
                 sub_token.repcount = int(atom.group("rpcount"))
             else:
                 if atom.group("mnrp"):
-                    sub_token.minrep = int(atom.group("mnrp"))
+                    sub_token.minrep = atom.group("mnrp")
                 if atom.group("mxrp"):
-                    sub_token.maxrep = int(atom.group("mxrp"))
+                    sub_token.maxrep = atom.group("mxrp")
             if atom.group("str"):
                 sub_token.match_str = parse_expr(\
                     routine, line, atom.start("str"), r'\w|[ .,:)(]|\s*$')
                 pos = sub_token.match_str.end
             elif atom.group("altlist"):
-                sub_token.alt_list = []
+                sub_token.params = []
                 pos = atom.end()
                 while line[pos] != ")":
                     (sub_pat, pos) = consume_pattern(lineno, line, pos)
-                    sub_token.alt_list.append(sub_pat)
+                    sub_token.params.append(sub_pat)
                     if line[pos] == ",":
                         pos = pos + 1
                 pos = pos + 1
@@ -242,7 +239,7 @@
     def consume_op(mobj):
         """ parses a Mumps operator"""
         op_type = line[mobj.start():mobj.end()]
-        token = Token(OP_TOKEN_DICT[op_type], mobj.start())
+        token = OpToken(OP_TOKEN_DICT[op_type], mobj.start())
         return (token, mobj.end())
 
     def consume_naked_ref(mobj):
@@ -323,8 +320,8 @@
     def consume_pattmatch(mobj):
         """ parses mumps-style pattern-matchine patterns"""
         pos = mobj.end()
-        token = Token(OPPATMATCH, mobj.start())
-        (token.atom_list, pos) = consume_pattern(routine, line, pos)
+        token = OpToken(OPPATMATCH, mobj.start())
+        (token.params, pos) = consume_pattern(routine, line, pos)
         token.end = pos
         return (token, pos)
 


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