示例#1
0
 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))
示例#2
0
 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)))
示例#3
0
 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)))