minecraft-datapack-language 16.0.13__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.13'
32
- __version_tuple__ = version_tuple = (16, 0, 13)
31
+ __version__ = version = '16.0.14'
32
+ __version_tuple__ = version_tuple = (16, 0, 14)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -835,12 +835,49 @@ class MDLCompiler:
835
835
  # Default: generic expression string, no inversion
836
836
  invert_then = False
837
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
+
838
875
  if isinstance(expression, BinaryExpression):
839
- left = expression.left
840
- right = expression.right
841
- op = expression.operator
876
+ left = unwrap(expression.left)
877
+ right = unwrap(expression.right)
878
+ op_sym = norm_op(expression.operator)
842
879
  # Variable vs literal
843
- 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)):
844
881
  objective = self.variables.get(left.name, left.name)
845
882
  scope = left.scope.strip("<>")
846
883
  # Normalize number
@@ -850,41 +887,47 @@ class MDLCompiler:
850
887
  v = None
851
888
  if v is not None:
852
889
  n = int(v) if float(v).is_integer() else v
853
- if op == TokenType.GREATER:
890
+ if op_sym == ">":
854
891
  rng = f"{int(n)+1}.." if isinstance(n, int) else f"{v+1}.."
855
892
  return (f"score {scope} {objective} matches {rng}", False)
856
- if op == TokenType.GREATER_EQUAL:
893
+ if op_sym == ">=":
857
894
  rng = f"{int(n)}.."
858
895
  return (f"score {scope} {objective} matches {rng}", False)
859
- if op == TokenType.LESS:
896
+ if op_sym == "<":
860
897
  rng = f"..{int(n)-1}"
861
898
  return (f"score {scope} {objective} matches {rng}", False)
862
- if op == TokenType.LESS_EQUAL:
899
+ if op_sym == "<=":
863
900
  rng = f"..{int(n)}"
864
901
  return (f"score {scope} {objective} matches {rng}", False)
865
- if op == TokenType.EQUAL:
902
+ if op_sym == "==":
866
903
  rng = f"{int(n)}"
867
904
  return (f"score {scope} {objective} matches {rng}", False)
868
- if op == TokenType.NOT_EQUAL:
905
+ if op_sym == "!=":
869
906
  rng = f"{int(n)}"
870
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)
871
921
  # Variable vs variable
872
- if isinstance(left, VariableSubstitution) and isinstance(right, VariableSubstitution):
922
+ if op_sym and isinstance(left, VariableSubstitution) and isinstance(right, VariableSubstitution):
873
923
  lobj = self.variables.get(left.name, left.name)
874
924
  lscope = left.scope.strip("<>")
875
925
  robj = self.variables.get(right.name, right.name)
876
926
  rscope = right.scope.strip("<>")
877
- if op in (TokenType.GREATER, TokenType.GREATER_EQUAL, TokenType.LESS, TokenType.LESS_EQUAL, TokenType.EQUAL):
878
- comp_map = {
879
- TokenType.GREATER: ">",
880
- TokenType.GREATER_EQUAL: ">=",
881
- TokenType.LESS: "<",
882
- TokenType.LESS_EQUAL: "<=",
883
- TokenType.EQUAL: "="
884
- }
885
- comp = comp_map[op]
927
+ if op_sym in (">", ">=", "<", "<=", "=="):
928
+ comp = op_sym if op_sym != "==" else "="
886
929
  return (f"score {lscope} {lobj} {comp} {rscope} {robj}", False)
887
- if op == TokenType.NOT_EQUAL:
930
+ if op_sym == "!=":
888
931
  # Use equals with inversion
889
932
  return (f"score {lscope} {lobj} = {rscope} {robj}", True)
890
933
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: minecraft-datapack-language
3
- Version: 16.0.13
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=zPid2C66t3qy7IALtBamczEZhSi2TvHUc9FEEgCFwOc,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=-ZwjHgJ8jJej8iiMovkbE8ry0aiLmXHc5rJ5Agj3Ep4,52293
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
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.13.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
14
- minecraft_datapack_language-16.0.13.dist-info/METADATA,sha256=0JbN_CstF60oTN4ypgfcq1JbLE0Q2nO3dcL_NWfioS8,8344
15
- minecraft_datapack_language-16.0.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- minecraft_datapack_language-16.0.13.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
17
- minecraft_datapack_language-16.0.13.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
18
- minecraft_datapack_language-16.0.13.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,,