From d3bceb997395ee13dcb00fd39098de025d8ba180 Mon Sep 17 00:00:00 2001 From: ptmcg Date: Sat, 7 Aug 2021 16:29:26 -0500 Subject: Minor code cleanups --- examples/verilogParse.py | 44 +++++++------------------------------------- 1 file changed, 7 insertions(+), 37 deletions(-) (limited to 'examples/verilogParse.py') 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() -- cgit v1.2.1