dshellInterpreter 0.1.22__tar.gz → 0.1.24__tar.gz

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.

Files changed (24) hide show
  1. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/_DshellInterpreteur/dshell_interpreter.py +13 -1
  2. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/_DshellTokenizer/dshell_token_type.py +1 -0
  3. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/_DshellTokenizer/dshell_tokenizer.py +28 -10
  4. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/PKG-INFO +1 -1
  5. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/dshellInterpreter.egg-info/PKG-INFO +1 -1
  6. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/setup.py +1 -1
  7. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/DISCORD_COMMANDS/__init__.py +0 -0
  8. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/DISCORD_COMMANDS/dshell_channel.py +0 -0
  9. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/DISCORD_COMMANDS/dshell_member.py +0 -0
  10. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/DISCORD_COMMANDS/dshell_message.py +0 -0
  11. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/_DshellInterpreteur/__init__.py +0 -0
  12. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/_DshellParser/__init__.py +0 -0
  13. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/_DshellParser/ast_nodes.py +0 -0
  14. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/_DshellParser/dshell_parser.py +0 -0
  15. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/_DshellTokenizer/__init__.py +0 -0
  16. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/_DshellTokenizer/dshell_keywords.py +0 -0
  17. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/Dshell/__init__.py +0 -0
  18. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/LICENSE +0 -0
  19. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/README.md +0 -0
  20. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/dshellInterpreter.egg-info/SOURCES.txt +0 -0
  21. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
  22. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/dshellInterpreter.egg-info/requires.txt +0 -0
  23. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/dshellInterpreter.egg-info/top_level.txt +0 -0
  24. {dshellinterpreter-0.1.22 → dshellinterpreter-0.1.24}/setup.cfg +0 -0
@@ -186,6 +186,8 @@ def get_params(node: ParamNode, interpreter: DshellInterpreteur) -> dict[str, An
186
186
  if regrouped_args[key] == '*':
187
187
  raise Exception(f"'{key}' is an obligatory parameter, but no value was given for it.")
188
188
 
189
+ print(regrouped_args)
190
+
189
191
  return regrouped_args
190
192
 
191
193
  def eval_expression_inline(if_node: IfNode, interpreter: DshellInterpreteur) -> Token:
@@ -278,6 +280,7 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur) -> li
278
280
 
279
281
  i = 0
280
282
  while i < n:
283
+
281
284
  if body[i].type == DTT.SEPARATOR and body[
282
285
  i + 1].type == DTT.IDENT: # Check if it's a separator and if the next token is an IDENT
283
286
  current_arg = body[i + 1].value # change the current argument. It will be impossible to return to '*'
@@ -291,7 +294,15 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur) -> li
291
294
  type_=DTT.SEPARATOR, value=body[i].value, position=body[i].position)
292
295
  ] + body[i + 1:], interpreter
293
296
  ) # add a sub-dictionary for sub-commands
294
- return list_tokens
297
+ #return list_tokens
298
+
299
+ elif (body[i].type == DTT.SEPARATOR and
300
+ (body[i + 1].type == DTT.MATHS_OPERATOR and body[i + 1].value == '*') and
301
+ body[i + 2].type == DTT.IDENT and
302
+ body[i + 3].type == DTT.ENGLOBE_SEPARATOR):
303
+ current_arg = body[i + 2].value # change the current argument
304
+ tokens[current_arg] = body[i + 3].value
305
+ i += 4
295
306
 
296
307
  else:
297
308
  if current_arg == '*':
@@ -299,6 +310,7 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur) -> li
299
310
  else:
300
311
  tokens[current_arg] = interpreter.eval_data_token(body[i]) # add the token to the current argument
301
312
  i += 1
313
+
302
314
  return list_tokens
303
315
 
304
316
 
@@ -25,6 +25,7 @@ class DshellTokenType(Enum):
25
25
  DISCORD_KEYWORD = auto() # embed, #embed...
26
26
  COMMAND = auto()
27
27
  SEPARATOR = auto() # --
28
+ ENGLOBE_SEPARATOR = auto(), # --*
28
29
  SUB_SEPARATOR = auto(), # ~~
29
30
  MATHS_OPERATOR = auto() # ==, +, -, *, etc.
30
31
  LOGIC_OPERATOR = auto(),
@@ -14,16 +14,16 @@ from .dshell_token_type import Token
14
14
  MASK_CHARACTER = '§'
15
15
 
16
16
  table_regex: dict[DTT, Pattern] = {
17
- DTT.COMMENT: compile(r"::(.*)"),
18
- # DTT.DICT: compile(r"\{(.*?)\}"),
19
- DTT.CALL_ARGS: compile(r"\((.*?)\)"),
17
+ DTT.COMMENT: compile(r"::(.*?)"),
18
+ DTT.ENGLOBE_SEPARATOR: compile(rf"--\*\w+\s*(.*)"),
19
+ DTT.STR: compile(r'"(.*?)"', flags=DOTALL),
20
20
  DTT.LIST: compile(r"\[(.*?)\]"),
21
- DTT.STR: compile(r"\"(.*?)\"", flags=DOTALL),
21
+ DTT.CALL_ARGS: compile(r"\((.*?)\)"),
22
22
  DTT.MENTION: compile(r'<(?:@!?|@&|#)([0-9]+)>'),
23
- DTT.KEYWORD: compile(rf"(?<!\w)(#?{'|'.join(dshell_keyword)})(?!\w)"),
24
- DTT.DISCORD_KEYWORD: compile(rf"(?<!\w|-)(#?{'|'.join(dshell_discord_keyword)})(?!\w|-)"),
25
23
  DTT.SEPARATOR: compile(rf"(--)"),
26
24
  DTT.SUB_SEPARATOR: compile(rf"(~~)"),
25
+ DTT.KEYWORD: compile(rf"(?<!\w)(#?{'|'.join(dshell_keyword)})(?!\w)"),
26
+ DTT.DISCORD_KEYWORD: compile(rf"(?<!\w|-)(#?{'|'.join(dshell_discord_keyword)})(?!\w|-)"),
27
27
  DTT.COMMAND: compile(rf"\b({'|'.join(dshell_commands.keys())})\b"),
28
28
  DTT.MATHS_OPERATOR: compile(rf"({'|'.join([escape(i) for i in dshell_mathematical_operators.keys()])})"),
29
29
  DTT.LOGIC_OPERATOR: compile(rf"(?<!\w)({'|'.join([escape(i) for i in dshell_logical_operators.keys()])})(?<!\w)"),
@@ -66,19 +66,35 @@ class DshellTokenizer:
66
66
  for token_type, pattern in table_regex.items(): # iter la table de régex pour tous les tester sur la ligne
67
67
 
68
68
  for match in finditer(pattern, ligne): # iter les résultat du match pour avoir leur position
69
+
70
+ start_match = match.start() # position de début du match
71
+ if token_type == DTT.ENGLOBE_SEPARATOR:
72
+ start_match += len(match.group(0)) - len(match.group(1)) # si c'est un séparateur englobant, on enlève les --* du début
73
+
69
74
  if token_type != DTT.COMMENT: # si ce n'est pas un commentaire
70
- token = Token(token_type, match.group(1), (line_number, match.start())) # on enregistre son token
75
+ token = Token(token_type, match.group(1), (line_number, start_match)) # on enregistre son token
71
76
  tokens_par_ligne.append(token)
72
77
 
73
78
  if token_type in (
74
79
  DTT.LIST,
75
- DTT.CALL_ARGS): # si c'est un regrouppement de donnée, on tokenize ce qu'il contient
80
+ DTT.CALL_ARGS): # si c'est un regroupement de donnée, on tokenize ce qu'il contient
76
81
  result = self.tokenizer([token.value])
77
82
  token.value = result[0] if len(
78
83
  result) > 0 else result # gère si la structure de donnée est vide ou non
79
84
 
80
- len_match = len(match.group(0))
81
- ligne = ligne[:match.start()] + (MASK_CHARACTER * len_match) + ligne[
85
+ for token_in_list in token.value:
86
+ token_in_list.position = (line_number, token_in_list.position[1])
87
+
88
+ for token_in_line in range(len(tokens_par_ligne)-1):
89
+ if tokens_par_ligne[token_in_line].position[1] > start_match:
90
+ str_tokens_in_list = tokens_par_ligne[token_in_line:-1]
91
+ tokens_par_ligne = tokens_par_ligne[:token_in_line] + [tokens_par_ligne[-1]]
92
+ token.value.extend(str_tokens_in_list)
93
+ token.value.sort(key=lambda t: t.position[1]) # trie les tokens par rapport à leur position
94
+ break
95
+
96
+ len_match = len(match.group(0)) # longueur du match trouvé
97
+ ligne = ligne[:start_match] + (MASK_CHARACTER * len_match) + ligne[
82
98
  match.end():] # remplace la match qui vient d'avoir lieu pour ne pas le rematch une seconde fois
83
99
 
84
100
  tokens_par_ligne.sort(key=lambda
@@ -86,6 +102,8 @@ class DshellTokenizer:
86
102
  if tokens_par_ligne:
87
103
  tokens.append(tokens_par_ligne)
88
104
 
105
+ line_number += 1 # incrémente le numéro de ligne pour la prochaine ligne
106
+
89
107
  return tokens
90
108
 
91
109
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.1.22
3
+ Version: 0.1.24
4
4
  Summary: A Discord bot interpreter for creating custom commands and automations.
5
5
  Home-page: https://github.com/BOXERRMD/Dshell_Interpreter
6
6
  Author: Chronos
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.1.22
3
+ Version: 0.1.24
4
4
  Summary: A Discord bot interpreter for creating custom commands and automations.
5
5
  Home-page: https://github.com/BOXERRMD/Dshell_Interpreter
6
6
  Author: Chronos
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name="dshellInterpreter",
8
- version="0.1.22",
8
+ version="0.1.24",
9
9
  author="Chronos",
10
10
  author_email="vagabonwalybi@gmail.com",
11
11
  description="A Discord bot interpreter for creating custom commands and automations.",