[Mumps2Py:] [114] added a bit of exception-handling code. |
[ Thread Index |
Date Index
| More lists.mumps2py.org/discuss Archives
]
Revision: 114
Author: pgallot
Date: 2008-02-15 21:19:40 +0000 (Fri, 15 Feb 2008)
Log Message:
-----------
added a bit of exception-handling code.
Modified Paths:
--------------
trunk/mumps2py_ui.pyw
Modified: trunk/mumps2py_ui.pyw
===================================================================
--- trunk/mumps2py_ui.pyw 2008-02-15 21:18:14 UTC (rev 113)
+++ trunk/mumps2py_ui.pyw 2008-02-15 21:19:40 UTC (rev 114)
@@ -146,7 +146,7 @@
self.before_window.insert(END, line)
fileinput.close()
- def __display_after(self, a_module, translation):
+ def __display_after(self, translation):
"""populate the after window with the translation of the Mumps module"""
self.after_window.delete(0.0, END)
for line in translation:
@@ -166,7 +166,10 @@
for a_module in self.modules:
if a_module.end < start_line:
continue
- mumps2py.parseMumps(a_module)
+ try:
+ mumps2py.parseMumps(a_module)
+ except mumps2py.ParseError, err:
+ self.message(err.error_msg())
def parsegivenmodule(self, popup):
"""parse the module specified by popup"""
@@ -180,23 +183,32 @@
try:
mumps2py.parseMumps(the_module)
translation = mumps2py.translate(the_module)
- self.__display_after(the_module, translation)
+ self.__display_after(translation)
except mumps2py.ParseError, err:
- print err.error_msg()
- self.__display_decomposed(the_module)
- return
+ self.message(err.error_msg())
+ except mumps2py.TranslationError, err:
+ self.message(err.error_msg())
def parse_all(self):
"""parse all the modules in a Mumps file"""
- if self.modules:
+ if self.modules and len(self.modules) > 1:
for the_module in self.modules:
+ try:
+ mumps2py.parseMumps(the_module)
+ except mumps2py.ParseError, err:
+ self.message(err.error_msg())
+ elif len(self.modules) == 1:
+ the_module = self.modules[0]
+ try:
mumps2py.parseMumps(the_module)
- if len(self.modules) == 1:
- the_module = self.modules[0]
- mumps2py.parseMumps(the_module)
- self.__display_decomposed(the_module)
+ except mumps2py.ParseError, err:
+ self.message(err.error_msg())
+ self.__display_decomposed(the_module)
+ try:
translation = mumps2py.translate(the_module)
- self.__display_after(the_module, translation)
+ self.__display_after(translation)
+ except mumps2py.TranslationError, err:
+ self.message(err.error_msg())
def parseuntilmodule(self, popup):
"""analyze the tokens up until the module specified by popup"""
@@ -229,6 +241,8 @@
for token in the_module.TokenList:
token.count_subtokens(toks)
the_module.empty_tokenlist() # keep memory usage down
+ except mumps2py.ParseError, err:
+ self.message(err.error_msg())
finally:
print time.time() - tstart, "seconds to parse %d routines" % \
modcnt
@@ -382,10 +396,10 @@
parse_btn.menu.add_command( label = "Parse From...", \
underline = 6, command = \
(lambda s = self: s.popup_query("from")))
- parse_btn.menu.add_command( label = "Parse until Module...", \
+ parse_btn.menu.add_command( label = "Parse until routine...", \
underline = 6, command = \
(lambda s = self: s.popup_query("until")))
- parse_btn.menu.add_command( label = "Parse Module...", \
+ parse_btn.menu.add_command( label = "Parse routine...", \
underline = 6, command = \
(lambda s = self: s.popup_query("module")))
parse_btn['menu'] = parse_btn.menu