minecraft-datapack-language 16.0.26__py3-none-any.whl → 16.0.28__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.
- minecraft_datapack_language/_version.py +2 -2
- minecraft_datapack_language/mdl_compiler.py +14 -5
- minecraft_datapack_language/mdl_parser.py +30 -28
- {minecraft_datapack_language-16.0.26.dist-info → minecraft_datapack_language-16.0.28.dist-info}/METADATA +1 -1
- {minecraft_datapack_language-16.0.26.dist-info → minecraft_datapack_language-16.0.28.dist-info}/RECORD +9 -9
- {minecraft_datapack_language-16.0.26.dist-info → minecraft_datapack_language-16.0.28.dist-info}/WHEEL +0 -0
- {minecraft_datapack_language-16.0.26.dist-info → minecraft_datapack_language-16.0.28.dist-info}/entry_points.txt +0 -0
- {minecraft_datapack_language-16.0.26.dist-info → minecraft_datapack_language-16.0.28.dist-info}/licenses/LICENSE +0 -0
- {minecraft_datapack_language-16.0.26.dist-info → minecraft_datapack_language-16.0.28.dist-info}/top_level.txt +0 -0
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
28
28
|
commit_id: COMMIT_ID
|
29
29
|
__commit_id__: COMMIT_ID
|
30
30
|
|
31
|
-
__version__ = version = '16.0.
|
32
|
-
__version_tuple__ = version_tuple = (16, 0,
|
31
|
+
__version__ = version = '16.0.28'
|
32
|
+
__version_tuple__ = version_tuple = (16, 0, 28)
|
33
33
|
|
34
34
|
__commit_id__ = commit_id = None
|
@@ -463,10 +463,15 @@ class MDLCompiler:
|
|
463
463
|
current_pos = 0
|
464
464
|
|
465
465
|
for var in variables:
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
466
|
+
# Support both $name<scope>$ and $name$ forms; parser already defaults scope to <@s>
|
467
|
+
with_scope = f"${var.name}{var.scope}$"
|
468
|
+
no_scope = f"${var.name}$"
|
469
|
+
pos_with = message.find(with_scope, current_pos)
|
470
|
+
pos_no = message.find(no_scope, current_pos)
|
471
|
+
# Choose the earliest valid occurrence >= current_pos
|
472
|
+
candidates = [p for p in [pos_with, pos_no] if p != -1]
|
473
|
+
if candidates:
|
474
|
+
var_pos = min(candidates)
|
470
475
|
if var_pos > current_pos:
|
471
476
|
text_before = message[current_pos:var_pos]
|
472
477
|
parts.append(f'{{"text":"{text_before}"}}')
|
@@ -475,7 +480,11 @@ class MDLCompiler:
|
|
475
480
|
scope = self._resolve_scope(var.scope)
|
476
481
|
parts.append(f'{{"score":{{"name":"{scope}","objective":"{objective}"}}}}')
|
477
482
|
|
478
|
-
|
483
|
+
# Advance past whichever token we matched
|
484
|
+
if var_pos == pos_with:
|
485
|
+
current_pos = var_pos + len(with_scope)
|
486
|
+
else:
|
487
|
+
current_pos = var_pos + len(no_scope)
|
479
488
|
|
480
489
|
if current_pos < len(message):
|
481
490
|
text_after = message[current_pos:]
|
@@ -181,14 +181,17 @@ class MDLParser:
|
|
181
181
|
"Use: recipe, loot_table, advancement, item_modifier, predicate, or structure")
|
182
182
|
|
183
183
|
def _parse_variable_declaration(self) -> VariableDeclaration:
|
184
|
-
"""Parse variable declaration: var num name<scope
|
184
|
+
"""Parse variable declaration: var num name<scope?> = value; defaults to <@s>."""
|
185
185
|
self._expect(TokenType.VAR, "Expected 'var' keyword")
|
186
186
|
|
187
187
|
self._expect(TokenType.NUM, "Expected 'num' keyword")
|
188
188
|
|
189
189
|
name = self._expect_identifier("Expected variable name")
|
190
|
-
|
191
|
-
|
190
|
+
# Optional scope selector; default to <@s>
|
191
|
+
if self._peek().type == TokenType.LANGLE:
|
192
|
+
scope = self._parse_scope_selector()
|
193
|
+
else:
|
194
|
+
scope = "<@s>"
|
192
195
|
|
193
196
|
self._expect(TokenType.ASSIGN, "Expected '=' after variable declaration")
|
194
197
|
|
@@ -204,10 +207,14 @@ class MDLParser:
|
|
204
207
|
)
|
205
208
|
|
206
209
|
def _parse_variable_assignment(self) -> VariableAssignment:
|
207
|
-
"""Parse variable assignment: name<scope
|
210
|
+
"""Parse variable assignment: name<scope?> = value; defaults to <@s>."""
|
208
211
|
name = self._expect_identifier("Expected variable name")
|
209
212
|
|
210
|
-
scope
|
213
|
+
# Optional scope selector; default to <@s>
|
214
|
+
if self._peek().type == TokenType.LANGLE:
|
215
|
+
scope = self._parse_scope_selector()
|
216
|
+
else:
|
217
|
+
scope = "<@s>"
|
211
218
|
|
212
219
|
self._expect(TokenType.ASSIGN, "Expected '=' after variable name")
|
213
220
|
|
@@ -423,17 +430,12 @@ class MDLParser:
|
|
423
430
|
|
424
431
|
# Extract variables from the message content
|
425
432
|
variables = []
|
426
|
-
#
|
433
|
+
# Support both $var<scope>$ and $var$
|
427
434
|
import re
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
# Parse the variable name and scope from the match
|
433
|
-
if '<' in match and '>' in match:
|
434
|
-
name = match[:match.index('<')]
|
435
|
-
scope = match[match.index('<'):match.index('>')+1]
|
436
|
-
variables.append(VariableSubstitution(name=name, scope=scope))
|
435
|
+
for m in re.finditer(r'\$([a-zA-Z_][a-zA-Z0-9_]*)(<[^>]+>)?\$', message):
|
436
|
+
name = m.group(1)
|
437
|
+
scope = m.group(2) if m.group(2) else "<@s>"
|
438
|
+
variables.append(VariableSubstitution(name=name, scope=scope))
|
437
439
|
|
438
440
|
self._expect(TokenType.QUOTE, "Expected closing quote for say message")
|
439
441
|
self._expect(TokenType.SEMICOLON, "Expected semicolon after say command")
|
@@ -441,23 +443,23 @@ class MDLParser:
|
|
441
443
|
return SayCommand(message=message, variables=variables)
|
442
444
|
|
443
445
|
def _parse_variable_substitution(self) -> VariableSubstitution:
|
444
|
-
"""Parse variable substitution: $variable<scope
|
446
|
+
"""Parse variable substitution: $variable<scope?>$; defaults to <@s>."""
|
445
447
|
self._expect(TokenType.DOLLAR, "Expected '$' to start variable substitution")
|
446
448
|
|
447
449
|
name = self._expect_identifier("Expected variable name")
|
448
450
|
|
449
|
-
#
|
450
|
-
self.
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
451
|
+
# Optional scope selector; if absent, default to <@s>
|
452
|
+
if self._peek().type == TokenType.LANGLE:
|
453
|
+
# Parse the selector content
|
454
|
+
self._advance() # consume '<'
|
455
|
+
selector_content = ""
|
456
|
+
while not self._is_at_end() and self._peek().type != TokenType.RANGLE:
|
457
|
+
selector_content += self._peek().value
|
458
|
+
self._advance()
|
459
|
+
self._expect(TokenType.RANGLE, "Expected '>' to close scope selector")
|
460
|
+
scope = f"<{selector_content}>"
|
461
|
+
else:
|
462
|
+
scope = "<@s>"
|
461
463
|
|
462
464
|
self._expect(TokenType.DOLLAR, "Expected '$' to end variable substitution")
|
463
465
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: minecraft-datapack-language
|
3
|
-
Version: 16.0.
|
3
|
+
Version: 16.0.28
|
4
4
|
Summary: Compile MDL language with explicit scoping into a Minecraft datapack (1.21+ ready). Features variables, control flow, error handling, and VS Code extension.
|
5
5
|
Project-URL: Homepage, https://www.mcmdl.com
|
6
6
|
Project-URL: Documentation, https://www.mcmdl.com/docs
|
@@ -1,18 +1,18 @@
|
|
1
1
|
minecraft_datapack_language/__init__.py,sha256=0KVXBE4ScRaRUrf83aA2tVB-y8A_jplyaxVvtHH6Uw0,1199
|
2
|
-
minecraft_datapack_language/_version.py,sha256=
|
2
|
+
minecraft_datapack_language/_version.py,sha256=bmhcpRqKLNV6g-1OUDfz8QiS6wYJ0UpSeaB-Hc5O-uA,708
|
3
3
|
minecraft_datapack_language/ast_nodes.py,sha256=L5izavSeXDr766vsfRvJrcnflXNJyXcy0WSfyJPq2ZA,4484
|
4
4
|
minecraft_datapack_language/cli.py,sha256=shmQtNNXgw5XNlGquAR52wWtYeNyYusZTwwCZl56mMU,9522
|
5
5
|
minecraft_datapack_language/dir_map.py,sha256=HmxFkuvWGkzHF8o_GFb4BpuMCRc6QMw8UbmcAI8JVdY,1788
|
6
|
-
minecraft_datapack_language/mdl_compiler.py,sha256=
|
6
|
+
minecraft_datapack_language/mdl_compiler.py,sha256=Cs3fXtIAG4_Johp7h3BeYOs9RNUogkvYsR8Dvt7Ek1E,70720
|
7
7
|
minecraft_datapack_language/mdl_errors.py,sha256=r0Gu3KhoX1YLPAVW_iO7Q_fPgaf_Dv9tOGSOdKNSzmw,16114
|
8
8
|
minecraft_datapack_language/mdl_lexer.py,sha256=YuRflOkoMOcjECPAZzoAkJciMks5amWMtGbcTIVKmAs,24166
|
9
9
|
minecraft_datapack_language/mdl_linter.py,sha256=z85xoAglENurCh30bR7kEHZ_JeMxcYaLDcGNRAl-RAI,17253
|
10
|
-
minecraft_datapack_language/mdl_parser.py,sha256=
|
10
|
+
minecraft_datapack_language/mdl_parser.py,sha256=1ecbkzvkgwcjfF8tn6Hxg4jBIjyFlk4bCzJ46p0-JR0,27477
|
11
11
|
minecraft_datapack_language/python_api.py,sha256=Iao1jbdeW6ekeA80BZG6gNqHVjxQJEheB3DbpVsuTZQ,12304
|
12
12
|
minecraft_datapack_language/utils.py,sha256=Aq0HAGlXqj9BUTEjaEilpvzEW0EtZYYMMwOqG9db6dE,684
|
13
|
-
minecraft_datapack_language-16.0.
|
14
|
-
minecraft_datapack_language-16.0.
|
15
|
-
minecraft_datapack_language-16.0.
|
16
|
-
minecraft_datapack_language-16.0.
|
17
|
-
minecraft_datapack_language-16.0.
|
18
|
-
minecraft_datapack_language-16.0.
|
13
|
+
minecraft_datapack_language-16.0.28.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
14
|
+
minecraft_datapack_language-16.0.28.dist-info/METADATA,sha256=1EihqA4rlANyoQN2_i-XMQNtsSwNGvdsPVunVG4WA6A,8344
|
15
|
+
minecraft_datapack_language-16.0.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
16
|
+
minecraft_datapack_language-16.0.28.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
|
17
|
+
minecraft_datapack_language-16.0.28.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
|
18
|
+
minecraft_datapack_language-16.0.28.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|