gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r25912 - monkey/trunk/seaspider


From: gnunet
Subject: [GNUnet-SVN] r25912 - monkey/trunk/seaspider
Date: Fri, 25 Jan 2013 17:11:38 +0100

Author: teichm
Date: 2013-01-25 17:11:38 +0100 (Fri, 25 Jan 2013)
New Revision: 25912

Modified:
   monkey/trunk/seaspider/seasp2_convert
Log:
ignore patterns in seasp2_convert part1

Modified: monkey/trunk/seaspider/seasp2_convert
===================================================================
--- monkey/trunk/seaspider/seasp2_convert       2013-01-25 16:09:42 UTC (rev 
25911)
+++ monkey/trunk/seaspider/seasp2_convert       2013-01-25 16:11:38 UTC (rev 
25912)
@@ -12,6 +12,7 @@
         return []
 
     ignlist = []
+    ignexp = []
     lineno = 0
 
     lines = ignfile.readlines(100)
@@ -29,6 +30,10 @@
             ign_func = m.group(2)
             ign_pattern = m.group(3)
             ignlist.append((ign_file, ign_func, ign_pattern))
+            ignexp.append((re.compile(m.group(1)),
+                           re.compile(m.group(2)),
+                           re.compile(m.group(3))))
+
         lines = ignfile.readlines(100)
     ignfile.close()
     return ignlist
@@ -103,6 +108,19 @@
                 UNIQUE (file_name, expr_syntax, start_lineno, end_lineno))''')
 
 
+# adds an Expression to the db
+def add_expr(cur, ignores, func_name,
+             file_name, expr_syntax, start_lineno, end_lineno, is_call):
+    for i in ignores:
+        if (func_name and
+            i[0] in file_name and
+            i[1] in func_name and
+            i[2] in expr_syntax):
+            return
+    vals = (file_name, expr_syntax, start_lineno, end_lineno, is_call)
+    cur.execute('INSERT OR IGNORE INTO Expression VALUES (NULL,?,?,?,?,?)', 
vals)
+
+
 # parses one .sea file
 def parse_sea_file(filename):
     scope_end = []
@@ -111,6 +129,7 @@
     expr_list = []
     prevtype = ""
     seafile_lineno = 0
+    func_name = (32767, None)
 
     try:
         infile = open(filename, 'r')
@@ -121,19 +140,22 @@
         return
     cfilename = os.path.split(os.path.splitext(filename)[0])[1] + '.c'
 
+    local_ignores = [ign for ign in ignores if ign[0] in cfilename]
+    print local_ignores
+
     lines = infile.readlines(10000)
     while lines:
         for line in lines:
             seafile_lineno += 1
             if prevtype == 'Begin-Expression':
                 if re.match(re.escape("End-Expression: " + rowfile + ':' + 
str(lineno) + ' ' + str(iscall)), line):
-                    vals = (rowfile, ' '.join(expr_list), lineno, 
scope_end[-1], iscall)
-                    sql_cur.execute('INSERT OR IGNORE INTO Expression VALUES 
(NULL,?,?,?,?,?)', vals)
+                    add_expr(sql_cur, local_ignores, func_name[1],
+                             rowfile, ' '.join(expr_list), lineno, 
scope_end[-1], iscall)
                     prevtype = 'End-Expression'
                 expr_list.append(line.strip())
                 continue
 
-            m = re.match(r"([A-Za-z-]+): ([^:]+):(\d+) (.+)", line)
+            m = re.match(r'([A-Za-z-]+): ([^:]+):(\d+) (.+)', line)
             if not m or m.lastindex < 4:
                 print 'unknown entry type: ', filename, ' on line ', 
seafile_lineno
                 prevtype = ''
@@ -151,8 +173,8 @@
                 vals = (rowfile, globalvar, lineno, 32767, 0)
                 sql_cur.execute('INSERT OR IGNORE INTO Expression VALUES 
(NULL,?,?,?,?,?)', vals)
             elif rowtype == 'Function':
-                pass
-#                print 'nothing to do yet for entry type Function'
+                funame = m.group(4)
+                print 'entering Function ', funame
             elif rowtype == 'Parameter':
                 if prevtype != 'Function' and prevtype != 'Parameter':
                     print 'Parameter can only follow Function or another 
Parameter: ', filename, ' on line ', seafile_lineno
@@ -162,6 +184,8 @@
             elif rowtype == 'Scope':
                 scope_begin = int(m.group(3))
                 scope_end.append(int(m.group(4)) + 1)
+                if prevtype == 'Parameter' or prevtype == 'Function':
+                    func_name = (scope_end[-1], funame)
                 while prevtype == 'Parameter':
                     try:
                         (rowfile, para, lineno) = parameters.popleft()
@@ -174,6 +198,8 @@
                 iscall = int(m.group(4)[0])
                 if lineno > scope_end[-1]:
                     scope_end.pop()
+                    if lineno > func_name[0]:
+                        func_name = (32767, None)
                 del expr_list[:]
                 tmp = (m.group(4)[1:]).strip()
                 if len(tmp) > 0: expr_list.append(tmp)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]