X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=pypreproc.py;h=164f4304832f4d1da12fa370563d054c144e5f7c;hb=10c1bd0020878f84ededfa7c47d0ed4fd43f50bf;hp=4569506f5aa3f6c6f0dff719d5df70e0608dc177;hpb=41c57e96455f92dc8edf111f009a021792ee5946;p=sv2nmigen.git diff --git a/pypreproc.py b/pypreproc.py index 4569506..164f430 100644 --- a/pypreproc.py +++ b/pypreproc.py @@ -1,10 +1,13 @@ -quote = "\"" import sys +quote = "\"" + + class Preprocessor: def __init__(self): self.docstrings = [] - def removeComments(self,data): - #print(data) + + def removeComments(self, data): + # print(data) ret = "" in_docstring = False docstring = "" @@ -14,17 +17,18 @@ class Preprocessor: ret += "//DOCSTRING_PLACEHOLDER\n" in_docstring = True docstring = "" - if(in_docstring==False): + if(in_docstring == False): ret += line + "\n" else: - if(not docstring_end): docstring += line + "\n" - if(docstring_end): + if(not docstring_end): + docstring += line + "\n" + if(docstring_end): in_docstring = False self.docstrings += [docstring] - print(docstring) return ret - def insertDocstrings(self,data): - ret ="" + + def insertDocstrings(self, data): + ret = "" docstring_counter = 0 for line in data.split("\n"): if("//DOCSTRING_PLACEHOLDER" in line): @@ -36,4 +40,3 @@ class Preprocessor: else: ret += "#"+line + "\n" return ret -