dshellInterpreter 0.2.6__py3-none-any.whl → 0.2.8__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/_DshellInterpreteur/dshell_interpreter.py +11 -4
- Dshell/_DshellParser/dshell_parser.py +2 -2
- Dshell/_DshellTokenizer/dshell_keywords.py +19 -14
- Dshell/_DshellTokenizer/dshell_token_type.py +1 -0
- Dshell/_DshellTokenizer/dshell_tokenizer.py +2 -1
- {dshellinterpreter-0.2.6.dist-info → dshellinterpreter-0.2.8.dist-info}/METADATA +1 -1
- {dshellinterpreter-0.2.6.dist-info → dshellinterpreter-0.2.8.dist-info}/RECORD +10 -10
- {dshellinterpreter-0.2.6.dist-info → dshellinterpreter-0.2.8.dist-info}/WHEEL +0 -0
- {dshellinterpreter-0.2.6.dist-info → dshellinterpreter-0.2.8.dist-info}/licenses/LICENSE +0 -0
- {dshellinterpreter-0.2.6.dist-info → dshellinterpreter-0.2.8.dist-info}/top_level.txt +0 -0
|
@@ -42,7 +42,6 @@ class DshellInterpreteur:
|
|
|
42
42
|
'__author_discriminator__': ctx.author.discriminator,
|
|
43
43
|
'__author_bot__': ctx.author.bot,
|
|
44
44
|
'__author_nick__': ctx.author.nick if hasattr(ctx.author, 'nick') else None,
|
|
45
|
-
'__author_avatar_url__': ctx.author.avatar.url if ctx.author.avatar else None,
|
|
46
45
|
'__author_id__': ctx.author.id,
|
|
47
46
|
'__message__': ctx.content,
|
|
48
47
|
'__message_id__': ctx.id,
|
|
@@ -50,7 +49,7 @@ class DshellInterpreteur:
|
|
|
50
49
|
'__channel_type__': ctx.channel.type.name if hasattr(ctx.channel, 'type') else None,
|
|
51
50
|
'__channel_id__': ctx.channel.id,
|
|
52
51
|
'__private_channel__': isinstance(ctx.channel, PrivateChannel),
|
|
53
|
-
}
|
|
52
|
+
} if ctx is not None else {}
|
|
54
53
|
self.vars = vars if vars is not None else ''
|
|
55
54
|
self.ctx: context = ctx
|
|
56
55
|
if debug:
|
|
@@ -250,7 +249,7 @@ def eval_expression(tokens: list[Token], interpreter: DshellInterpreteur) -> Any
|
|
|
250
249
|
if token.type in {DTT.INT, DTT.FLOAT, DTT.BOOL, DTT.STR, DTT.LIST, DTT.IDENT}:
|
|
251
250
|
stack.append(interpreter.eval_data_token(token))
|
|
252
251
|
|
|
253
|
-
elif token.type in (DTT.MATHS_OPERATOR, DTT.LOGIC_OPERATOR):
|
|
252
|
+
elif token.type in (DTT.MATHS_OPERATOR, DTT.LOGIC_OPERATOR, DTT.LOGIC_WORD_OPERATOR):
|
|
254
253
|
op = token.value
|
|
255
254
|
|
|
256
255
|
if op == "not":
|
|
@@ -259,7 +258,14 @@ def eval_expression(tokens: list[Token], interpreter: DshellInterpreteur) -> Any
|
|
|
259
258
|
|
|
260
259
|
else:
|
|
261
260
|
b = stack.pop()
|
|
262
|
-
|
|
261
|
+
try:
|
|
262
|
+
a = stack.pop()
|
|
263
|
+
except IndexError:
|
|
264
|
+
if op == "-":
|
|
265
|
+
a = 0
|
|
266
|
+
else:
|
|
267
|
+
raise SyntaxError(f"Invalid expression: {op} operator requires two operands, but only one was found.")
|
|
268
|
+
|
|
263
269
|
result = dshell_operators[op][0](a, b)
|
|
264
270
|
|
|
265
271
|
stack.append(result)
|
|
@@ -401,6 +407,7 @@ def build_permission(body: list[Token], interpreter: DshellInterpreteur) -> dict
|
|
|
401
407
|
|
|
402
408
|
for i in args_permissions:
|
|
403
409
|
i.pop('*')
|
|
410
|
+
i.pop('--*')
|
|
404
411
|
permissions.update(DshellPermissions(i).get_permission_overwrite(interpreter.ctx.channel.guild))
|
|
405
412
|
|
|
406
413
|
return permissions
|
|
@@ -268,7 +268,7 @@ def to_postfix(expression):
|
|
|
268
268
|
operators: list[Token] = []
|
|
269
269
|
|
|
270
270
|
for token in expression:
|
|
271
|
-
if token.type in (DTT.IDENT, DTT.CALL_ARGS, DTT.INT, DTT.FLOAT, DTT.LIST, DTT.STR): # Si c'est un ident
|
|
271
|
+
if token.type in (DTT.IDENT, DTT.CALL_ARGS, DTT.INT, DTT.FLOAT, DTT.LIST, DTT.STR, DTT.BOOL): # Si c'est un ident
|
|
272
272
|
output.append(token)
|
|
273
273
|
elif token.value in dshell_operators:
|
|
274
274
|
while (operators and operators[-1].value in dshell_operators and
|
|
@@ -289,7 +289,7 @@ def parse_postfix_expression(postfix_tokens: list[Token]) -> list[IdentOperation
|
|
|
289
289
|
|
|
290
290
|
for tok in postfix_tokens:
|
|
291
291
|
|
|
292
|
-
if tok.type in (DTT.IDENT, DTT.CALL_ARGS, DTT.INT, DTT.STR, DTT.LIST):
|
|
292
|
+
if tok.type in (DTT.IDENT, DTT.CALL_ARGS, DTT.INT, DTT.STR, DTT.LIST, DTT.FLOAT, DTT.BOOL):
|
|
293
293
|
stack.append(tok)
|
|
294
294
|
|
|
295
295
|
elif tok.type == DTT.MATHS_OPERATOR:
|
|
@@ -4,7 +4,8 @@ __all__ = [
|
|
|
4
4
|
"dshell_commands",
|
|
5
5
|
"dshell_mathematical_operators",
|
|
6
6
|
"dshell_logical_operators",
|
|
7
|
-
"dshell_operators"
|
|
7
|
+
"dshell_operators",
|
|
8
|
+
"dshell_logical_word_operators"
|
|
8
9
|
]
|
|
9
10
|
|
|
10
11
|
from typing import Callable
|
|
@@ -64,15 +65,6 @@ dshell_commands: dict[str, Callable] = {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
dshell_mathematical_operators: dict[str, tuple[Callable, int]] = {
|
|
67
|
-
r"<": (lambda a, b: a < b, 4),
|
|
68
|
-
r"<=": (lambda a, b: a <= b, 4),
|
|
69
|
-
r"=<": (lambda a, b: a <= b, 4),
|
|
70
|
-
r"=": (lambda a, b: a == b, 4),
|
|
71
|
-
r"!=": (lambda a, b: a != b, 4),
|
|
72
|
-
r"=!": (lambda a, b: a != b, 4),
|
|
73
|
-
r">": (lambda a, b: a > b, 4),
|
|
74
|
-
r">=": (lambda a, b: a >= b, 4),
|
|
75
|
-
r"=>": (lambda a, b: a >= b, 4),
|
|
76
68
|
|
|
77
69
|
r".": (lambda a, b: a.b, 9),
|
|
78
70
|
r"->": (lambda a: a.at, 10), # equivalent to calling .at(key)
|
|
@@ -87,18 +79,31 @@ dshell_mathematical_operators: dict[str, tuple[Callable, int]] = {
|
|
|
87
79
|
r"/": (lambda a, b: a / b, 7),
|
|
88
80
|
}
|
|
89
81
|
|
|
82
|
+
dshell_logical_word_operators: dict[str, tuple[Callable, int]] = {
|
|
83
|
+
r"and": (lambda a, b: bool(a and b), 2),
|
|
84
|
+
r"or": (lambda a, b: bool(a or b), 1),
|
|
85
|
+
r"not": (lambda a: not a, 3),
|
|
86
|
+
r"in": (lambda a, b: a in b, 4),
|
|
87
|
+
}
|
|
88
|
+
|
|
90
89
|
dshell_logical_operators: dict[str, tuple[Callable, int]] = {
|
|
91
90
|
|
|
92
|
-
r"
|
|
91
|
+
r"<": (lambda a, b: a < b, 4),
|
|
92
|
+
r"<=": (lambda a, b: a <= b, 4),
|
|
93
|
+
r"=<": (lambda a, b: a <= b, 4),
|
|
94
|
+
r"=": (lambda a, b: a == b, 4),
|
|
95
|
+
r"!=": (lambda a, b: a != b, 4),
|
|
96
|
+
r"=!": (lambda a, b: a != b, 4),
|
|
97
|
+
r">": (lambda a, b: a > b, 4),
|
|
98
|
+
r">=": (lambda a, b: a >= b, 4),
|
|
99
|
+
r"=>": (lambda a, b: a >= b, 4),
|
|
93
100
|
r"&": (lambda a, b: a & b, 2),
|
|
94
|
-
r"or": (lambda a, b: bool(a or b), 1),
|
|
95
101
|
r"|": (lambda a, b: a | b, 1),
|
|
96
|
-
r"in": (lambda a, b: a in b, 4),
|
|
97
|
-
r"not": (lambda a: not a, 3),
|
|
98
102
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
dshell_operators: dict[str, tuple[Callable, int]] = dshell_logical_operators.copy()
|
|
106
|
+
dshell_operators.update(dshell_logical_word_operators)
|
|
102
107
|
dshell_operators.update(dshell_mathematical_operators)
|
|
103
108
|
|
|
104
109
|
'''
|
|
@@ -26,7 +26,8 @@ table_regex: dict[DTT, Pattern] = {
|
|
|
26
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
|
-
DTT.LOGIC_OPERATOR: compile(rf"(
|
|
29
|
+
DTT.LOGIC_OPERATOR: compile(rf"({'|'.join([escape(i) for i in dshell_logical_operators.keys()])})"),
|
|
30
|
+
DTT.LOGIC_WORD_OPERATOR: compile(rf"({'|'.join([escape(i) for i in dshell_logical_word_operators.keys()])})"),
|
|
30
31
|
DTT.FLOAT: compile(r"(\d+\.\d+)"),
|
|
31
32
|
DTT.INT: compile(r"(\d+)"),
|
|
32
33
|
DTT.BOOL: compile(r"(True|False)", flags=IGNORECASE),
|
|
@@ -7,16 +7,16 @@ Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=SvX9I4nYMWm8ACE56QJBM5yEiZoXIKb
|
|
|
7
7
|
Dshell/DISCORD_COMMANDS/dshell_pastbin.py,sha256=TkWFGRRTvhhJgvwkDFx9Fz4UM2UUFwxyq0laMVx0mUk,881
|
|
8
8
|
Dshell/DISCORD_COMMANDS/dshell_role.py,sha256=fotsYWGHebgIx157q-zRbcCd90Y7jIuKCZ8udQoEzSU,4970
|
|
9
9
|
Dshell/_DshellInterpreteur/__init__.py,sha256=xy5-J-R3YmY99JF3NBHTRRLsComFxpjnCA5xacISctU,35
|
|
10
|
-
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=
|
|
10
|
+
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=sYQ9qIVjRedwkfITEeVAFN0RdHjiY7RGO6z0j4D7eno,23072
|
|
11
11
|
Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
|
|
12
12
|
Dshell/_DshellParser/ast_nodes.py,sha256=2qwL_M0ELPia6L6gqwgV5hqprvyuo97cx3Zk2dVz09U,15341
|
|
13
|
-
Dshell/_DshellParser/dshell_parser.py,sha256=
|
|
13
|
+
Dshell/_DshellParser/dshell_parser.py,sha256=RxS5GgmTel10pH9HII0X_8XZnVyIQGd9ThZZcZDpEqc,15545
|
|
14
14
|
Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
|
|
15
|
-
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=
|
|
16
|
-
Dshell/_DshellTokenizer/dshell_token_type.py,sha256=
|
|
17
|
-
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256
|
|
18
|
-
dshellinterpreter-0.2.
|
|
19
|
-
dshellinterpreter-0.2.
|
|
20
|
-
dshellinterpreter-0.2.
|
|
21
|
-
dshellinterpreter-0.2.
|
|
22
|
-
dshellinterpreter-0.2.
|
|
15
|
+
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=l8PZhSXLhFHpi8RRoBRm2NRvAyA_NoONw0vRU4bw3t0,5058
|
|
16
|
+
Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
|
|
17
|
+
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=3KZhysONhgFmB7olDEZh-fvLwpai1_Asbqu0IO2p400,7134
|
|
18
|
+
dshellinterpreter-0.2.8.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
|
19
|
+
dshellinterpreter-0.2.8.dist-info/METADATA,sha256=EXwmP5l2xkbC-eernwlaTW5hzUiEXGRMLyGBUo9cMWY,1120
|
|
20
|
+
dshellinterpreter-0.2.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
21
|
+
dshellinterpreter-0.2.8.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
|
|
22
|
+
dshellinterpreter-0.2.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|