We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In [1]: from javalang.tokenizer import tokenize In [2]: list(tokenize("a == 0")) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[3], line 1 ----> 1 list(tokenize("a == 0")) File .\env\Lib\site-packages\javalang\tokenizer.py:538, in JavaTokenizer.tokenize(self) 535 self.read_string() 537 elif c in '0123456789': --> 538 token_type = self.read_integer_or_float(c, c_next) 540 elif self.is_java_identifier_start(c): 541 token_type = self.read_identifier() File .\env\Lib\site-packages\javalang\tokenizer.py:370, in JavaTokenizer.read_integer_or_float(self, c, c_next) 369 def read_integer_or_float(self, c, c_next): --> 370 if c == '0' and c_next in 'xX': 371 return self.read_hex_integer_or_float() 372 elif c == '0' and c_next in 'bB': TypeError: 'in <string>' requires string as left operand, not NoneType
In [1]: from javalang.tokenizer import tokenize In [2]: list(tokenize("a == 0")) Out[2]: [Identifier "a" line 1, position 1, Operator "==" line 1, position 3, DecimalInteger "0" line 1, position 6]
Lies in the expectation that an integer of '0' would always be followed by another token (this is done to check for possible hexadecimal or binary notation), see https://github.com/c2nes/javalang/blob/master/javalang/tokenizer.py#L370 . But this does not have to be the case.
catch None for c_next in read_integer_or_float
None
c_next
read_integer_or_float
def read_integer_or_float(self, c, c_next): if c == '0' and c_next is None: return self.read_decimal_float_or_integer() elif c == '0' and c_next in 'xX': return self.read_hex_integer_or_float() elif c == '0' and c_next in 'bB': self.read_bin_integer() return BinaryInteger elif c == '0' and c_next in '01234567': self.read_octal_integer() return OctalInteger else: return self.read_decimal_float_or_integer()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Minimal example reproducing bug
Expected behavior
Source of problem
Lies in the expectation that an integer of '0' would always be followed by another token (this is done to check for possible hexadecimal or binary notation), see https://github.com/c2nes/javalang/blob/master/javalang/tokenizer.py#L370 . But this does not have to be the case.
Suggested fix
catch
None
forc_next
inread_integer_or_float
The text was updated successfully, but these errors were encountered: