gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r24299 - monkey/trunk/seaspider
Date: Sun, 14 Oct 2012 03:43:31 +0200

Author: teichm
Date: 2012-10-14 03:43:30 +0200 (Sun, 14 Oct 2012)
New Revision: 24299

Added:
   monkey/trunk/seaspider/seasp2
   monkey/trunk/seaspider/seasp2_convert
Removed:
   monkey/trunk/seaspider/db_convert
Modified:
   monkey/trunk/seaspider/Makefile
Log:
-added seasp2 script to run cparser.
-seasp2_convert now supports function parameters.


Modified: monkey/trunk/seaspider/Makefile
===================================================================
--- monkey/trunk/seaspider/Makefile     2012-10-12 16:14:54 UTC (rev 24298)
+++ monkey/trunk/seaspider/Makefile     2012-10-14 01:43:30 UTC (rev 24299)
@@ -3,3 +3,7 @@
        bin/javacc C.out.jj
        javac -nowarn -classpath 
contrib/antlr-runtime-3.1.3.jar:contrib/sqljet.1.0.3.b914.jar `find * -name 
"*.java"`
        jar -cvef org.gnunet.seaspider.Seaspider seaspider.jar `find * -name 
"*.class"` 
+
+install: seasp2_convert seasp2
+       install -t /usr/local/bin seasp2 seasp2_convert
+

Deleted: monkey/trunk/seaspider/db_convert
===================================================================
--- monkey/trunk/seaspider/db_convert   2012-10-12 16:14:54 UTC (rev 24298)
+++ monkey/trunk/seaspider/db_convert   2012-10-14 01:43:30 UTC (rev 24299)
@@ -1,76 +0,0 @@
-#! /usr/bin/env python
-
-import sqlite3
-import argparse
-import os
-
-parser = argparse.ArgumentParser(description="converts .sea files generated by 
cparser to a seaspider sqlite database")
-
-parser.add_argument('--version', action='version', version='db_convert 1.0')
-parser.add_argument("-o", "--output", metavar="FILENAME", 
type=argparse.FileType('w'), dest="outfile", help="filename for the resulting 
sqlite database. defaulting to infile.sqlite")
-parser.add_argument('infile', type=argparse.FileType('r'), help='input file')
-args = parser.parse_args()
-
-if args.outfile== None:
-       (outfilename, ext) = os.path.splitext(args.infile.name)
-       outfilename += '.sqlite'
-else:
-       outfilename = args.outfile.name
-       args.outfile.close()
-
-# remove old db
-try:
-       os.remove(outfilename)
-except OSError:
-       pass
-
-
-# connect to db
-conn = sqlite3.connect(outfilename)
-c = conn.cursor()
-
-# create table
-c.execute('''CREATE TABLE Expression (
-                       expr_ID INTEGER PRIMARY KEY AUTOINCREMENT,
-                       file_name TEXT NOT NULL,
-                       expr_syntax TEXT,
-                       start_lineno INT,
-                       end_lineno INT,
-                       is_call INT)''')
-
-# commit changes
-conn.commit()
-
-scope_end = []
-
-lines = args.infile.readlines(10000)
-while lines:
-       for line in lines:
-               (rowtype, remainder) = line.split(': ', 1)
-               if rowtype == 'Function':
-                       pass
-               elif rowtype == 'Parameter':
-                       pass
-               elif rowtype == 'Scope':
-                       (rowfile, scoperange) = remainder.split(':', 1)
-                       (scope_begin, scope_end_tmp) = scoperange.split(' ', 1)
-                       scope_begin = int(scope_begin)
-                       scope_end.append(int(scope_end_tmp) + 1)
-                       print 'entered new scope: ', scope_begin, '-', 
scope_end[-1]
-               elif rowtype == 'Expression':
-                       (rowfile, rowexpr) = remainder.split(':', 1)
-                       (lineno, iscall, expression) = rowexpr.split(' ', 2)
-                       lineno = int(lineno)
-                       iscall = int(iscall)
-                       if lineno > scope_end[-1]:
-                               scope_end.pop()
-                       vals = (rowfile, expression, lineno, scope_end[-1], 
iscall)
-                       c.execute('INSERT INTO Expression VALUES 
(NULL,?,?,?,?,?)', vals)
-               else:
-                       print 'unknown entry type: ' + rowtype
-       conn.commit()
-       lines = args.infile.readlines(10000)
-
-
-# close db
-conn.close()

Added: monkey/trunk/seaspider/seasp2
===================================================================
--- monkey/trunk/seaspider/seasp2                               (rev 0)
+++ monkey/trunk/seaspider/seasp2       2012-10-14 01:43:30 UTC (rev 24299)
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+echo "BEWARE! This is an unfinished and unstable script. use with care!"
+echo "Will start in 5..."
+sleep 1s
+echo "Will start in 4..."
+sleep 1s
+echo "Will start in 3..."
+sleep 1s
+echo "Will start in 2..."
+sleep 1s
+echo "Will start in 1..."
+sleep 1s
+
+export CC="/usr/local/bin/cparser"
+export CFLAGS="--seaspider -m32"
+./configure
+make $1
+cat `find * -name "*.sea"` > expressions.sea
+# probably call seasp2_convert here later
+


Property changes on: monkey/trunk/seaspider/seasp2
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Copied: monkey/trunk/seaspider/seasp2_convert (from rev 24298, 
monkey/trunk/seaspider/db_convert)
===================================================================
--- monkey/trunk/seaspider/seasp2_convert                               (rev 0)
+++ monkey/trunk/seaspider/seasp2_convert       2012-10-14 01:43:30 UTC (rev 
24299)
@@ -0,0 +1,93 @@
+#! /usr/bin/env python
+
+import sqlite3
+import argparse
+import os
+from collections import deque
+
+parser = argparse.ArgumentParser(description="converts .sea files generated by 
cparser to a seaspider sqlite database")
+
+parser.add_argument('--version', action='version', version='db_convert 1.0')
+parser.add_argument("-o", "--output", metavar="FILENAME", 
type=argparse.FileType('w'), dest="outfile", help="filename for the resulting 
sqlite database. defaulting to infile.sqlite")
+parser.add_argument('infile', type=argparse.FileType('r'), help='input file')
+args = parser.parse_args()
+
+if args.outfile== None:
+       (outfilename, ext) = os.path.splitext(args.infile.name)
+       outfilename += '.sqlite'
+else:
+       outfilename = args.outfile.name
+       args.outfile.close()
+
+# remove old db
+try:
+       os.remove(outfilename)
+except OSError:
+       pass
+
+
+# connect to db
+conn = sqlite3.connect(outfilename)
+c = conn.cursor()
+
+# create table
+c.execute('''CREATE TABLE Expression (
+                       expr_ID INTEGER PRIMARY KEY AUTOINCREMENT,
+                       file_name TEXT NOT NULL,
+                       expr_syntax TEXT,
+                       start_lineno INT,
+                       end_lineno INT,
+                       is_call INT)''')
+
+# commit changes
+conn.commit()
+
+scope_end = []
+parameters = deque()
+prevtype = ""
+
+lines = args.infile.readlines(10000)
+while lines:
+       for line in lines:
+               (rowtype, remainder) = line.split(': ', 1)
+               if rowtype == 'Global':
+                       print 'entry type Global not yet supported'
+               elif rowtype == 'Function':
+                       print 'nothing to do for entry type Function'
+               elif rowtype == 'Parameter':
+                       if prevtype == 'Function' or prevtype == 'Parameter':
+                               (rowfile, rowpar) = remainder.split(':', 1)
+                               (lineno, para) = rowpar.split(' ', 1)
+                               lineno = int(lineno)
+                               parameters.append((rowfile, para, lineno))
+               elif rowtype == 'Scope':
+                       (rowfile, scoperange) = remainder.split(':', 1)
+                       (scope_begin, scope_end_tmp) = scoperange.split(' ', 1)
+                       scope_begin = int(scope_begin)
+                       scope_end.append(int(scope_end_tmp) + 1)
+                       while prevtype == 'Parameter':
+                               try:
+                                       (rowfile, para, lineno) = 
parameters.popleft()
+                               except IndexError:
+                                       break
+                               vals = (rowfile, para, lineno, scope_end[-1], 0)
+                               c.execute('INSERT INTO Expression VALUES 
(NULL,?,?,?,?,?)', vals)
+                       print 'entered new scope: ', scope_begin, '-', 
scope_end[-1]
+               elif rowtype == 'Expression':
+                       (rowfile, rowexpr) = remainder.split(':', 1)
+                       (lineno, iscall, expression) = rowexpr.split(' ', 2)
+                       lineno = int(lineno)
+                       iscall = int(iscall)
+                       if lineno > scope_end[-1]:
+                               scope_end.pop()
+                       vals = (rowfile, expression, lineno, scope_end[-1], 
iscall)
+                       c.execute('INSERT INTO Expression VALUES 
(NULL,?,?,?,?,?)', vals)
+               else:
+                       print 'unknown entry type: ' + rowtype
+               prevtype = rowtype
+       conn.commit()
+       lines = args.infile.readlines(10000)
+
+
+# close db
+conn.close()




reply via email to

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