dshellInterpreter 0.1.21__py3-none-any.whl → 0.1.23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dshellInterpreter might be problematic. Click here for more details.
- Dshell/_DshellTokenizer/dshell_tokenizer.py +21 -8
- {dshellinterpreter-0.1.21.dist-info → dshellinterpreter-0.1.23.dist-info}/METADATA +1 -1
- {dshellinterpreter-0.1.21.dist-info → dshellinterpreter-0.1.23.dist-info}/RECORD +6 -6
- {dshellinterpreter-0.1.21.dist-info → dshellinterpreter-0.1.23.dist-info}/WHEEL +0 -0
- {dshellinterpreter-0.1.21.dist-info → dshellinterpreter-0.1.23.dist-info}/licenses/LICENSE +0 -0
- {dshellinterpreter-0.1.21.dist-info → dshellinterpreter-0.1.23.dist-info}/top_level.txt +0 -0
|
@@ -14,11 +14,11 @@ from .dshell_token_type import Token
|
|
|
14
14
|
MASK_CHARACTER = '§'
|
|
15
15
|
|
|
16
16
|
table_regex: dict[DTT, Pattern] = {
|
|
17
|
-
DTT.COMMENT: compile(r"::(
|
|
17
|
+
DTT.COMMENT: compile(r"::(.*?)"),
|
|
18
18
|
# DTT.DICT: compile(r"\{(.*?)\}"),
|
|
19
|
-
DTT.
|
|
19
|
+
DTT.STR: compile(r'"(.*?)"', flags=DOTALL),
|
|
20
20
|
DTT.LIST: compile(r"\[(.*?)\]"),
|
|
21
|
-
DTT.
|
|
21
|
+
DTT.CALL_ARGS: compile(r"\((.*?)\)"),
|
|
22
22
|
DTT.MENTION: compile(r'<(?:@!?|@&|#)([0-9]+)>'),
|
|
23
23
|
DTT.KEYWORD: compile(rf"(?<!\w)(#?{'|'.join(dshell_keyword)})(?!\w)"),
|
|
24
24
|
DTT.DISCORD_KEYWORD: compile(rf"(?<!\w|-)(#?{'|'.join(dshell_discord_keyword)})(?!\w|-)"),
|
|
@@ -70,22 +70,35 @@ class DshellTokenizer:
|
|
|
70
70
|
token = Token(token_type, match.group(1), (line_number, match.start())) # on enregistre son token
|
|
71
71
|
tokens_par_ligne.append(token)
|
|
72
72
|
|
|
73
|
-
len_match = len(match.group(0))
|
|
74
|
-
ligne = ligne[:match.start()] + (MASK_CHARACTER * len_match) + ligne[
|
|
75
|
-
match.end():] # remplace la match qui vient d'avoir lieu pour ne pas le rematch une seconde fois
|
|
76
|
-
|
|
77
73
|
if token_type in (
|
|
78
74
|
DTT.LIST,
|
|
79
|
-
DTT.CALL_ARGS): # si c'est un
|
|
75
|
+
DTT.CALL_ARGS): # si c'est un regroupement de donnée, on tokenize ce qu'il contient
|
|
80
76
|
result = self.tokenizer([token.value])
|
|
81
77
|
token.value = result[0] if len(
|
|
82
78
|
result) > 0 else result # gère si la structure de donnée est vide ou non
|
|
83
79
|
|
|
80
|
+
for token_in_list in token.value:
|
|
81
|
+
token_in_list.position = (line_number, token_in_list.position[1])
|
|
82
|
+
|
|
83
|
+
for token_in_line in range(len(tokens_par_ligne)-1):
|
|
84
|
+
if tokens_par_ligne[token_in_line].position[1] > match.start():
|
|
85
|
+
str_tokens_in_list = tokens_par_ligne[token_in_line:-1]
|
|
86
|
+
tokens_par_ligne = tokens_par_ligne[:token_in_line] + [tokens_par_ligne[-1]]
|
|
87
|
+
token.value.extend(str_tokens_in_list)
|
|
88
|
+
token.value.sort(key=lambda t: t.position[1]) # trie les tokens par rapport à leur position
|
|
89
|
+
break
|
|
90
|
+
|
|
91
|
+
len_match = len(match.group(0))
|
|
92
|
+
ligne = ligne[:match.start()] + (MASK_CHARACTER * len_match) + ligne[
|
|
93
|
+
match.end():] # remplace la match qui vient d'avoir lieu pour ne pas le rematch une seconde fois
|
|
94
|
+
|
|
84
95
|
tokens_par_ligne.sort(key=lambda
|
|
85
96
|
token: token.position[1]) # trie la position par rapport aux positions de match des tokens pour les avoir dans l'ordre du code
|
|
86
97
|
if tokens_par_ligne:
|
|
87
98
|
tokens.append(tokens_par_ligne)
|
|
88
99
|
|
|
100
|
+
line_number += 1 # incrémente le numéro de ligne pour la prochaine ligne
|
|
101
|
+
|
|
89
102
|
return tokens
|
|
90
103
|
|
|
91
104
|
@staticmethod
|
|
@@ -11,9 +11,9 @@ Dshell/_DshellParser/dshell_parser.py,sha256=jCnwxY_J-_u1W_tEotQznp4_Y0aeAH4pTcP
|
|
|
11
11
|
Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
|
|
12
12
|
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=10VctszIRg8AX5Nsr7kwRIjdwzUgTfrrJYbD7QfYR5s,4253
|
|
13
13
|
Dshell/_DshellTokenizer/dshell_token_type.py,sha256=Q8Jpil9S3-Tin1sXEHW7cnNdDdUh7Fiv8_lki0OWC0E,1443
|
|
14
|
-
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=
|
|
15
|
-
dshellinterpreter-0.1.
|
|
16
|
-
dshellinterpreter-0.1.
|
|
17
|
-
dshellinterpreter-0.1.
|
|
18
|
-
dshellinterpreter-0.1.
|
|
19
|
-
dshellinterpreter-0.1.
|
|
14
|
+
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=CMRUXLkRPGUmsyT3Rkal-INQ7tTneFFH0WYQ-2ItMv8,6686
|
|
15
|
+
dshellinterpreter-0.1.23.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
|
16
|
+
dshellinterpreter-0.1.23.dist-info/METADATA,sha256=HLrQ28EL8AiKBPqHpZMLvMizGDn6Q0nM574b5DKElMY,1096
|
|
17
|
+
dshellinterpreter-0.1.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
18
|
+
dshellinterpreter-0.1.23.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
|
|
19
|
+
dshellinterpreter-0.1.23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|