-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Consider the following code:
text = """private void unlockMap(Player player) {
TowerData towerData = player.getTowerData();
if (!towerData.getClass().equals(TowerData.class)) {
CommandHandler.sendTranslatedMessage(player, "commands.generic.no_permissions");
} else {
if (towerData."""
import code_tokenize as ctok
tokens = ctok.tokenize(text, lang='java', syntax_error='ignore')
assert tokens[-1].type == '.', (tokens[-1].type, tokens[-1].text)The result of executing the above code is:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[23], line 11
8 import code_tokenize as ctok
9 tokens = ctok.tokenize(text, lang='java', syntax_error='ignore')
---> 11 assert tokens[-1].type == '.', (tokens[-1].type, tokens[-1].text)
AssertionError: ('}', '')
There is an additional token of type '}' in the end of the tokenstream, and it doesn't match any text.
The tokenstream upto the last token is as expected:
[private,
void,
unlockMap,
,
(,
Player,
player,
),
{,
TowerData,
towerData,
=,
player,
.,
getTowerData,
(,
),
;,
if,
(,
!,
towerData,
.,
getClass,
(,
),
.,
equals,
(,
TowerData,
.,
class,
),
),
{,
CommandHandler,
.,
sendTranslatedMessage,
(,
player,
,,
"commands.generic.no_permissions",
),
;,
},
else,
{,
if,
(,
towerData,
.,
]
Metadata
Metadata
Assignees
Labels
No labels