def showCode(self,fileCode): print('-'*120) print(Style.customHeader('Your Code\n')) file = open(fileCode,'r') for line,code in enumerate(file): print(Style.reset('{}) {}'.format(line+1,code))) print(Style.reset('-'*120))
def matchFactor(self, tokenName, tokenNameNeed=None): if (self.tokenList.token.tokenName) == tokenName: print( Style.green('Line({})-Pass '.format(self.tokenList.token.line)) + Style.reset('token {}'.format(self.tokenList.token))) self.tokenList.nextToken() else: if (tokenNameNeed): print( Style.red('Line({})-Pass Error '.format( self.tokenList.token.line)) + Style.reset('{} required.'.format(tokenNameNeed))) else: print( Style.red('Line({})-Pass Error '.format( self.tokenList.token.line)) + Style.reset('{} required.'.format(tokenName)))
def match(self, tokenAttributeValue): if (self.tokenList.token.attributeValue) == tokenAttributeValue: print( Style.green('Line({})-Match '.format( self.tokenList.token.line)) + 'token ({} {} {}) '.format( self.tokenList.token, Style.green('with'), tokenAttributeValue)) self.tokenList.nextToken() else: print( Style.red('Line({})-Syntax Error '.format( self.tokenList.token.line)) + Style.reset('{} required.'.format(tokenAttributeValue)))