def createEOF(self): Vt = VT(const.EOF, self.line, '', self.wordNo) # 如果head 都没有被初始化,处理链表第一个元素 if self.head is None: self.head = Vt self.pointer = Vt else: Vt.previous = self.pointer self.pointer.next = Vt self.pointer = Vt
def createVT(self): # 如果读取到的是注释,不创建节点,直接跳过 if self.symbol == const.ANNOTATION: return # 如果处于出错状态,不创建节点 if self.isInError(): return Vt = VT(self.symbol, self.line, self.token, self.wordNo) # 如果head 都没有被初始化,处理链表第一个元素 if self.head is None: self.head = Vt self.pointer = Vt else: Vt.previous = self.pointer self.pointer.next = Vt self.pointer = Vt