def __init__(self, filename, data=None): self.filename = filename self.tokenlist = [] self.indexstack = [] self.tokenindex = -1 self.matchingPair = {} self.reverseMatchingPair = {} self.ifdefstack = [] import nsiqcppstyle_lexer lexer = nsiqcppstyle_lexer.lex() self.data = data if data is None: with open(filename) as f: try: self.data = f.read() except UnicodeDecodeError as ex: console.Out.Ci( "[ERROR] UnicodeDecodeError in CppLexerNavigator: " + str(ex)) console.Out.Ci( "[ERROR] Exception occurred reading file '%s', convert from UTF16LE to UTF8" % (filename)) raise ex self.lines = self.data.splitlines() lexer.input(self.data) index = 0 while True: tok = lexer.token() if not tok: break tok.column = self._GetColumn(tok) tok.index = index tok.inactive = False index += 1 self.tokenlist.append(tok) tok.line = self.lines[tok.lineno - 1] tok.filename = self.filename tok.pp = None # self.ProcessIfdef(tok) self.tokenlistsize = len(self.tokenlist) self.PushTokenIndex() while (True): t = self.GetNextToken() if t is None: break t.inactive = self.ProcessIfdef(t) self.PopTokenIndex()
def __init__(self, filename, data=None): self.filename = filename self.tokenlist = [] self.indexstack = [] self.tokenindex = -1 self.matchingPair = {} self.reverseMatchingPair = {} self.ifdefstack = [] import nsiqcppstyle_lexer lexer = nsiqcppstyle_lexer.lex() self.data = data if data is None: f = open(filename) self.data = f.read() self.lines = self.data.splitlines() lexer.input(self.data) index = 0 while True: tok = lexer.token() if not tok: break tok.column = self._GetColumn(tok) tok.index = index tok.inactive = False index += 1 self.tokenlist.append(tok) tok.line = self.lines[tok.lineno - 1] tok.filename = self.filename tok.pp = None # self.ProcessIfdef(tok) self.tokenlistsize = len(self.tokenlist) self.PushTokenIndex() while (True): t = self.GetNextToken() if t is None: break t.inactive = self.ProcessIfdef(t) self.PopTokenIndex()
def __init__(self, filename, data= None): self.filename = filename self.tokenlist = [] self.indexstack = [] self.tokenindex = -1 self.matchingPair = {} self.reverseMatchingPair = {} self.ifdefstack = [] import nsiqcppstyle_lexer lexer = nsiqcppstyle_lexer.lex() self.data = data if data == None : f = open(filename) self.data = f.read() self.lines = self.data.splitlines() lexer.input(self.data) index = 0 while True : tok = lexer.token() if not tok : break; tok.column = self._GetColumn(tok) tok.index = index tok.inactive = False index += 1 self.tokenlist.append(tok) tok.line = self.lines[tok.lineno-1] tok.filename = self.filename tok.pp = None # self.ProcessIfdef(tok) self.tokenlistsize = len(self.tokenlist) self.PushTokenIndex() while(True) : t = self.GetNextToken() if t == None : break t.inactive = self.ProcessIfdef(t) self.PopTokenIndex()