self.right = right
class Absyn:
- def __init__(self):
- self.outputfile = open("output.py","w")
+ def __init__(self,outputfn):
+ self.outputfile = open(outputfn,"w")
self.outputfile.write(preamble)
self.assign = []
self.ports = []
print(str(clsdecl))
return clsdecl
+ def appendComments(self,data):
+ lines = data.split("\n")
+ for line in lines:
+ self.printpy("#"+line)
+
# combinatorical assign
def cont_assign_1(self,p):
- print("#ASSIGN:BROKEN"+str(list(p)))
+ # print("#ASSIGN:BROKEN"+str(list(p)))
self.assign += [Assignment(p[1],p[2],p[3])]
import absyn
from ply import *
+import os
if __name__ == '__main__':
fname = sys.argv[1]
+ outputfn = os.path.splitext(fname)[0]+'.py'
+ print(outputfn)
with open(fname) as f:
data = f.read()
- parse_sv.absyn = absyn.Absyn()
+ parse_sv.absyn = absyn.Absyn(outputfn)
yacc.parse(data, debug=parse_sv.yacc2_debug)
print("No Error")
+ parse_sv.absyn.appendComments(data)