[Mumps2Py:] [84] analyzing tokens per routine now frees the tokens after parsing each routine .

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


Revision: 84
Author:   pgallot
Date:     2008-02-04 23:35:50 +0000 (Mon, 04 Feb 2008)

Log Message:
-----------
analyzing tokens per routine now frees the tokens after parsing each routine.  Makes analyzing large files possible. Otherwise, some misc. tweaks.

Modified Paths:
--------------
    trunk/mumps2py_ui.pyw


Modified: trunk/mumps2py_ui.pyw
===================================================================
--- trunk/mumps2py_ui.pyw	2008-02-04 23:33:14 UTC (rev 83)
+++ trunk/mumps2py_ui.pyw	2008-02-04 23:35:50 UTC (rev 84)
@@ -19,7 +19,7 @@
 
 import os, re, fileinput
 from mumps2py.mumps_module import parse_for_routines
-from mumps2py.mumps2tok import parseMumps
+from mumps2py.mumps2tok import parseMumps, ParseError
 from mumps2py.tok2python import translate
 from mumps2py.mumps2py_config import create_m2p_file
 import mumps2py_test
@@ -181,10 +181,13 @@
                     self.display_before(the_module.input_file, \
                                        the_module.start, \
                                        the_module.end)
-                    parseMumps(the_module)
+                    try:
+                        parseMumps(the_module)
+                        translation = translate(the_module)
+                        self.display_after(the_module, translation)
+                    except ParseError, err:
+                        print err.error_msg()
                     self.display_decomposed(the_module)
-                    translation = translate(the_module)
-                    self.display_after(the_module, translation)
                     return
 
     def parseuntilmodule(self, popup):
@@ -231,18 +234,20 @@
 
     def parse_analyze_tokens(self):
         """count the frequency of the different token types, sort and display"""
-        import gc 
+        #import gc 
         toks = {}
         if self.modules:
+            input_file = fileinput.input(self.modules[0].input_file)
             for the_module in self.modules:
                 print the_module.mod_name
                 if the_module.tokenlist_isempty():
-                    parseMumps(the_module)
+                    parseMumps(the_module, input_file)
                 for token in the_module.TokenList:
                     token.count_subtokens(toks)
                 the_module.empty_tokenlist() # keep memory usage down
-                gc.collect()
+                #gc.collect()
 
+            fileinput.close()
             analysis = [(v, k) for k, v in toks.items()]
             analysis.sort(reverse = True)
 
@@ -261,10 +266,10 @@
         """ open a file of Mumps code"""
         mumps_file = tkFileDialog.askopenfilename(\
             parent = self.root,
-            filetypes = [ ("MUMPS files", "*.mps"), ("RSA files","*.rsa"),
-                          ("RTN files","*.rtn"), ("m2p files","*.m2p")], 
-            initialdir = "./testfiles",
-            initialfile = "VistA.m2p")
+            filetypes = [ ("m2p files","*.m2p"), ("MUMPS files", "*.mps"),
+                          ("RSA files","*.rsa"), ("RTN files","*.rtn")], 
+            initialdir = "./testfiles")
+            #initialfile = "VistA.m2p")
         m2py_dir = "./out"
 
         if not mumps_file:


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