[Mumps2Py:] [172] Parsing fixes; based on Thilo's patch.

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


Revision: 172
Author:   pgallot
Date:     2008-03-12 21:29:10 +0000 (Wed, 12 Mar 2008)

Log Message:
-----------
Parsing fixes; based on Thilo's patch.

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


Modified: trunk/mumps2py/mumps2tok.py
===================================================================
--- trunk/mumps2py/mumps2tok.py	2008-03-12 16:44:24 UTC (rev 171)
+++ trunk/mumps2py/mumps2tok.py	2008-03-12 21:29:10 UTC (rev 172)
@@ -91,6 +91,7 @@
 
 def parse_entry_ref(line, pos):
     """ parses a Mumps Entry Ref"""
+    startpos = pos
     token = Token(ENTRYREF, pos)
     token.end = None
     if line[pos] == '@':
@@ -137,7 +138,10 @@
             token.end = pos
         if not MUMPS_RE_DICT["cmdEnd"].match(line, pos) and line[pos] == '(':
             pos, token.params = consume_actuallist(line, pos + 1)
-    
+
+    if pos == startpos:
+        raise ParseError(line, "unknown form of entryref", pos )                
+
     if not token.end:
         token.end = pos
     return (token, pos)
@@ -477,7 +481,7 @@
             else:
                 sub_token = parse_expr(line, pos, r"([;, ]|\s*$)")
                 pos = sub_token.end
-            if line[pos] == ',':
+            if not mterminated.match(line, pos) and line[pos] == ',':
                 pos += 1
             write_list.append(sub_token)
 
@@ -759,7 +763,7 @@
             exprtok = parse_expr(line, pos, r"([ ,]|\s*$)")
             expr_list.append(exprtok)
             pos = exprtok.end
-            if line[pos] == ",":
+            if not mterminated.match(line, pos) and line[pos] == ",":
                 pos += 1
         parent_tok.condition_list = expr_list
         parent_tok.end = pos + 1
@@ -823,7 +827,7 @@
         entry_ref_list = []
         mterminated = MUMPS_RE_DICT["cmdEnd"]
         while not mterminated.match(line, pos):
-            (entry_ref, pos) = parse_entry_ref(line, pos)
+            (entry_ref, new_pos) = parse_entry_ref(line, pos)
             if not mterminated.match(line, pos) and line[pos] == '(':
                 pos += 1
                 params = []


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