Lines Matching refs:self
94 def __init__ (self): argument
95 self.leftTokens = []
96 self.leftScope = None
100 def __init__ (self, tokens, defines): argument
101 self.tokens = tokens
102 self.defines = defines
104 def expand (self): argument
105 self.pos = 0
106 while self.pos < len(self.tokens):
107 self.expandToken()
109 def expandToken (self): argument
110 token = self.tokens[self.pos]
111 if token not in self.defines:
112 self.pos += 1
115 macro = self.defines[token]
119 self.tokens[self.pos:self.pos+1] = macro.tokens
123 values, lastPos = self.parseValues()
136 self.tokens[self.pos:self.pos+lastPos+1] = newtokens
139 def parseValues (self): argument
155 tk = self.tokens[self.pos+i]
159 print(self.tokens[self.pos+j], end=' ')
161 srclexer.dumpTokens(self.tokens)
162 srclexer.dumpTokens(self.newtokens)
164 for tk in self.expandedTokens:
167 srclexer.dumpTokens(self.defines[tk].tokens)
189 def getTokens (self): argument
190 return self.tokens
195 def __init__ (self, tokens, defines = None): argument
196 self.tokens = tokens
197 self.defines = defines
198 self.debug = False
199 self.onlyExpandMacros = False
201 def init (self): argument
202 self.elementStack = [RootNode()]
203 self.stmtData = Statement()
204 self.tokenBuf = []
205 self.leftTokens = []
208 if self.debug:
210 for key in list(self.defines.keys()):
213 self.expandMacro()
214 self.tokenSize = len(self.tokens)
216 def expandMacro (self): argument
217 macroExp = MacroExpander(self.tokens, self.defines)
219 self.tokens = macroExp.getTokens()
220 if self.onlyExpandMacros:
221 srclexer.dumpTokens(self.tokens)
224 def parse (self): argument
229 self.init()
232 while i < self.tokenSize:
233 tk = self.tokens[i]
235 i = self.openBrace(i)
237 i = self.closeBrace(i)
239 i = self.semiColon(i)
241 i = self.assignment(i)
243 self.tokenBuf.append(tk)
247 return self.elementStack[0]
266 def assignment (self, i): argument
267 self.leftTokens = self.tokenBuf[:]
268 if self.stmtData.leftScope == None:
270 self.stmtData.leftTokens = self.tokenBuf[:]
271 self.stmtData.leftScope = len(self.elementStack) - 1
273 self.tokenBuf = []
277 def openBrace (self, i): argument
278 bufSize = len(self.tokenBuf)
279 leftSize = len(self.leftTokens)
283 obj = Element(self.leftTokens[0])
287 wgtType = self.tokenBuf[0]
290 wgtRID = self.tokenBuf[1]
295 obj = Element(self.leftTokens[0])
296 obj.setAttr("type", self.tokenBuf[0])
301 i = self.parseStringList(i)
303 i = self.parseFilterList(i, obj)
305 self.elementStack[-1].appendChild(obj)
306 self.elementStack.append(obj)
308 self.tokenBuf = []
309 self.leftTokens = []
314 def closeBrace (self, i): argument
315 if len(self.tokenBuf) > 0:
316 if self.debug:
317 print(self.tokenBuf)
319 self.elementStack.pop()
323 def semiColon (self, i): argument
324 stackSize = len(self.elementStack)
326 if len(self.tokenBuf) == 0:
335 elem = self.elementStack[-1]
338 if len(self.leftTokens) > 0:
341 name = self.leftTokens[0]
345 i = self.parsePosAttr(i)
347 i = self.parseSizeAttr(i)
348 elif len (self.tokenBuf) == 1:
350 value = transValue(self.tokenBuf[0])
354 if not self.stmtData.leftScope == None and self.stmtData.leftScope < scope:
358 if self.stmtData.leftScope == scope:
360 self.stmtData.leftScope = None
362 self.tokenBuf = []
363 self.leftTokens = []
367 def parseStringList (self, i): argument
370 while i < self.tokenSize:
371 tk = self.tokens[i]
378 def parseFilterList (self, i, obj): argument
379 self.elementStack[-1].appendChild(obj)
380 self.elementStack.append(obj)
384 def parsePosAttr (self, i): argument
387 elem = self.elementStack[-1]
388 x, y = self.parseMapAppfont(self.tokenBuf)
394 def parseSizeAttr (self, i): argument
397 elem = self.elementStack[-1]
398 width, height = self.parseMapAppfont(self.tokenBuf)
404 def parseMapAppfont (self, tokens): argument