diff options
author | ptmcg <ptmcg@austin.rr.com> | 2021-08-07 16:29:26 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2021-08-07 16:29:26 -0500 |
commit | d3bceb997395ee13dcb00fd39098de025d8ba180 (patch) | |
tree | a3b7b61e3fd7a041c258d04834388072378194de /examples/verilogParse.py | |
parent | 9c53c41b009f480812f9263df7e5c1e6b4fc5be6 (diff) | |
download | pyparsing-git-d3bceb997395ee13dcb00fd39098de025d8ba180.tar.gz |
Minor code cleanups
Diffstat (limited to 'examples/verilogParse.py')
-rw-r--r-- | examples/verilogParse.py | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/examples/verilogParse.py b/examples/verilogParse.py index cba0ac0..ec2f694 100644 --- a/examples/verilogParse.py +++ b/examples/verilogParse.py @@ -899,19 +899,7 @@ def test(strng): return tokens -# ~ if __name__ == "__main__": -if 0: - import pprint - - toptest = """ - module TOP( in, out ); - input [7:0] in; - output [5:0] out; - COUNT_BITS8 count_bits( .IN( in ), .C( out ) ); - endmodule""" - pprint.pprint(test(toptest).asList()) - -else: +if __name__ == "__main__": def main(): import sys @@ -931,8 +919,7 @@ else: Verilog_BNF() numlines = 0 startTime = time.time() - fileDir = "../scratch/verilog" - # ~ fileDir = "verilog/new" + fileDir = "verilog" # ~ fileDir = "verilog/new2" # ~ fileDir = "verilog/new3" allFiles = [f for f in os.listdir(fileDir) if f.endswith(".v")] @@ -960,18 +947,13 @@ else: totalTime += elapsed if len(tokens): print("OK", elapsed) - # ~ print "tokens=" - # ~ pp.pprint( tokens.asList() ) - # ~ print ofnam = fileDir + "/parseOutput/" + vfile + ".parsed.txt" - outfile = open(ofnam, "w") - outfile.write(teststr) - outfile.write("\n") - outfile.write("\n") - outfile.write(pp.pformat(tokens.asList())) - outfile.write("\n") - outfile.close() + with open(ofnam, "w") as outfile: + outfile.write(teststr) + outfile.write("\n\n") + outfile.write(pp.pformat(tokens.asList())) + outfile.write("\n") else: print("failed", elapsed) failCount += 1 @@ -988,16 +970,4 @@ else: return 0 - # ~ from line_profiler import LineProfiler - # ~ from pyparsing import ParseResults - # ~ lp = LineProfiler(ParseResults.__init__) - main() - - # ~ lp.print_stats() - # ~ import hotshot - # ~ p = hotshot.Profile("vparse.prof",1,1) - # ~ p.start() - # ~ main() - # ~ p.stop() - # ~ p.close() |