def next_token(self):
        """Lexical analyser of the raw input."""
        while self.char is not None:

            if self.char.isspace():
                # The current character is a whitespace
                self.whitespace()
                continue

            elif self.char == '#':
                # The current character is `#`
                self.advance()
                self.comment()
                continue

            elif self.char.isalpha() or self.char == '_':
                # The current character is a letter or `_`
                return self._id()

            elif self.char == ';':
                # The current character is `;`
                self.advance()
                return Token(Nature.SEMI, ';')

            elif self.char == ',':
                # The current character is `,`
                self.advance()
                return Token(Nature.COMMA, ';')

            elif self.char.isdigit():
                # The current character is a number
                return self.number()

            elif self.char == '=' and self.peek() == '=':
                # The current character is `==`
                self.advance()
                self.advance()
                return Token(Nature.EQ, '==')

            elif self.char == '!' and self.peek() == '=':
                # The current character is `!=`
                self.advance()
                self.advance()
                return Token(Nature.NE, '!=')

            elif self.char == '<' and self.peek() == '=':
                # The current character is `<=`
                self.advance()
                self.advance()
                return Token(Nature.LE, '<=')

            elif self.char == '>' and self.peek() == '=':
                # The current character is `>=`
                self.advance()
                self.advance()
                return Token(Nature.GE, '>=')

            elif self.char == '<':
                # The current character is `<`
                self.advance()
                return Token(Nature.LT, '<')

            elif self.char == '>':
                # The current character is `>`
                self.advance()
                return Token(Nature.GT, '>')

            elif self.char == '=':
                # The current character is `=`
                self.advance()
                return Token(Nature.ASSIGN, '=')

            elif self.char == '+':
                # The current character is `+`
                self.advance()
                return Token(Nature.PLUS, '+')

            elif self.char == '-':
                # The current character is `-`
                self.advance()
                return Token(Nature.MINUS, '-')

            elif self.char == '*':
                # The current character is `*`
                self.advance()
                return Token(Nature.MUL, '*')

            elif self.char == '/' and self.peek() == '/':
                # The current character is `//`
                self.advance()
                self.advance()
                return Token(Nature.INT_DIV, '//')

            elif self.char == '/':
                # The current character is `/`
                self.advance()
                return Token(Nature.DIV, '/')

            elif self.char == '(':
                # The current character is `(`
                self.advance()
                return Token(Nature.LPAREN, '(')

            elif self.char == ')':
                # The current character is `)`
                self.advance()
                return Token(Nature.RPAREN, ')')

            elif self.char == '{':
                # The current character is `{`
                self.advance()
                return Token(Nature.LBRACKET, '{')

            elif self.char == '}':
                # The current character is `}`
                self.advance()
                return Token(Nature.RBRACKET, '}')

            else:
                # The current character is unknown
                raise LexicalError(f"Invalid character `{self.char}`.")

        # End of raw input
        return Token(Nature.EOF, None)
def next_token ( self ) : while self . char is not None : if self . char . isspace ( ) : self . whitespace ( ) continue elif self . char == '#' : self . advance ( ) self . comment ( ) continue elif self . char . isalpha ( ) or self . char == '_' : return self . _id ( ) elif self . char == ';' : self . advance ( ) return Token ( Nature . SEMI , ';' ) elif self . char == ',' : self . advance ( ) return Token ( Nature . COMMA , ';' ) elif self . char . isdigit ( ) : return self . number ( ) elif self . char == '=' and self . peek ( ) == '=' : self . advance ( ) self . advance ( ) return Token ( Nature . EQ , '==' ) elif self . char == '!' and self . peek ( ) == '=' : self . advance ( ) self . advance ( ) return Token ( Nature . NE , '!=' ) elif self . char == '<' and self . peek ( ) == '=' : self . advance ( ) self . advance ( ) return Token ( Nature . LE , '<=' ) elif self . char == '>' and self . peek ( ) == '=' : self . advance ( ) self . advance ( ) return Token ( Nature . GE , '>=' ) elif self . char == '<' : self . advance ( ) return Token ( Nature . LT , '<' ) elif self . char == '>' : self . advance ( ) return Token ( Nature . GT , '>' ) elif self . char == '=' : self . advance ( ) return Token ( Nature . ASSIGN , '=' ) elif self . char == '+' : self . advance ( ) return Token ( Nature . PLUS , '+' ) elif self . char == '-' : self . advance ( ) return Token ( Nature . MINUS , '-' ) elif self . char == '*' : self . advance ( ) return Token ( Nature . MUL , '*' ) elif self . char == '/' and self . peek ( ) == '/' : self . advance ( ) self . advance ( ) return Token ( Nature . INT_DIV , '//' ) elif self . char == '/' : self . advance ( ) return Token ( Nature . DIV , '/' ) elif self . char == '(' : self . advance ( ) return Token ( Nature . LPAREN , '(' ) elif self . char == ')' : self . advance ( ) return Token ( Nature . RPAREN , ')' ) elif self . char == '{' : self . advance ( ) return Token ( Nature . LBRACKET , '{' ) elif self . char == '}' : self . advance ( ) return Token ( Nature . RBRACKET , '}' ) else : raise LexicalError ( f"Invalid character `{self.char}`." ) return Token ( Nature . EOF , None )
Lexical analyser of the raw input.