def parseCpp(self, filePathName): with open(filePathName, 'r', encoding = 'utf8') as fHandle: tokenParseData = TokenParseData.TokenParseData('') try: tokenParseData.m_fileStr = fHandle.read(); # 读取所有的内容 except Exception as e: Utils.logStackInfo() Logger.instance().info("{0} 文件解析错误".format(filePathName)) return Utils.skipSpaceAndBr(tokenParseData) # 删除左边的空格 while len(tokenParseData.m_fileStr): oneToken = Utils.getToken(tokenParseData) if oneToken == "#ifndef": Utils.skipCurLine(tokenParseData) elif oneToken == "#define": Utils.skipCurLine(tokenParseData) elif oneToken == "#include": Utils.skipCurLine(tokenParseData) elif oneToken[0:3] == "/**": self.m_curCppElem = CppMultiComment.CppMultiComment() self.m_pStack.push(self.m_curCppElem) self.m_curCppElem.parseCppElem(tokenParseData) elif oneToken[0:2] == "//": Utils.skipCurLine(tokenParseData) elif oneToken == "struct": self.m_curCppElem = CppStructItem.CppStructItem() self.m_curCppElem.parseCppElem(tokenParseData) Utils.skipSpaceAndBr(tokenParseData) # 删除左边的空格
def parseCppElem(self, strParam): super.parseCppElem(strParam) while len(strParam): oneToken = Utils.getToken(strParam) if oneToken[0:2] == "*/": break