0

"cannot unpack non-iterable method object"

What is wrong with this pls help I am trying to make a lexer but the something is wrong with the tokens variable def make_tokens(self): tokens = [] while self.current_char != None: if self.current_char in ' \t': self.advance() elif self.current_char in DIGITS: tokens.append(self.make_number) self.advance() elif self.current_char == '+': tokens.append(Token(TT_PLUS)) self.advance() elif self.current_char == '+': tokens.append(Token(TT_PLUS)) self.advance() elif self.current_char == '-': tokens.append(Token(TT_MINUS)) self.advance() elif self.current_char == '*': tokens.append(Token(TT_MUL)) self.advance() elif self.current_char == '/': tokens.append(Token(TT_DIV)) self.advance() elif self.current_char == '(': tokens.append(Token(TT_LPAREN)) self.advance() elif self.current_char == ')': tokens.append(Token(TT_RPAREN)) self.advance() else: char = self.current_char self.advance return [], IllegalCharError("'" + char + "'") return tokens, None def run(text): lexer = Lexer(text) tokens, error = lexer.make_tokens return tokens, error

21st Jul 2020, 9:58 PM
Mason Wolff
Mason Wolff - avatar
1 Respuesta
+ 1
You may have better chance for answer if you share a saved code link instead of raw text code. Less hassle for those who wants to check and debug the code, plus no risk of code truncation. Follow the below guide on how to share links 👇 https://www.sololearn.com/post/75089/?ref=app
22nd Jul 2020, 4:21 AM
Ipang