Lines Matching refs:self

27     def __init__ (self):  argument
30 def str (self): argument
34 def __init__ (self): argument
37 def str (self): argument
93 def __init__ (self): argument
94 self.defines = {}
95 self.tokens = []
111 def __init__ (self, chars, filepath = None): argument
112 self.filepath = filepath
113 self.parentLexer = None
114 self.chars = chars
115 self.bufsize = len(self.chars)
119 self.headerDict = dict ()
120 self.debug = False
121 self.debugMacro = False
122 self.includeDirs = list ()
123 self.expandHeaders = True
124 self.inMacroDefine = False
125 self.stopOnHeader = False
127 def copyProperties (self, other): argument
131 self.headerDict = other.headerDict
132 self.debug = other.debug
133 self.debugMacro = other.debugMacro
134 self.includeDirs = other.includeDirs[:]
135 self.expandHeaders = other.expandHeaders
136 self.inMacroDefine = other.inMacroDefine
137 self.stopOnHeader = other.stopOnHeader
139 def init (self): argument
140 self.firstNonBlank = ''
141 self.token = ''
142 self.tokens = []
143 self.defines = {}
144 self.visibilityStack = []
146 def getTokens (self): argument
147 return self.tokens
149 def getDefines (self): argument
150 return self.defines
152 def nextPos (self, i): argument
156 c = self.chars[i]
165 def prevPos (self, i): argument
169 c = self.chars[i]
178 def isCodeVisible (self): argument
179 if len(self.visibilityStack) == 0:
181 for item in self.visibilityStack:
186 def tokenize (self): argument
187 self.init()
191 c = self.chars[i]
193 if self.firstNonBlank == '' and not c in [' ', "\n", "\t"]:
195 self.firstNonBlank = c
197 self.firstNonBlank = ''
200 i = self.pound(i)
202 i = self.slash(i)
204 i = self.lineBreak(i)
206 i = self.doubleQuote(i)
208 i = self.blank(i)
211 i = self.anyToken(i, c)
212 elif self.isCodeVisible():
213 self.token += c
216 i = self.nextPos(i)
220 if len(self.token):
221 self.tokens.append(self.token)
223 if not self.parentLexer and self.debug:
226 keys = sorted(self.defines.keys())
230 def dumpTokens (self, toError=False): argument
231 dumpTokens(self.tokens, toError)
234 def maybeAddToken (self): argument
235 if len(self.token) > 0:
236 self.tokens.append(self.token)
237 self.token = ''
243 def blank (self, i): argument
244 if not self.isCodeVisible():
247 self.maybeAddToken()
251 def pound (self, i): argument
253 if self.inMacroDefine:
256 if not self.firstNonBlank == '#':
259 self.maybeAddToken()
268 i = self.nextPos(i)
269 c = self.chars[i]
270 if c == '\\' and self.chars[self.nextPos(i)] == "\n":
271 i = self.nextPos(i)
279 i = self.prevPos(i)
301 self.handleMacroDefine(buf)
303 self.handleMacroInclude(buf)
306 if defineName in self.defines:
307 self.visibilityStack.append(SrcLexer.VISIBLE)
309 self.visibilityStack.append(SrcLexer.INVISIBLE_PRE)
313 if defineName in self.defines:
314 self.visibilityStack.append(SrcLexer.INVISIBLE_PRE)
316 self.visibilityStack.append(SrcLexer.VISIBLE)
319 if self.evalCodeVisibility(buf):
320 self.visibilityStack.append(SrcLexer.VISIBLE)
322 self.visibilityStack.append(SrcLexer.INVISIBLE_PRE)
325 if len(self.visibilityStack) == 0:
328 if self.visibilityStack[-1] == SrcLexer.VISIBLE:
329 self.visibilityStack[-1] = SrcLexer.INVISIBLE_POST
330 elif self.visibilityStack[-1] == SrcLexer.INVISIBLE_PRE:
332 if self.evalCodeVisibility(buf):
333 self.visibilityStack[-1] = SrcLexer.VISIBLE
336 if len(self.visibilityStack) == 0:
339 if self.visibilityStack[-1] == SrcLexer.VISIBLE:
340 self.visibilityStack[-1] = SrcLexer.INVISIBLE_POST
341 if self.visibilityStack[-1] == SrcLexer.INVISIBLE_PRE:
342 self.visibilityStack[-1] = SrcLexer.VISIBLE
345 if len(self.visibilityStack) == 0:
347 self.visibilityStack.pop()
355 print(self.filepath)
361 def evalCodeVisibility (self, buf): argument
367 def handleMacroDefine (self, buf): argument
370 mparser.debug = self.debugMacro
374 self.defines[macro.name] = macro
376 def handleMacroInclude (self, buf): argument
384 if not self.expandHeaders:
386 if self.debug:
392 for includeDir in self.includeDirs:
394 if os.path.isfile(hpath) and hpath != self.filepath:
399 error("included header file " + headerSub + " not found\n", self.stopOnHeader)
402 if self.debug:
405 if headerPath in self.headerDict:
406 if self.debug:
411 if self.debug:
414 self.defines[key] = SrcLexer.headerCache[headerPath].defines[key]
419 mclexer.copyProperties(self)
420 mclexer.parentLexer = self
429 self.headerDict[headerPath] = True
434 self.headerDict[key] = True
436 if self.debug:
442 self.defines[key] = defines[key]
445 def slash (self, i): argument
446 if not self.isCodeVisible():
449 if i < self.bufsize - 1 and self.chars[i+1] == '/':
453 while i < self.bufsize:
454 c = self.chars[i]
459 self.token = ''
460 elif i < self.bufsize - 1 and self.chars[i+1] == '*':
463 while i < self.bufsize:
464 c = self.chars[i]
465 if c == '/' and self.chars[i-1] == '*':
470 return self.anyToken(i, '/')
475 def lineBreak (self, i): argument
476 if not self.isCodeVisible():
479 self.maybeAddToken()
484 def doubleQuote (self, i): argument
485 if not self.isCodeVisible():
490 while i < self.bufsize:
491 c = self.chars[i]
493 self.tokens.append('"'+literal+'"')
501 def anyToken (self, i, token): argument
502 if not self.isCodeVisible():
505 self.maybeAddToken()
506 self.token = token
507 self.maybeAddToken()