def syntax_error(self, expected):
     print (expected + " was expected, but " + T.get_name(self.lookahead[0]) + " was found in line " + str(self.lookahead[3]))
     sys.exit("The program is not valid.")
 def match(self, token):
     if self.peek() == token:
         self.lookahead = self.lexical_analyser.yylex()
         #print "Matched " + T.get_name(token)
     else:
         self.syntax_error(T.get_name(token))
 def __init__ (self, lexical_analyser):
     T.load()
     self.lexical_analyser = lexical_analyser
     self.lookahead = self.lexical_analyser.yylex()