[Mumps2Py:] [183] numeric-literal parsing fix to handle a decimal point not followed by number (e.g. |
[ Thread Index |
Date Index
| More lists.mumps2py.org/discuss Archives
]
Revision: 183
Author: pgallot
Date: 2008-03-20 23:46:49 +0100 (Thu, 20 Mar 2008)
Log Message:
-----------
numeric-literal parsing fix to handle a decimal point not followed by number (e.g. 1.)
Modified Paths:
--------------
trunk/mumps2py/mumps2tok.py
Modified: trunk/mumps2py/mumps2tok.py
===================================================================
--- trunk/mumps2py/mumps2tok.py 2008-03-19 22:25:38 UTC (rev 182)
+++ trunk/mumps2py/mumps2tok.py 2008-03-20 22:46:49 UTC (rev 183)
@@ -27,11 +27,14 @@
self.lineno = lineno
self.pos = pos
self.dscr = dscr
- print self.error_msg()
def line_no(self, lineno):
"""set the linenumber on which exception occured."""
self.lineno = lineno
+
+ def routine(self, name):
+ """ adds the routine name to the description."""
+ self.dscr = "%s: %s" % (name, self.dscr)
def error_msg(self):
""" returns a formated string containing information about the error"""
@@ -49,7 +52,7 @@
"indirection":re.compile(r"@"),
"op":re.compile(r"[-_/+']|([']?(([*]{1,2})|([]]{1,2})|\\|[[=><#&!/]))"),
"str":re.compile(r'"'),
- "num":re.compile(r"([0-9]*[.])?[0-9]+([eE][+-][0-9]+)?"),
+ "num":re.compile(r"([.]?\d+([.]\d*)?){1}([eE][+-]\d+)?"),
"extr":re.compile(r"[$]{2}"),
"external":re.compile(r"[$][&](?P<pkg>[%a-zA-Z0-9][A-Za-z0-9]*[.]{1})?"),
"extglobal":re.compile(r"\^[|[]"),
@@ -1063,6 +1066,7 @@
break
except ParseError, err:
err.line_no(lineno)
+ err.routine(routine.mod_name)
raise err
if not pattern_match:
@@ -1080,7 +1084,7 @@
try:
mods = parse_for_routines("../testfiles/fm22.m2p", "./out")
- #mods = parse_for_routines("../testfiles/famo_errors.mrt", "./out")
+ #mods = parse_for_routines("../testfiles/problem_lines.mps", "./out")
#parsemodule(mods,"KMPSGE")
for the_module in mods:
print the_module.mod_name