json-model-compiler 2.0.60__tar.gz → 2.0.61__tar.gz

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.
Files changed (132) hide show
  1. {json_model_compiler-2.0.60/json_model_compiler.egg-info → json_model_compiler-2.0.61}/PKG-INFO +1 -1
  2. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/VERSION.md +5 -0
  3. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/analyze.py +9 -3
  4. json_model_compiler-2.0.61/json_model/data/VERSION +1 -0
  5. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/jmc.pod +4 -0
  6. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/irep.py +20 -2
  7. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/script.py +23 -16
  8. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61/json_model_compiler.egg-info}/PKG-INFO +1 -1
  9. json_model_compiler-2.0.60/json_model/data/VERSION +0 -1
  10. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/.github/workflows/docs.yml +0 -0
  11. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/.github/workflows/sanity.yml +0 -0
  12. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/.gitignore +0 -0
  13. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/.gitmodules +0 -0
  14. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/API.md +0 -0
  15. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/BACKLOG.md +0 -0
  16. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/BENCH.md +0 -0
  17. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/DESIGN.md +0 -0
  18. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/DEV.md +0 -0
  19. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/DOC.md +0 -0
  20. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/HOWTO.md +0 -0
  21. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/INTEGRATION.md +0 -0
  22. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/MANIFEST.in +0 -0
  23. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/Makefile +3 -3
  24. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/PUBS.md +0 -0
  25. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/README.md +0 -0
  26. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/SPEC.md +0 -0
  27. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/TUTO.md +0 -0
  28. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/about.sh +0 -0
  29. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/bench.sh +0 -0
  30. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/README.md +0 -0
  31. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/__init__.py +0 -0
  32. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/clang.py +0 -0
  33. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/convert.py +0 -0
  34. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/clang_entry.c +0 -0
  35. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/clang_free.c +0 -0
  36. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/clang_init.c +0 -0
  37. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/clang_pcre2_fun.c +0 -0
  38. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/clang_re2_fun.c +0 -0
  39. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/java_free.java +0 -0
  40. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/java_init.java +0 -0
  41. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/javascript_exe.js +0 -0
  42. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/javascript_foot.js +0 -0
  43. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/javascript_free.js +0 -0
  44. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/javascript_head.js +0 -0
  45. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/javascript_init.js +0 -0
  46. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/javascript_main.js +0 -0
  47. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/perl_entry.pl +0 -0
  48. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/perl_exe.pl +0 -0
  49. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/perl_free.pl +0 -0
  50. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/perl_init.pl +0 -0
  51. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/perl_main.pl +0 -0
  52. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/perl_pkg.pl +0 -0
  53. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/plpgsql_entry.sql +0 -0
  54. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/python_entry.py +0 -0
  55. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/python_exe.py +0 -0
  56. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/python_free.py +0 -0
  57. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/python_init.py +0 -0
  58. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/data/python_main.py +0 -0
  59. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/export.py +0 -0
  60. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/java.py +0 -0
  61. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/javascript.py +0 -0
  62. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/language.py +0 -0
  63. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/model.py +0 -0
  64. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/mtypes.py +0 -0
  65. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/objops.py +0 -0
  66. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/optim.py +0 -0
  67. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/perl.py +0 -0
  68. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/plpgsql.py +0 -0
  69. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/predefs.py +0 -0
  70. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/python.py +0 -0
  71. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/recurse.py +0 -0
  72. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/regex.py +0 -0
  73. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/resolver.py +0 -0
  74. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/Makefile +0 -0
  75. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/__init__.py +0 -0
  76. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/c/Makefile +0 -0
  77. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/c/json-model.c +0 -0
  78. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/c/json-model.h +0 -0
  79. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/c/main.c +0 -0
  80. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/.gitignore +0 -0
  81. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/Makefile +0 -0
  82. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/README.md +0 -0
  83. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/env.sh +0 -0
  84. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Checker.java +0 -0
  85. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/GSON.java +0 -0
  86. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/JSON.java +0 -0
  87. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/JSONP.java +0 -0
  88. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Jackson.java +0 -0
  89. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Main.java +0 -0
  90. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/ModelChecker.java +0 -0
  91. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Path.java +0 -0
  92. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Report.java +0 -0
  93. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Runtime.java +0 -0
  94. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/java/pom.xml +0 -0
  95. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/js/README.md +0 -0
  96. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/js/index.js +0 -0
  97. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/js/main.js +0 -0
  98. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/js/package.json +0 -0
  99. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/.gitignore +0 -0
  100. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/Changes +0 -0
  101. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/LICENSE +0 -0
  102. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/MANIFEST +0 -0
  103. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/Makefile.PL +0 -0
  104. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/README +0 -0
  105. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/env.sh +0 -0
  106. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/ignore.txt +0 -0
  107. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/lib/JSON/JsonModel.pm +0 -0
  108. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/t/00-load.t +0 -0
  109. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/t/manifest.t +0 -0
  110. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/t/pod-coverage.t +0 -0
  111. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/t/pod.t +0 -0
  112. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/pl/xt/boilerplate.t +0 -0
  113. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/sql/META.json +0 -0
  114. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/sql/Makefile +0 -0
  115. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/sql/json_model--2.0.sql +0 -0
  116. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/sql/json_model.control +0 -0
  117. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/support.py +0 -0
  118. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/runtime/types.py +0 -0
  119. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/submodel.py +0 -0
  120. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/ts_export.py +0 -0
  121. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/url_cache.py +0 -0
  122. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/utils.py +0 -0
  123. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model/xstatic.py +0 -0
  124. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/SOURCES.txt +0 -0
  125. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/dependency_links.txt +0 -0
  126. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/entry_points.txt +0 -0
  127. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/not-zip-safe +0 -0
  128. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/requires.txt +0 -0
  129. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/top_level.txt +0 -0
  130. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/package.json +0 -0
  131. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/pyproject.toml +0 -0
  132. {json_model_compiler-2.0.60 → json_model_compiler-2.0.61}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json_model_compiler
3
- Version: 2.0.60
3
+ Version: 2.0.61
4
4
  Summary: JSON Model Tools
5
5
  Author: Fabien Coelho, Claire Yannou-Medrala
6
6
  License-Expression: CC0-1.0
@@ -1,5 +1,10 @@
1
1
  # JSON Model Compiler Versions
2
2
 
3
+ ## 2.0.61 on 2026-09-18
4
+
5
+ - ir: ensure that a nope is kept when optimizing sequences
6
+ - front: allow to accept all-caps definitions with `--no-caps`
7
+
3
8
  ## 2.0.60 on 2026-09-15
4
9
 
5
10
  - pr: jm site added to [awesome docsify](https://github.com/docsifyjs/awesome-docsify/commit/3950ece64978f41294463e1a2b12e809c65a6379)
@@ -65,7 +65,12 @@ def check(jm: JsonModel, assertion: ModelFilter, what: str = "?", short: bool =
65
65
  return okay
66
66
 
67
67
  # FIXME must tell why it is unhappy!
68
- def valid(jm: JsonModel, path: ModelPath = [], root: bool = True, extend: bool = False) -> bool:
68
+ def valid(jm: JsonModel,
69
+ path: ModelPath = [],
70
+ root: bool = True, # expect a root model (start recursion)
71
+ extend: bool = False, # allow model extensions (.mo, .in)
72
+ caps: bool = True, # all-caps defs are rejected
73
+ ) -> bool:
69
74
  """Check JSON Model structural (and slightly more) validity."""
70
75
 
71
76
  is_valid = True
@@ -195,8 +200,9 @@ def valid(jm: JsonModel, path: ModelPath = [], root: bool = True, extend: bool =
195
200
 
196
201
  try:
197
202
  for name, jmr in jm._defs.items():
198
- assert not re.search(r"^[A-Z_][A-Z_0-9]*$", name), \
199
- f"all caps reserved for predefs at ${name}"
203
+ if caps:
204
+ assert not re.search(r"^[A-Z_][A-Z_0-9]*$", name), \
205
+ f"all caps reserved for predefs at ${name}"
200
206
  assert finiteRef("$" + name), f"finite recursion on ${name}"
201
207
  check(jm, validFlt, "JSON Model Structural Validity")
202
208
  is_valid = True
@@ -0,0 +1 @@
1
+ 2.0.61
@@ -104,6 +104,10 @@ Accept JSON with objects containing duplicated properties.
104
104
 
105
105
  Allow some extensions to help with JSU back-end implementation.
106
106
 
107
+ =item B<--caps> or B<--no-caps>
108
+
109
+ Reject (the default) or accept all-caps definitions.
110
+
107
111
  =item B<--from-ir>/B<-fir>
108
112
 
109
113
  Read a JSON intermediate representation, as generated with C<-C -F json>, instead of a
@@ -807,6 +807,10 @@ def recurseIR(code: Jsonable,
807
807
  rwt: Callable[[Jsonable, Path], Jsonable]):
808
808
  _recIR(code, [], flt, rwt)
809
809
 
810
+ #
811
+ # Actual IR optimizations
812
+ #
813
+
810
814
  def callShortcuts(code: Jsonable, shortcuts: dict[str, str]) -> int:
811
815
  """Update check function calls based on shortcuts."""
812
816
 
@@ -837,6 +841,7 @@ def callShortcuts(code: Jsonable, shortcuts: dict[str, str]) -> int:
837
841
 
838
842
  recurseIR(code, _goStructIR, repRwt)
839
843
 
844
+ log.debug(f"csc {changes}")
840
845
  return changes
841
846
 
842
847
  SCALAR_TYPES = { "int", "float", "bool", "str" }
@@ -898,6 +903,7 @@ def partialEval(code: Jsonable, reporting: bool) -> int:
898
903
 
899
904
  recurseIR(code, _goStructIR, peRwt)
900
905
 
906
+ log.debug(f"pev {changes}")
901
907
  return changes
902
908
 
903
909
  def elimCommonSub(code: Jsonable) -> int:
@@ -995,6 +1001,8 @@ def elimCommonSub(code: Jsonable) -> int:
995
1001
  return code
996
1002
 
997
1003
  recurseIR(code, cseFlt, cseRwt)
1004
+
1005
+ log.debug(f"cse {changes}")
998
1006
  return changes
999
1007
 
1000
1008
  def elimEmptySeq(code: Jsonable, reporting: bool) -> int:
@@ -1018,11 +1026,12 @@ def elimEmptySeq(code: Jsonable, reporting: bool) -> int:
1018
1026
  break
1019
1027
  if code and remove:
1020
1028
  changes += 1
1021
- # keep nope to avoid empty else in python: TODO catch in code generator!
1022
- return list(filter(lambda o: _isOps(o, {"co", "seq", "no"}), code))
1029
+ code = getComments(code) + [ {"o": "no"} ]
1023
1030
  return code
1024
1031
 
1025
1032
  recurseIR(code, _goIR, eecRwt)
1033
+
1034
+ log.debug(f"ees {changes}")
1026
1035
  return changes
1027
1036
 
1028
1037
 
@@ -1075,6 +1084,8 @@ def elimEmptyLoop(code: Jsonable, reporting: bool) -> int:
1075
1084
  return code
1076
1085
 
1077
1086
  recurseIR(code, _goIR, eelRwt)
1087
+
1088
+ log.debug(f"eel {changes}")
1078
1089
  return changes
1079
1090
 
1080
1091
  def elimDeadCode(code: Jsonable, reporting: bool) -> int:
@@ -1104,6 +1115,8 @@ def elimDeadCode(code: Jsonable, reporting: bool) -> int:
1104
1115
  return code
1105
1116
 
1106
1117
  recurseIR(code, _goIR, edcRwt)
1118
+
1119
+ log.debug(f"edc {changes}")
1107
1120
  return changes
1108
1121
 
1109
1122
  def elimUnreachableCode(code: Jsonable) -> int:
@@ -1134,6 +1147,8 @@ def elimUnreachableCode(code: Jsonable) -> int:
1134
1147
  return code
1135
1148
 
1136
1149
  recurseIR(code, _goStructIR, eucRwt)
1150
+
1151
+ log.debug(f"euc {changes}")
1137
1152
  return changes
1138
1153
 
1139
1154
  # TODO what about other variables?!
@@ -1165,6 +1180,7 @@ def elimUnusedBoolVars(code: Jsonable) -> int:
1165
1180
  bop.clear()
1166
1181
  bop.update(o="ign")
1167
1182
 
1183
+ log.debug(f"eub {changes}")
1168
1184
  return changes
1169
1185
 
1170
1186
  def mifToIf(code: Jsonable) -> int:
@@ -1183,6 +1199,7 @@ def mifToIf(code: Jsonable) -> int:
1183
1199
 
1184
1200
  recurseIR(code, _goStructIR, mif2ifRwt)
1185
1201
 
1202
+ log.debug(f"m2i {changes}")
1186
1203
  return changes
1187
1204
 
1188
1205
  def simplifySimpleIf(code: Jsonable, reporting: bool) -> int:
@@ -1211,6 +1228,7 @@ def simplifySimpleIf(code: Jsonable, reporting: bool) -> int:
1211
1228
 
1212
1229
  recurseIR(code, _goStructIR, sisifRwt)
1213
1230
 
1231
+ log.debug(f"ssi {changes}")
1214
1232
  return changes
1215
1233
 
1216
1234
  def optimizeIR(
@@ -33,9 +33,11 @@ LANG = {
33
33
  "json": "IR",
34
34
  }
35
35
 
36
- def process_model(model: JsonModel, *,
37
- check: bool = True, merge: bool = True, optimize: bool = True,
38
- disabled_optims: list[str] = [], extend: bool = False, debug: int = 0):
36
+ def process_model(
37
+ model: JsonModel, *,
38
+ check: bool = True, merge: bool = True, optimize: bool = True,
39
+ disabled_optims: list[str] = [], extend: bool = False, caps: bool = True,
40
+ debug: int = 0):
39
41
  """Apply necessary preprocessing to JsonModel."""
40
42
 
41
43
  # initial sanity check
@@ -48,7 +50,7 @@ def process_model(model: JsonModel, *,
48
50
 
49
51
  if debug or check:
50
52
  for m in all_models:
51
- if not analyze.valid(m, extend=extend):
53
+ if not analyze.valid(m, extend=extend, caps=caps):
52
54
  raise ModelError(f"invalid initial model {m._url}:{m._id}")
53
55
 
54
56
  # simplify before merging
@@ -60,7 +62,7 @@ def process_model(model: JsonModel, *,
60
62
  if debug or check:
61
63
  # log.debug(json.dumps(model.toJSON(), sort_keys=True, indent=2))
62
64
  for m in all_models:
63
- if not analyze.valid(m, extend=extend):
65
+ if not analyze.valid(m, extend=extend, caps=caps):
64
66
  raise ModelError(f"invalid optimized model {m._url}:{m._id}")
65
67
 
66
68
  # merge in reverse order to move alts up before inlining?!
@@ -76,7 +78,7 @@ def process_model(model: JsonModel, *,
76
78
  # check after merge & optimize
77
79
  if debug or check:
78
80
  for m in all_models:
79
- if not analyze.valid(m, extend=extend):
81
+ if not analyze.valid(m, extend=extend, caps=caps):
80
82
  raise ModelError(f"invalid merged model {m._url}:{m._id}")
81
83
 
82
84
 
@@ -88,7 +90,7 @@ def model_from_json(
88
90
  loose_int: bool|None = None, loose_float: bool|None = None,
89
91
  # processing stuff
90
92
  check: bool = True, merge: bool = True, optimize: bool = True,
91
- extend: bool = False, disabled_optims: list[str] = [],
93
+ extend: bool = False, caps: bool = True, disabled_optims: list[str] = [],
92
94
  ) -> JsonModel:
93
95
  """JsonModel instanciation from JSON data."""
94
96
 
@@ -117,7 +119,7 @@ def model_from_json(
117
119
  if check or merge or optimize or extend:
118
120
  process_model(
119
121
  jm, debug=debug, extend=extend, check=check, merge=merge,
120
- optimize=optimize, disabled_optims=disabled_optims,
122
+ optimize=optimize, disabled_optims=disabled_optims, caps=caps,
121
123
  )
122
124
 
123
125
  return jm
@@ -148,8 +150,8 @@ def model_from_str(
148
150
  return model_from_json(json_loads(mstring, allow_duplicates=allow_duplicates), **kwargs)
149
151
 
150
152
 
151
- # it is unclear if this tricks actually works
152
153
  def _model_checker(jm: JsonModel, *, debug: bool = False, **options):
154
+ """Return the python checker function for the model."""
153
155
  code = xstatic_compile(jm, lang="py", debug=debug, **options)
154
156
  env = {}
155
157
  exec(str(code), env)
@@ -166,13 +168,14 @@ def model_checker(jm: JsonModel, *, debug: bool = False, **options) -> EntryChec
166
168
  def model_checker_from_json(
167
169
  mjson: Jsonable, *, auto: bool = False, debug: int = 0,
168
170
  resolver: Resolver|None = None, single_line: bool = False,
169
- loose_int: bool|None = None, loose_float: bool|None = None, extend: bool = False,
171
+ loose_int: bool|None = None, loose_float: bool|None = None,
172
+ extend: bool = False, caps: bool = True,
170
173
  **options,
171
174
  ) -> EntryCheckFun:
172
175
  """Return an executable model checker from a URL."""
173
176
  jm = model_from_json(
174
177
  mjson, auto=auto, debug=debug, resolver=resolver, single_line=single_line,
175
- loose_int=loose_int, loose_float=loose_float, extend=extend
178
+ loose_int=loose_int, loose_float=loose_float, extend=extend, caps=caps,
176
179
  )
177
180
  return model_checker(jm, debug=debug > 0, **options)
178
181
 
@@ -181,12 +184,14 @@ def model_checker_from_url(
181
184
  murl: str, *, auto: bool = False, debug: int = 0,
182
185
  resolver: Resolver|None = None, follow: bool = True, single_line: bool = False,
183
186
  loose_int: bool|None = None, loose_float: bool|None = None, extend: bool = False,
187
+ caps: bool = True,
184
188
  **options,
185
189
  ) -> EntryCheckFun:
186
190
  """Return an executable model checker from a URL."""
187
191
  jm = model_from_url(
188
192
  murl, auto=auto, debug=debug, resolver=resolver, follow=follow,
189
- loose_int=loose_int, loose_float=loose_float, extend=extend, single_line=single_line,
193
+ loose_int=loose_int, loose_float=loose_float, extend=extend,
194
+ caps=caps, single_line=single_line,
190
195
  )
191
196
  return model_checker(jm, debug=debug > 0, **options)
192
197
 
@@ -196,13 +201,13 @@ def create_model(
196
201
  auto: bool = False, follow: bool = True, debug: int = 0,
197
202
  check: bool = True, merge: bool = True, optimize: bool = True,
198
203
  loose_int: bool|None = None, loose_float: bool|None = None,
199
- extend: bool = False, single_line: bool = False
204
+ extend: bool = False, caps: bool = True, single_line: bool = False
200
205
  ) -> JsonModel:
201
206
  """JsonModel instanciation without preprocessing."""
202
207
  return model_from_url(
203
208
  murl, auto=auto, follow=follow, debug=debug, resolver=resolver,
204
209
  loose_int=loose_int, loose_float=loose_float, single_line=single_line,
205
- check=check, merge=merge, optimize=optimize, extend=extend
210
+ check=check, merge=merge, optimize=optimize, extend=extend, caps=caps,
206
211
  )
207
212
 
208
213
 
@@ -368,11 +373,13 @@ def jmc_script(xargs: list[str]|None = None) -> int:
368
373
  grp = ap.add_argument_group("Model input")
369
374
  arg = grp.add_argument
370
375
  arg("--allow-duplicates", "-ad", action="store_true", default=False,
371
- help="allow duplicated properties in parsed model, probably a bad idea.""")
376
+ help="allow duplicated properties in parsed model, probably a bad idea.")
372
377
  arg("--maps", "-m", action="append", default=[], help="URL mappings")
373
378
  arg("--auto", "-a", action="store_true", help="automatic URL mapping")
374
379
  arg("--extend", default=False, action="store_true", help="allow some extensions")
375
380
  arg("--no-extend", dest="extend", action="store_false", help="do not allow some extensions")
381
+ arg("--caps", action="store_true", default=True, help="reject all-caps defs")
382
+ arg("--no-caps", dest="caps", action="store_false", help="accept all-caps defs")
376
383
  arg("--from-ir", "-fir", action="store_true", default=False,
377
384
  help="input is a JSON IR file instead of a JSON model")
378
385
 
@@ -852,7 +859,7 @@ def jmc_script(xargs: list[str]|None = None) -> int:
852
859
  args.model, resolver, auto=args.auto, debug=args.debug,
853
860
  loose_int=args.loose_int, loose_float=args.loose_float,
854
861
  check=args.check, merge=args.op != "N", single_line=args.single_line_regex,
855
- optimize=args.optimize, extend=args.extend, follow=False
862
+ optimize=args.optimize, extend=args.extend, caps=args.caps, follow=False
856
863
  )
857
864
  except Exception as e:
858
865
  log.error(e)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json_model_compiler
3
- Version: 2.0.60
3
+ Version: 2.0.61
4
4
  Summary: JSON Model Tools
5
5
  Author: Fabien Coelho, Claire Yannou-Medrala
6
6
  License-Expression: CC0-1.0
@@ -1 +0,0 @@
1
- 2.0.60
@@ -170,6 +170,9 @@ jmc.1: json_model/data/jmc.pod dev
170
170
  year=$$(date +%Y)
171
171
  pod2man $< | sed "s/^\.TH JMC 1.*/.TH JMC 1 $$year \"v$$version\" \"User Documentation\"/" > $@
172
172
 
173
+ .PHONY: build.site
174
+ build.site: site/models.json site/JMC.md site/ABOUT.md site/BENCH.md
175
+
173
176
  _site: build.site
174
177
  cp -rL site _site
175
178
  find _site -type d -print | xargs chmod a+rx
@@ -186,9 +189,6 @@ www: build.site
186
189
  # SITE and SITEPATH are out of the git repository
187
190
  -include local.mk
188
191
 
189
- .PHONY: build.site
190
- build.site: site/models.json site/JMC.md site/ABOUT.md site/BENCH.md
191
-
192
192
  .PHONY: publish.site
193
193
  publish.site: build.site
194
194
  # NOTE --delete: no, keep old benchmark pages archive on the site for now