- #Remove # comments (from input and output file
- removeComments = re.compile("#.*$",flags=re.MULTILINE)
- self.text = removeComments.sub("",self.text)
- #Remove // comments
- removeLineComment = re.compile("\/\/.*$",flags=re.MULTILINE)
- nolinecomment = removeLineComment.sub("",self.text)
- #Remove all spaces and lines
- cleantext = re.sub("\s*","",nolinecomment)
- #Remove multine C style comments
- nocomment = re.sub("/\*.*?\*/","",cleantext)
- entries = re.split("TRACEPOINT_.*?",nocomment)
+ # Remove # comments (from input and output file) but keep
+ # #include in the output file
+ removeComments = re.compile("#[^include].*$", flags=re.MULTILINE)
+ self.text = removeComments.sub("", self.text)
+ # Remove #include directive from the parsed text
+ removePreprocess = re.compile("#.*$", flags=re.MULTILINE)
+ noPreprocess = removePreprocess.sub("", self.text)
+ # Remove // comments
+ removeLineComment = re.compile("\/\/.*$", flags=re.MULTILINE)
+ nolinecomment = removeLineComment.sub("", noPreprocess)
+ # Remove all spaces and lines
+ cleantext = re.sub("\s*", "", nolinecomment)
+ # Remove multine C style comments
+ nocomment = re.sub("/\*.*?\*/", "", cleantext)
+ entries = re.split("TRACEPOINT_.*?", nocomment)