minecraft-datapack-language 16.0.25__py3-none-any.whl → 16.0.27__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.
@@ -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.25'
32
- __version_tuple__ = version_tuple = (16, 0, 25)
31
+ __version__ = version = '16.0.27'
32
+ __version_tuple__ = version_tuple = (16, 0, 27)
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
- var_pattern = f"${var.name}{var.scope}$"
467
- var_pos = message.find(var_pattern, current_pos)
468
-
469
- if var_pos != -1:
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
- current_pos = var_pos + len(var_pattern)
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> = value;"""
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
- scope = self._parse_scope_selector()
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> = value;"""
210
+ """Parse variable assignment: name<scope?> = value; defaults to <@s>."""
208
211
  name = self._expect_identifier("Expected variable name")
209
212
 
210
- scope = self._parse_scope_selector()
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
- # Simple regex-like extraction of $variable<scope>$ patterns
433
+ # Support both $var<scope>$ and $var$
427
434
  import re
428
- var_pattern = r'\$([a-zA-Z_][a-zA-Z0-9_]*<[^>]+>)\$'
429
- matches = re.findall(var_pattern, message)
430
-
431
- for match in matches:
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
- # For variable substitutions, use LANGLE/RANGLE
450
- self._expect(TokenType.LANGLE, "Expected '<' for scope selector")
451
-
452
- # Parse the selector content
453
- selector_content = ""
454
- while not self._is_at_end() and self._peek().type != TokenType.RANGLE:
455
- selector_content += self._peek().value
456
- self._advance()
457
-
458
- self._expect(TokenType.RANGLE, "Expected '>' to close scope selector")
459
-
460
- scope = f"<{selector_content}>"
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.25
3
+ Version: 16.0.27
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=FBXSAywC2BN2llzA1TA3jz0AgS4-JqxTSCNdM9ODWTU,708
2
+ minecraft_datapack_language/_version.py,sha256=qKbKZwUR9bB7C77PJEdMS03qTO2ZDLkSYCAXHhoVYgo,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=DRE6du7JRScZo8NRIGN9hF0CkDPeHspsKaYXNL8ZPRc,70187
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=vIcPRudxDaezNy85Q5CBcumLhCglofCNITsrRmj9YWw,27302
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.25.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
14
- minecraft_datapack_language-16.0.25.dist-info/METADATA,sha256=ISJm9-FcwnBqhJtKzETtxKsvGQY3k4sgX1QqFCFToA4,8344
15
- minecraft_datapack_language-16.0.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- minecraft_datapack_language-16.0.25.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
17
- minecraft_datapack_language-16.0.25.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
18
- minecraft_datapack_language-16.0.25.dist-info/RECORD,,
13
+ minecraft_datapack_language-16.0.27.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
14
+ minecraft_datapack_language-16.0.27.dist-info/METADATA,sha256=pTVTghBG9RekfmcPUQj6FU0HbNj8514gsd9mJaXW5UI,8344
15
+ minecraft_datapack_language-16.0.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ minecraft_datapack_language-16.0.27.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
17
+ minecraft_datapack_language-16.0.27.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
18
+ minecraft_datapack_language-16.0.27.dist-info/RECORD,,