def main(argv): try: testfiles = [argv[1]] except: testfiles = [os.path.join("source", x) for x in os.listdir("source") if x[-3:] == ".js"] for testfile in testfiles: try: sexp.convert(js.parse(file(testfile, 'r').read())) except Exception, e: print "Failure in converting %s to s-expressions\n%s" % (testfile, e) return 1 sys.stdout.write(".") sys.stdout.flush()
def main(argv): try: testfiles = [argv[1]] except: testfiles = [ os.path.join("source", x) for x in os.listdir("source") if x[-3:] == ".js" ] for testfile in testfiles: try: sexp.convert(js.parse(file(testfile, 'r').read())) except Exception, e: print "Failure in converting %s to s-expressions\n%s" % (testfile, e) return 1 sys.stdout.write(".") sys.stdout.flush()
def main(): with open(jsfile) as js: sys.stdout.write("File: {}\n".format(jsfile)) try: tree = flatten(sparse(sexp.convert(jsparser.parse(js.read())))) x = copy([i for i in clean(tree) if i in ops]) y = str(x) z = {i: y.count(i) for i in sorted(set(x))} data = [z[i] for i in sorted(z)] sys.stdout.write("Success:{}\n".format(z)) except jsparser.SyntaxError_: sys.stderr.write( "Failure {}: SyntaxError_ thrown by jsparser \n".format( jsfile)) sys.exit(1) sys.exit(0)
def main(): with open(jsfile) as js: sys.stdout.write("File: {}\n".format(jsfile)) try: tree = flatten( sparse( sexp.convert( jsparser.parse( js.read())))) x = copy([i for i in clean(tree) if i in ops]) y = str(x) z = {i:y.count(i) for i in sorted(set(x))} data = [z[i] for i in sorted(z)] sys.stdout.write("Success:{}\n".format(z)) except jsparser.SyntaxError_: sys.stderr.write("Failure {}: SyntaxError_ thrown by jsparser \n".format(jsfile)) sys.exit(1) sys.exit(0)