minecraft-datapack-language 16.0.12__py3-none-any.whl → 16.0.14__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.12'
32
- __version_tuple__ = version_tuple = (16, 0, 12)
31
+ __version__ = version = '16.0.14'
32
+ __version_tuple__ = version_tuple = (16, 0, 14)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -187,7 +187,10 @@ class MDLCompiler:
187
187
  if macro_re.search(line):
188
188
  stripped = line.lstrip()
189
189
  if not stripped.startswith('$'):
190
- return '$' + line
190
+ # Insert '$' immediately after indentation so there is no space after '$'
191
+ leading_ws_len = len(line) - len(stripped)
192
+ leading_ws = line[:leading_ws_len]
193
+ return f"{leading_ws}${stripped}"
191
194
  return line
192
195
  if '\n' in text:
193
196
  return '\n'.join(process_line(ln) for ln in text.split('\n'))
@@ -832,12 +835,49 @@ class MDLCompiler:
832
835
  # Default: generic expression string, no inversion
833
836
  invert_then = False
834
837
 
838
+ # Helpers local to this method to keep concerns contained
839
+ def unwrap(e: Any) -> Any:
840
+ while isinstance(e, ParenthesizedExpression):
841
+ e = e.expression
842
+ return e
843
+
844
+ def norm_op(op_in: Any) -> Optional[str]:
845
+ # Return one of: '>', '>=', '<', '<=', '==', '!=' or None
846
+ if op_in == TokenType.GREATER or op_in == ">":
847
+ return ">"
848
+ if op_in == TokenType.GREATER_EQUAL or op_in == ">=":
849
+ return ">="
850
+ if op_in == TokenType.LESS or op_in == "<":
851
+ return "<"
852
+ if op_in == TokenType.LESS_EQUAL or op_in == "<=":
853
+ return "<="
854
+ if op_in == TokenType.EQUAL or op_in == "==" or op_in == "EQUAL":
855
+ return "=="
856
+ if op_in == TokenType.NOT_EQUAL or op_in == "!=" or op_in == "NOT_EQUAL":
857
+ return "!="
858
+ # Accept python bindings string names as well
859
+ if isinstance(op_in, str):
860
+ upper = op_in.upper()
861
+ if upper == "GREATER":
862
+ return ">"
863
+ if upper == "GREATER_EQUAL":
864
+ return ">="
865
+ if upper == "LESS":
866
+ return "<"
867
+ if upper == "LESS_EQUAL":
868
+ return "<="
869
+ if upper == "EQUAL":
870
+ return "=="
871
+ if upper == "NOT_EQUAL":
872
+ return "!="
873
+ return None
874
+
835
875
  if isinstance(expression, BinaryExpression):
836
- left = expression.left
837
- right = expression.right
838
- op = expression.operator
876
+ left = unwrap(expression.left)
877
+ right = unwrap(expression.right)
878
+ op_sym = norm_op(expression.operator)
839
879
  # Variable vs literal
840
- if isinstance(left, VariableSubstitution) and isinstance(right, LiteralExpression) and isinstance(right.value, (int, float)):
880
+ if op_sym and isinstance(left, VariableSubstitution) and isinstance(right, LiteralExpression) and isinstance(right.value, (int, float)):
841
881
  objective = self.variables.get(left.name, left.name)
842
882
  scope = left.scope.strip("<>")
843
883
  # Normalize number
@@ -847,41 +887,47 @@ class MDLCompiler:
847
887
  v = None
848
888
  if v is not None:
849
889
  n = int(v) if float(v).is_integer() else v
850
- if op == TokenType.GREATER:
890
+ if op_sym == ">":
851
891
  rng = f"{int(n)+1}.." if isinstance(n, int) else f"{v+1}.."
852
892
  return (f"score {scope} {objective} matches {rng}", False)
853
- if op == TokenType.GREATER_EQUAL:
893
+ if op_sym == ">=":
854
894
  rng = f"{int(n)}.."
855
895
  return (f"score {scope} {objective} matches {rng}", False)
856
- if op == TokenType.LESS:
896
+ if op_sym == "<":
857
897
  rng = f"..{int(n)-1}"
858
898
  return (f"score {scope} {objective} matches {rng}", False)
859
- if op == TokenType.LESS_EQUAL:
899
+ if op_sym == "<=":
860
900
  rng = f"..{int(n)}"
861
901
  return (f"score {scope} {objective} matches {rng}", False)
862
- if op == TokenType.EQUAL:
902
+ if op_sym == "==":
863
903
  rng = f"{int(n)}"
864
904
  return (f"score {scope} {objective} matches {rng}", False)
865
- if op == TokenType.NOT_EQUAL:
905
+ if op_sym == "!=":
866
906
  rng = f"{int(n)}"
867
907
  return (f"score {scope} {objective} matches {rng}", True)
908
+ # Literal vs variable (swap sides)
909
+ if op_sym and isinstance(left, LiteralExpression) and isinstance(left.value, (int, float)) and isinstance(right, VariableSubstitution):
910
+ # Swap by inverting the operator appropriately, then reuse logic
911
+ invert_map = {
912
+ ">": "<",
913
+ ">=": "<=",
914
+ "<": ">",
915
+ "<=": ">=",
916
+ "==": "==",
917
+ "!=": "!="
918
+ }
919
+ swapped = BinaryExpression(left=right, operator=invert_map.get(op_sym, op_sym), right=left)
920
+ return self._build_condition(swapped)
868
921
  # Variable vs variable
869
- if isinstance(left, VariableSubstitution) and isinstance(right, VariableSubstitution):
922
+ if op_sym and isinstance(left, VariableSubstitution) and isinstance(right, VariableSubstitution):
870
923
  lobj = self.variables.get(left.name, left.name)
871
924
  lscope = left.scope.strip("<>")
872
925
  robj = self.variables.get(right.name, right.name)
873
926
  rscope = right.scope.strip("<>")
874
- if op in (TokenType.GREATER, TokenType.GREATER_EQUAL, TokenType.LESS, TokenType.LESS_EQUAL, TokenType.EQUAL):
875
- comp_map = {
876
- TokenType.GREATER: ">",
877
- TokenType.GREATER_EQUAL: ">=",
878
- TokenType.LESS: "<",
879
- TokenType.LESS_EQUAL: "<=",
880
- TokenType.EQUAL: "="
881
- }
882
- comp = comp_map[op]
927
+ if op_sym in (">", ">=", "<", "<=", "=="):
928
+ comp = op_sym if op_sym != "==" else "="
883
929
  return (f"score {lscope} {lobj} {comp} {rscope} {robj}", False)
884
- if op == TokenType.NOT_EQUAL:
930
+ if op_sym == "!=":
885
931
  # Use equals with inversion
886
932
  return (f"score {lscope} {lobj} = {rscope} {robj}", True)
887
933
 
@@ -357,6 +357,14 @@ class MDLLexer:
357
357
  if (self.source[self.current:self.current + 5] == 'raw!$'):
358
358
  # Found the end marker - extract the content
359
359
  raw_content = self.source[content_start:self.current]
360
+ # Trim leading/trailing whitespace on each line within the raw block
361
+ try:
362
+ lines = raw_content.split('\n')
363
+ trimmed_lines = [ln.strip() for ln in lines]
364
+ raw_content = '\n'.join(trimmed_lines)
365
+ except Exception:
366
+ # If anything goes wrong, fall back to original content
367
+ pass
360
368
 
361
369
  # Generate a single RAW_CONTENT token with all the content
362
370
  self.tokens.append(Token(TokenType.RAW_CONTENT, raw_content, self.line, self.column))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: minecraft-datapack-language
3
- Version: 16.0.12
3
+ Version: 16.0.14
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=qcI2Mkb_Pla9x345XpE8wo3tbrWbgeMISZVSqOvyEo8,708
2
+ minecraft_datapack_language/_version.py,sha256=gzXobEdwW19w9dKSP9heKx935VDlTBc_KDRK74zvMvY,708
3
3
  minecraft_datapack_language/ast_nodes.py,sha256=L5izavSeXDr766vsfRvJrcnflXNJyXcy0WSfyJPq2ZA,4484
4
4
  minecraft_datapack_language/cli.py,sha256=R4QZYtox-Da9B8pr_kCg_9qc9aI-ORTah7kMkhsI5tw,10373
5
5
  minecraft_datapack_language/dir_map.py,sha256=HmxFkuvWGkzHF8o_GFb4BpuMCRc6QMw8UbmcAI8JVdY,1788
6
- minecraft_datapack_language/mdl_compiler.py,sha256=mgw3tscpAYtAuhiCsMGQgFy03KVHUt6OWIk4xQf12IU,52065
6
+ minecraft_datapack_language/mdl_compiler.py,sha256=XnwT2M6-qVLPSh36BNOnUNpODQYlMegRTFycIEqjrSk,54097
7
7
  minecraft_datapack_language/mdl_errors.py,sha256=r0Gu3KhoX1YLPAVW_iO7Q_fPgaf_Dv9tOGSOdKNSzmw,16114
8
- minecraft_datapack_language/mdl_lexer.py,sha256=rfsW2QNcZxa9HAHpU9HFReshQSmjOrrK6xY_r43mKFk,23485
8
+ minecraft_datapack_language/mdl_lexer.py,sha256=bDzAj39-kfnX0uVlYQg1oQ7YDb-JO9UZx8jbODQqg6E,23902
9
9
  minecraft_datapack_language/mdl_linter.py,sha256=z85xoAglENurCh30bR7kEHZ_JeMxcYaLDcGNRAl-RAI,17253
10
10
  minecraft_datapack_language/mdl_parser.py,sha256=Krk7Y_E9OKNCcsDOCT7ATvQLbJII951AU2qzEY00GLE,26068
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.12.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
14
- minecraft_datapack_language-16.0.12.dist-info/METADATA,sha256=ub5-kid2nQqJIWlv7VGeG6vsQkXwi0O7qkN1zaSG6e8,8344
15
- minecraft_datapack_language-16.0.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- minecraft_datapack_language-16.0.12.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
17
- minecraft_datapack_language-16.0.12.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
18
- minecraft_datapack_language-16.0.12.dist-info/RECORD,,
13
+ minecraft_datapack_language-16.0.14.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
14
+ minecraft_datapack_language-16.0.14.dist-info/METADATA,sha256=ea-Agrnwv9H6nt-UrkHVdeTIh0fNOhGhKGAhDqgibSs,8344
15
+ minecraft_datapack_language-16.0.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ minecraft_datapack_language-16.0.14.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
17
+ minecraft_datapack_language-16.0.14.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
18
+ minecraft_datapack_language-16.0.14.dist-info/RECORD,,