json-model-compiler 2.0.62__tar.gz → 2.0.64__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.
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/BACKLOG.md +4 -19
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/BENCH.md +19 -6
- json_model_compiler-2.0.64/COMP.md +75 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/DOC.md +4 -2
- {json_model_compiler-2.0.62/json_model_compiler.egg-info → json_model_compiler-2.0.64}/PKG-INFO +1 -1
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/SPEC.md +33 -9
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/VERSION.md +50 -0
- json_model_compiler-2.0.64/bench.sh +59 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/analyze.py +9 -4
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/clang.py +9 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/convert.py +6 -0
- json_model_compiler-2.0.64/json_model/data/VERSION +1 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/jmc.pod +6 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/irep.py +4 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/java.py +9 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/javascript.py +9 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/language.py +25 -2
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/model.py +210 -43
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/objops.py +2 -2
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/optim.py +33 -3
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/perl.py +9 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/plpgsql.py +10 -1
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/predefs.py +2 -1
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/python.py +9 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/recurse.py +7 -2
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/pom.xml +3 -3
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/script.py +4 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/xstatic.py +33 -100
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64/json_model_compiler.egg-info}/PKG-INFO +1 -1
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/SOURCES.txt +1 -0
- json_model_compiler-2.0.62/bench.sh +0 -47
- json_model_compiler-2.0.62/json_model/data/VERSION +0 -1
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/.github/workflows/docs.yml +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/.github/workflows/sanity.yml +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/.gitignore +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/.gitmodules +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/API.md +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/DESIGN.md +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/DEV.md +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/HOWTO.md +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/INTEGRATION.md +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/MANIFEST.in +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/Makefile +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/PUBS.md +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/README.md +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/TUTO.md +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/about.sh +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/README.md +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/__init__.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/clang_entry.c +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/clang_free.c +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/clang_init.c +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/clang_pcre2_fun.c +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/clang_re2_fun.c +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/java_free.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/java_init.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/javascript_exe.js +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/javascript_foot.js +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/javascript_free.js +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/javascript_head.js +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/javascript_init.js +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/javascript_main.js +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/perl_entry.pl +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/perl_exe.pl +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/perl_free.pl +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/perl_init.pl +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/perl_main.pl +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/perl_pkg.pl +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/plpgsql_entry.sql +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/python_entry.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/python_exe.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/python_free.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/python_init.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/data/python_main.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/export.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/iroptim.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/mtypes.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/regex.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/resolver.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/Makefile +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/__init__.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/c/Makefile +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/c/json-model.c +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/c/json-model.h +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/c/main.c +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/.gitignore +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/Makefile +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/README.md +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/env.sh +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Checker.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/GSON.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/JSON.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/JSONP.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Jackson.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Main.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/ModelChecker.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Path.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Report.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Runtime.java +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/js/README.md +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/js/index.js +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/js/main.js +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/js/package.json +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/.gitignore +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/Changes +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/LICENSE +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/MANIFEST +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/Makefile.PL +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/README +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/env.sh +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/ignore.txt +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/lib/JSON/JsonModel.pm +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/t/00-load.t +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/t/manifest.t +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/t/pod-coverage.t +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/t/pod.t +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/pl/xt/boilerplate.t +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/sql/META.json +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/sql/Makefile +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/sql/json_model--2.0.sql +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/sql/json_model.control +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/support.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/runtime/types.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/submodel.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/ts_export.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/url_cache.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model/utils.py +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/dependency_links.txt +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/entry_points.txt +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/not-zip-safe +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/requires.txt +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/top_level.txt +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/package.json +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/pyproject.toml +0 -0
- {json_model_compiler-2.0.62 → json_model_compiler-2.0.64}/setup.cfg +0 -0
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Current Tasks
|
|
4
4
|
|
|
5
|
-
- [ ]
|
|
5
|
+
- [ ] models: add for openapi overlay spec, json patch and others
|
|
6
|
+
- [ ] java-runtime: consider automatic updates?
|
|
7
|
+
- [ ] pr: improve compiler page, list and describe optimizations?
|
|
6
8
|
- [ ] bench: better count should ignore bads
|
|
7
9
|
- [ ] bench: handle case failures for radar (wip, ajv handling)
|
|
8
10
|
- [ ] bench: collect error runs?
|
|
9
|
-
- [ ] bench: add corvus reference?
|
|
10
11
|
- [ ] bench: add stddev performance computation
|
|
11
12
|
- [ ] bench: improve resilience to bad overhead estimation
|
|
12
13
|
- [ ] bench: collect JSON parse times for comparison with validation times
|
|
@@ -21,15 +22,11 @@
|
|
|
21
22
|
- [ ] static: check for common object part?
|
|
22
23
|
- [ ] front: generate valid minimal, maximal and random values from a model
|
|
23
24
|
- [ ] front: generate invalid minimal values from a model
|
|
24
|
-
- [ ] optim: simplify some '!=' cases
|
|
25
25
|
- [ ] optim: collect and display stats about what works
|
|
26
|
-
- [ ] spec: allow to _remove_ definitions, eg `{ "$stuff": {"/": "$foo"}}`
|
|
27
26
|
- [ ] spec: restrict regex syntax to a smaller subset
|
|
28
|
-
- [ ] perf: add another loop over performance collection?
|
|
29
27
|
- [ ] perf: drop and/or merge identical results when comparing
|
|
30
28
|
- [ ] backend: check `mv-34/mu` test case which may require some utf normalization
|
|
31
29
|
- [ ] runtime: count graphemes instead of characters? for Java, see `java.text.BreakIterator`
|
|
32
|
-
- [ ] pr: better document optimizations, eg add compiler optimization page
|
|
33
30
|
- [ ] static: improve startswith pattern recognition `/^xyz.*/`
|
|
34
31
|
- [ ] js: implement cset as an or-expression
|
|
35
32
|
- [ ] c-backend: factor out str extraction in or-list in more cases
|
|
@@ -53,7 +50,6 @@
|
|
|
53
50
|
- [ ] predefs: _url_ vs _uri_ vs _iri_
|
|
54
51
|
- [ ] predefs: improve `$URI` and `$URL`
|
|
55
52
|
- [ ] predefs: add `$SIMPLE_REGEX` for regex syntax subset?
|
|
56
|
-
- [ ] docker: enable user remap
|
|
57
53
|
- [ ] export: java classes
|
|
58
54
|
- [ ] export: go interfaces
|
|
59
55
|
- [ ] export: ts interfaces
|
|
@@ -114,19 +110,8 @@
|
|
|
114
110
|
- [ ] predefs: add country codes, eg `$COUNTRY $COUNTRY2 $COUNTRY3 $COUNTRYN`
|
|
115
111
|
- [ ] spec: be precise about predefs standard references, eg `$DATE` and co.
|
|
116
112
|
|
|
117
|
-
## Internship
|
|
113
|
+
## Internship Ideas
|
|
118
114
|
|
|
119
|
-
- [x] pr: read www, papers, spec… setup dev env, report issues
|
|
120
|
-
- [x] pr: try tutorial, report issues and suggest improvements
|
|
121
|
-
- [x] tests: add a few tests for jsonrpc model
|
|
122
|
-
- [x] model: write a model for MCP
|
|
123
|
-
- [x] tests: add a few tests for MCP model
|
|
124
|
-
- [x] export: generate ts interfaces
|
|
125
|
-
- [x] model: fix IR model and tests
|
|
126
|
-
- [x] front: IR re-entrance
|
|
127
|
-
- [ ] tests: generate valid (pseudo-random) values
|
|
128
|
-
- [ ] tests: generate invalid minimal, maximal, pseudo-random values
|
|
129
|
-
- [ ] tests: generate invalid values on each constraint
|
|
130
115
|
- [ ] backend: C and runtime with json-c (\*, but beware of runtime integration)
|
|
131
116
|
- [ ] backend: C# (\*\*)
|
|
132
117
|
- [ ] backend: go (\*\*\*)
|
|
@@ -36,7 +36,7 @@ which will spawn the necessary containers:
|
|
|
36
36
|
|
|
37
37
|
```sh
|
|
38
38
|
JMC=latest JMC_OPTS="--predef --cc=clang" \
|
|
39
|
-
nohup ./start_bench.sh latest -p 12 -l 1000 -r 5 -c &
|
|
39
|
+
nohup ./start_bench.sh latest -p 12 -l 1000 -r 5 -L -c &
|
|
40
40
|
# in the generated directory, look for the summary markdown and radar json files.
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -59,12 +59,17 @@ misplaced keywords or bad regex, or better native models), and induce small
|
|
|
59
59
|
differences in the validated results, in which case they are manually
|
|
60
60
|
validated and discussed.
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
- Performance elapsed times for each test are collected over a loop to compute
|
|
63
|
+
an average and standard deviation.
|
|
64
|
+
The repetition also intends to catch hidden costs such as JIT compilation, GC runs and
|
|
65
|
+
lazy initializations, amortized over the loop and tests, typically _1,000,000_ validations
|
|
66
|
+
for a _1000_ iteration loop over _1000_ test values.
|
|
67
|
+
- Several independent runs are performed to reduce host load effects.
|
|
67
68
|
- Compilation times and performance times are the _median_ encountered over the runs.
|
|
69
|
+
- Runs are usually performed in _fast_ mode: the rejection reasons are not collected,
|
|
70
|
+
and the run stops as soon as possible.
|
|
71
|
+
- The benchmark presents relative comparison ratios to smooth out the wide range of
|
|
72
|
+
collected performances (from 10 ns to over 300 µs for validating one test value).
|
|
68
73
|
|
|
69
74
|
Note that performance figures **must** be taken with a pinch of salt, please consider
|
|
70
75
|
the following caveats, and others:
|
|
@@ -81,6 +86,14 @@ the following caveats, and others:
|
|
|
81
86
|
so it is often disabled.
|
|
82
87
|
- The measure overhead is estimated and deduced from the performance figures by default,
|
|
83
88
|
which leads to potentially fuzzy results when testing very small values.
|
|
89
|
+
- Parsing is not taken into account:
|
|
90
|
+
From a user perspective, the combined time for parsing or building, checking, and
|
|
91
|
+
using or serializing makes more sense.
|
|
92
|
+
From our tool perspective, it is built around external representations, and
|
|
93
|
+
aims at being _inserted_ into existing code, without changing the underlying
|
|
94
|
+
JSON libraries, so the validation is the only new overhead to consider.
|
|
95
|
+
For other tools which force using their own representation (eg Blaze or Corvus C#)
|
|
96
|
+
and may imply conversion costs, an end-to-end measure seems more appropriate.
|
|
84
97
|
- Compilers, libraries and other design and updates can have dramatic effects:
|
|
85
98
|
for faster parsing, a library may use linked-list for properties, which means
|
|
86
99
|
that retrieving a given property value will cost more than a library which uses
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# JSON Model Compiler
|
|
2
|
+
|
|
3
|
+
This page documents the JSON Model Compiler (JMC), accessible from the `jmc` command.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The compiler is composed of 8 parts:
|
|
8
|
+
|
|
9
|
+
1. Parser from JSON, YAML or JS
|
|
10
|
+
2. Preprocessor
|
|
11
|
+
3. Model Optimizations
|
|
12
|
+
4. Static Compilation to IR
|
|
13
|
+
5. Export to TS, JSON Schema or Pydantic
|
|
14
|
+
6. IR Optimizations
|
|
15
|
+
7. Target Source Code Generation in Python, C, JavaScript, Java, Perl, PL/pgSQL
|
|
16
|
+
8. Target Runtime for each target language
|
|
17
|
+
|
|
18
|
+
```mermaid
|
|
19
|
+
flowchart LR
|
|
20
|
+
filein(json
|
|
21
|
+
yaml
|
|
22
|
+
js)
|
|
23
|
+
parser[parser]
|
|
24
|
+
preproc[preproc]
|
|
25
|
+
m-optim[optim]
|
|
26
|
+
compile[static]
|
|
27
|
+
export[export]
|
|
28
|
+
ir-optim["IR
|
|
29
|
+
optim"]
|
|
30
|
+
codegen["code
|
|
31
|
+
gen"]
|
|
32
|
+
code(py
|
|
33
|
+
c
|
|
34
|
+
js
|
|
35
|
+
java
|
|
36
|
+
pl
|
|
37
|
+
sql)
|
|
38
|
+
filein --> parser --> preproc --> m-optim --> compile --> ir-optim --> codegen --> code
|
|
39
|
+
fileout(schema
|
|
40
|
+
ts
|
|
41
|
+
py)
|
|
42
|
+
m-optim --> export --> fileout
|
|
43
|
+
runtime[runtime]
|
|
44
|
+
runtime --> code
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Parser
|
|
48
|
+
|
|
49
|
+
Read a model, possibly resolving remote references, from JSON, YAML or JS syntaxes.
|
|
50
|
+
|
|
51
|
+
## Preprocessor
|
|
52
|
+
|
|
53
|
+
Apply model transformations (`%`), check references (`$`) and eliminate object merges (`+`).
|
|
54
|
+
|
|
55
|
+
## Model Optimization
|
|
56
|
+
|
|
57
|
+
Perform optimizations at the model level, including partial evaluation,
|
|
58
|
+
various simplifications and normalizations.
|
|
59
|
+
|
|
60
|
+
## Static Compiler
|
|
61
|
+
|
|
62
|
+
Generate a language-agnostic AST (Abstract Syntax Tree) IR (Intermediate Representation) for the evaluator.
|
|
63
|
+
|
|
64
|
+
## IR Optimization
|
|
65
|
+
|
|
66
|
+
Optimize the AST, which results in simpler source code.
|
|
67
|
+
|
|
68
|
+
## Code Generator
|
|
69
|
+
|
|
70
|
+
Generate actual target source code from the AST.
|
|
71
|
+
This includes target-specific optimizations.
|
|
72
|
+
|
|
73
|
+
## Runtime
|
|
74
|
+
|
|
75
|
+
Per-language runtimes provide support functions.
|
|
@@ -4,12 +4,14 @@ Following the [diátaxis](https://diataxis.fr/) approach, this project provides:
|
|
|
4
4
|
|
|
5
5
|
## Explanations and discussions
|
|
6
6
|
|
|
7
|
-
See [introduction](README.md)
|
|
7
|
+
See [introduction](README.md), [compiler documentation](COMP.md)
|
|
8
|
+
and [research papers](PUBS#research-papers).
|
|
8
9
|
|
|
9
10
|
## Tutorial
|
|
10
11
|
|
|
11
12
|
See [tutorial](TUTO.md) about JSON Model and the `jmc` command,
|
|
12
|
-
using a [docker](DOCKER.md)
|
|
13
|
+
using a [docker](DOCKER.md)
|
|
14
|
+
[image](https://hub.docker.com/r/zx80/jmc) for easy deployment.
|
|
13
15
|
|
|
14
16
|
## How To
|
|
15
17
|
|
|
@@ -127,6 +127,7 @@ for all possible values for that type.
|
|
|
127
127
|
- `"$F16"`, `"$F32"`, `"$F64"`: 16/32/64 bit precision
|
|
128
128
|
[IEEE 754](https://standards.ieee.org/ieee/754/6210/) floats.
|
|
129
129
|
- "`$STRING"`: a string.
|
|
130
|
+
- `"$RATE"`: a float between _0.0_ and _1.0_.
|
|
130
131
|
|
|
131
132
|
In addition, the following string predefs are defined:
|
|
132
133
|
|
|
@@ -196,7 +197,9 @@ Property names are matched as follow:
|
|
|
196
197
|
- `"?XXX"`: optional properties directly provided after the `?`.
|
|
197
198
|
- `"/.../"`: optional property names matching a regular expression:
|
|
198
199
|
eg `{"/^a/": ""}` means property names starting with _a_ must have string values.
|
|
199
|
-
- `"$XXX"`: optional property reference to a **string** [definition](#definitions-and-scope)
|
|
200
|
+
- `"$XXX"`: optional property reference to a **string** [definition](#definitions-and-scope)
|
|
201
|
+
or predef. The target definition type must be resolved as a string according to
|
|
202
|
+
the [typing lattice](#static-typing-lattice).
|
|
200
203
|
- `""` catch all property: any property name matches.
|
|
201
204
|
This is consistent with `""` standing for any string.
|
|
202
205
|
- property names starting with other characters are reserved for future uses and must be rejected.
|
|
@@ -216,7 +219,7 @@ property specifications are **not** cumulative.
|
|
|
216
219
|
|
|
217
220
|
The matching search **should** follow the specification order within these classes
|
|
218
221
|
if the language JSON representation allows it.
|
|
219
|
-
However, a model **should
|
|
222
|
+
However, a model **should not** rely on the fact that the specification order is preserved
|
|
220
223
|
for its expected semantics.
|
|
221
224
|
This allows to hint optimization by putting more likely properties ahead of the check.
|
|
222
225
|
|
|
@@ -457,7 +460,7 @@ Implementation should detect external reference cycles which are errors and shou
|
|
|
457
460
|
|
|
458
461
|
## (EXPERIMENTAL) Model Transformations
|
|
459
462
|
|
|
460
|
-
Symbol `%` at the root of the model defines a model transformation object, which
|
|
463
|
+
Symbol `%` at the root of the model defines a global model transformation object, which
|
|
461
464
|
may include symbol renamings, model importations and model editions.
|
|
462
465
|
|
|
463
466
|
- **Symbol Names**
|
|
@@ -503,8 +506,8 @@ may include symbol renamings, model importations and model editions.
|
|
|
503
506
|
|
|
504
507
|
Model editions are specified with properties which are references possibly followed
|
|
505
508
|
by a JSON path, allowing to point to a JSON element in the model, and either a value
|
|
506
|
-
with special properties `/ *` to remove or add sub elements,
|
|
507
|
-
taken as-is, but which must not be an object with any of the special properties.
|
|
509
|
+
with special properties `/ *` to remove or add sub elements, `:` to rename properties.
|
|
510
|
+
Anything else taken as-is, but which must not be an object with any of the special properties.
|
|
508
511
|
|
|
509
512
|
- Addition/replacement on a `"$External#name"` reference to a definition:
|
|
510
513
|
- a non-existing definition is added to available definitions _in the target scope_.
|
|
@@ -512,29 +515,50 @@ may include symbol renamings, model importations and model editions.
|
|
|
512
515
|
- Edition on a `"$External#name.foo.0"`: the target element **must** exist.
|
|
513
516
|
The `.foo.0` path instructs to select the first element (index _0_) of
|
|
514
517
|
the array value of property _foo_ inside definition _name_.
|
|
518
|
+
- Rename on "$External:name.foo.0": the target element **must** exist and be an object.
|
|
515
519
|
|
|
516
520
|
The following edition rules apply, in order, depending on the type of the target element:
|
|
517
521
|
|
|
518
|
-
- if the transformation value is an edition object (ie include at least one `/
|
|
522
|
+
- if the transformation value is an edition object (ie include at least one `/ * ~` property):
|
|
519
523
|
- if the target is a JSON object (not necessarily a model for an object):
|
|
520
524
|
- `/` value may be a string or a list of strings.
|
|
521
525
|
All properties of these names are removed.
|
|
522
526
|
If a property does not exist, this is an error and must be rejected.
|
|
523
|
-
- `*` value
|
|
524
|
-
If
|
|
527
|
+
- `*` value may be an objecti or list
|
|
528
|
+
If the value is an obhect, it is merged into the target object.
|
|
529
|
+
If a property already exists, this is an error and must be rejected.
|
|
530
|
+
If the value is a list, keep only the listed properties, others are discarded.
|
|
531
|
+
- `~` value must be an object, which is a string mapping to rename properties
|
|
532
|
+
in the target object. All renamed properties **must** exists.
|
|
533
|
+
Specifying `{"?a": "b", "?b": "a"}` exchanges optional property values and makes them mandatory.
|
|
534
|
+
As a special case, `{"!": "?"}` and `{"?": "!"}` are bulk changes to downgrade
|
|
535
|
+
mandatory properties to optional, or upgrade optional properties to mandatory.
|
|
525
536
|
- if the target is a JSON array (not necessarily a model for an array):
|
|
526
537
|
- `/`: may be value or a list of values.
|
|
527
538
|
Array items equal to these values are removed.
|
|
528
539
|
If a value is not found, this is an error and must be rejected.
|
|
529
540
|
- `*`: if the value is an array, append its items to the target array.
|
|
530
|
-
|
|
541
|
+
If the value is something else, appends to the array.
|
|
542
|
+
- `~`: currently invalid
|
|
531
543
|
- if the target is a JSON scalar: this is an error and must be rejected.
|
|
532
544
|
- if the transformation value is a model (i.e. an object without any `/ *` property),
|
|
533
545
|
the target value is _replaced_ by this value, in place.
|
|
534
546
|
|
|
547
|
+
Moreover, operations can also apply on model definitions when the path ends with `#` and
|
|
548
|
+
must designate a _head_ model, not a submodel:
|
|
549
|
+
|
|
550
|
+
- `/`: remove one (scalar) or several (array) definitions
|
|
551
|
+
- `*`: add or override definitions
|
|
552
|
+
- `~`: Rename, and possibly override, existing definitions
|
|
553
|
+
|
|
535
554
|
These additions and editions are performed _after_ property renamings and imports,
|
|
536
555
|
and _before_ merge pre-processing.
|
|
537
556
|
|
|
557
|
+
Symbols `<`, `/`, `*`, `~` inside a _definition_ define a local transformation.
|
|
558
|
+
|
|
559
|
+
- `<` must be a local reference `$name`, the target model is **copied** inside the definition.
|
|
560
|
+
- `/`, `*` and `~` define local editions inside the definition, as describe above.
|
|
561
|
+
|
|
538
562
|
What is the _right_ balance between features, syntax and ease-of-use for a type transformation
|
|
539
563
|
language is an on-going investigation: should it allow renaming, moving or copying attributes?
|
|
540
564
|
Should it allow to remove definitions? Should imports allow to define a namespace?
|
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# JSON Model Compiler Versions
|
|
2
2
|
|
|
3
|
+
## 2.0.64 on 2026-10-26
|
|
4
|
+
|
|
5
|
+
- bench: do not link same version and message artifacts, keep first encountered
|
|
6
|
+
- bench: move corvus at then end of the radar to keep colors consistent
|
|
7
|
+
- bench: run cron bench with corvus
|
|
8
|
+
- bench: re-build corvus image automatically
|
|
9
|
+
- model: transformation rename properties with `~` (experimental)
|
|
10
|
+
- model: transformation make work on import? checked!
|
|
11
|
+
- model: allow to edit definitions (namespace `$foo#`) with transformations
|
|
12
|
+
- models: add `:` trafo to json model meta model
|
|
13
|
+
- models: add diff model from v1 to v2
|
|
14
|
+
- bench: work around cal dns issues
|
|
15
|
+
- bench: fix missing jmc on cron job
|
|
16
|
+
- bench: improve report section title about classification metrics
|
|
17
|
+
- docker: enable user remap (for a long time?)
|
|
18
|
+
- models: add OpenAPI-with-models alternative model
|
|
19
|
+
- model: fix definition cross renames
|
|
20
|
+
- model: add local transformations
|
|
21
|
+
- model: add keep-only transformation
|
|
22
|
+
- model: allow bulk mandatory to optional and optional to mandatory renames
|
|
23
|
+
- model: fix model internals when adding definitions with a namespace trafo
|
|
24
|
+
- models: add json schema draft 03 diff model
|
|
25
|
+
- model: move local transformations _after_ global transformations
|
|
26
|
+
|
|
27
|
+
## 2.0.63 on 2026-10-05
|
|
28
|
+
|
|
29
|
+
- pr: center logo in sidebar
|
|
30
|
+
- optim: handle indirect number models
|
|
31
|
+
- optim: improve partial eval for more num nones
|
|
32
|
+
- optim: simplify some '!=' cases
|
|
33
|
+
- perf: ~add another loop over performance collection?~
|
|
34
|
+
- pr: add simple compiler description page
|
|
35
|
+
- optim: fix xor bad deduplication optimization when 3 models are equal
|
|
36
|
+
- optim: `{"a":"$NONE"}` is `"$NONE"`
|
|
37
|
+
- optim: `{"?a":"$NONE"}` or `{"": "$NONE"}` is `{}`
|
|
38
|
+
- check: prop references must be strings
|
|
39
|
+
- static: shortcut on open may-only props
|
|
40
|
+
- sql: capitalize bool and int type names for consistency
|
|
41
|
+
- backends: refactor language-specific code generation settings to each language
|
|
42
|
+
- bench: add corvus external reference
|
|
43
|
+
- bench: add untested `--collect` option
|
|
44
|
+
- bench: submit `negatives.jsonl` to jsb for sanity checks (wip)
|
|
45
|
+
- bench: always use `latest` tag for external tools (ajv, corvus)
|
|
46
|
+
- java-runtime: update dependent java lib versions (base container, runtime)
|
|
47
|
+
- bench: run negatives to access tool accuracy
|
|
48
|
+
- bench: extract and report tool accuracy, precision, recall…
|
|
49
|
+
- spec: add `$RATE` predef, float in [0.0, 1.0]
|
|
50
|
+
- bench: add build option to cron script
|
|
51
|
+
- bench: disactivate reruns on jsb changes
|
|
52
|
+
|
|
3
53
|
## 2.0.62 on 2026-09-20
|
|
4
54
|
|
|
5
55
|
- bench: add case names to generated radar
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#! /bin/bash
|
|
2
|
+
#
|
|
3
|
+
# generate BENCH.md page with links to available benchmarks
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
MAX=10
|
|
7
|
+
PYPI="https://pypi.org/project"
|
|
8
|
+
|
|
9
|
+
# extract version from file
|
|
10
|
+
get_version()
|
|
11
|
+
{
|
|
12
|
+
local what=$1 file=$2
|
|
13
|
+
local line=$(grep "$what version:" < $file)
|
|
14
|
+
line=${line#*:\*\* }
|
|
15
|
+
line=${line%% *}
|
|
16
|
+
echo $line
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# up to artifact list
|
|
20
|
+
sed -ne '1,/BENCHES/p' < BENCH.md | grep -v '^BENCHES$'
|
|
21
|
+
|
|
22
|
+
# list max 10 latest artifacts
|
|
23
|
+
nartifacts=0 p_jsu= p_jmc= p_sbc= p_crv= p_msg=
|
|
24
|
+
|
|
25
|
+
for artifact in $(ls site/benchmarks/*.md | sort -r) ; do
|
|
26
|
+
|
|
27
|
+
jsu=$(get_version jsu $artifact)
|
|
28
|
+
jmc=$(get_version jmc $artifact)
|
|
29
|
+
sbc=$(get_version jsonschema-cli $artifact)
|
|
30
|
+
crv=$(get_version corvus-cli $artifact)
|
|
31
|
+
|
|
32
|
+
msg=""
|
|
33
|
+
[ "$(grep 'content:.*yes' $artifact)" ] && msg+="content" || msg+="no content"
|
|
34
|
+
[ "$(grep 'JSU_OPT.*--no-id' $artifact)" ] && msg+=", no id" || msg+=", id"
|
|
35
|
+
[ "$(grep 'fix:.*yes' $artifact)" ] && msg+=", fix" || msg+=", no fix"
|
|
36
|
+
|
|
37
|
+
# skip same version (details may differ, keep first encountered)
|
|
38
|
+
[ "$jsu" = "$p_jsu" -a "$jmc" = "$p_jmc" -a \
|
|
39
|
+
"$sbc" = "$p_sbc" -a "$crv" = "$p_crv" -a "$msg" = "$p_msg" ] && continue
|
|
40
|
+
|
|
41
|
+
p_jsu=$jsu p_jmc=$jmc p_sbc=$sbc p_crv=$crv p_msg=$msg
|
|
42
|
+
|
|
43
|
+
link=${artifact#site/}
|
|
44
|
+
name=${link#benchmarks/}
|
|
45
|
+
name=${name%.md}
|
|
46
|
+
|
|
47
|
+
echo "- Artifact [$name]($link) using"
|
|
48
|
+
echo " [JMC $jmc]($PYPI/json-model-compiler/$jmc/), "
|
|
49
|
+
echo " [JSU $jsu]($PYPI/json-schema-utils/$jsu/), "
|
|
50
|
+
[ "$sbc" ] && echo " [SBC $sbc](https://github.com/sourcemeta/jsonschema/releases/tag/v$sbc),"
|
|
51
|
+
[ "$crv" ] && echo " [Corvus $crv](https://corvus-oss.org/Corvus.JsonSchema/),"
|
|
52
|
+
echo " $msg."
|
|
53
|
+
|
|
54
|
+
let nartifacts+=1
|
|
55
|
+
[ $nartifacts -eq $MAX ] && break
|
|
56
|
+
done
|
|
57
|
+
|
|
58
|
+
# after artifact list
|
|
59
|
+
sed -ne '/BENCHES/,$p' < BENCH.md | grep -v '^BENCHES$'
|
|
@@ -60,7 +60,7 @@ def check(jm: JsonModel, assertion: ModelFilter, what: str = "?", short: bool =
|
|
|
60
60
|
okay = False
|
|
61
61
|
return okay if short else True
|
|
62
62
|
|
|
63
|
-
recModel(jm._model, checkFlt, noRwt, True)
|
|
63
|
+
recModel(jm._model, checkFlt, noRwt, True, jm._is_root)
|
|
64
64
|
|
|
65
65
|
return okay
|
|
66
66
|
|
|
@@ -83,6 +83,9 @@ def valid(jm: JsonModel,
|
|
|
83
83
|
ARR_KW = {"!"}
|
|
84
84
|
OP_KW = {"@", "|", "&", "^", "+"}
|
|
85
85
|
|
|
86
|
+
# trafo are applied before checking model validity, thus out of scope
|
|
87
|
+
# TRAFO_KW = {"/", "*", "~"}
|
|
88
|
+
|
|
86
89
|
if extend: # multiple-of: number, contains: model
|
|
87
90
|
CMP_KW |= {".mo"}
|
|
88
91
|
ARR_KW |= {".in"}
|
|
@@ -186,14 +189,16 @@ def valid(jm: JsonModel,
|
|
|
186
189
|
else: # check object
|
|
187
190
|
props = set() # check property name collisions
|
|
188
191
|
for p, m in model.items():
|
|
189
|
-
if p == "#":
|
|
192
|
+
if p == "#" or p and p[0] == "#": # skip comments
|
|
190
193
|
continue
|
|
191
194
|
assert isinstance(p, str), f"property name {p} is a string at {spath}"
|
|
192
|
-
if p and p[0] not in
|
|
195
|
+
if p and p[0] not in "$/":
|
|
193
196
|
name = p[1:] if p[0] in ("?", "_", "!") else p
|
|
194
197
|
assert name not in props, f"no property name collison at {spath}"
|
|
195
198
|
props.add(name)
|
|
196
|
-
|
|
199
|
+
elif p and p[0] == "$": # check property name type
|
|
200
|
+
assert ultimate_type(jm, p) is str, f"property name reference {p} is a string at {spath}"
|
|
201
|
+
# else p == "" or p is a regex
|
|
197
202
|
case _:
|
|
198
203
|
assert False, f"unexpected model base type at {spath}"
|
|
199
204
|
return True
|
|
@@ -301,6 +301,15 @@ class CLangJansson(Language):
|
|
|
301
301
|
self._partition_threshold = partition_threshold
|
|
302
302
|
self._byte_order = byte_order
|
|
303
303
|
|
|
304
|
+
self._settings |= {
|
|
305
|
+
"mot": 0,
|
|
306
|
+
"mmo": 0,
|
|
307
|
+
"moo": 3,
|
|
308
|
+
"map": 256,
|
|
309
|
+
"par": 6,
|
|
310
|
+
"omu": 4,
|
|
311
|
+
"aun": 4,
|
|
312
|
+
}
|
|
304
313
|
# instance counter
|
|
305
314
|
self._count = Counter()
|
|
306
315
|
|
|
@@ -9,12 +9,15 @@ from .predefs import PREDEF_RE, PREDEFS
|
|
|
9
9
|
|
|
10
10
|
PREDEF_TYPES: dict[str, str] = {
|
|
11
11
|
"$NUMBER": "number",
|
|
12
|
+
"$RATE": "number",
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
for name, model in PREDEFS.items():
|
|
15
16
|
if name[0] == "o": # skip $oXXX
|
|
16
17
|
continue
|
|
17
18
|
pname = "$" + name
|
|
19
|
+
if pname in PREDEF_TYPES:
|
|
20
|
+
continue
|
|
18
21
|
match model:
|
|
19
22
|
case None:
|
|
20
23
|
PREDEF_TYPES[pname] = "null"
|
|
@@ -146,6 +149,9 @@ def _m2s(model: ModelType, path: ModelPath, defs: Symbols) -> JsonSchema:
|
|
|
146
149
|
schema["contentMediaType"] = "application/json"
|
|
147
150
|
elif model in PREDEF_RE:
|
|
148
151
|
schema["pattern"] = PREDEF_RE[model][1]
|
|
152
|
+
elif model == "$RATE":
|
|
153
|
+
schema["minimum"] = 0.0
|
|
154
|
+
schema["maximum"] = 1.0
|
|
149
155
|
# else: ignore
|
|
150
156
|
elif model[0] == "$":
|
|
151
157
|
if model == "$#":
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.0.64
|
|
@@ -204,6 +204,12 @@ is below the provided threshold, default is depends on target.
|
|
|
204
204
|
Consider must-only object property scheme if the number of mandatory
|
|
205
205
|
properties is below the provided threshold, default depends on target.
|
|
206
206
|
|
|
207
|
+
=item B<--may-only-open-threshold THRESHOLD>
|
|
208
|
+
|
|
209
|
+
Count-based shorcut for may-only open objects if the number of optional
|
|
210
|
+
properties is greater than 1 and below the provided threshold.
|
|
211
|
+
Default is 3, 0 to disable.
|
|
212
|
+
|
|
207
213
|
=item B<--partition-threshold THRESHOLD>
|
|
208
214
|
|
|
209
215
|
Number of properties to trigger partitioning inlined property checks,
|
|
@@ -96,6 +96,10 @@ class IRep(Language):
|
|
|
96
96
|
self._if_optim = if_optim
|
|
97
97
|
self._byte_order = lang._byte_order if lang else "le"
|
|
98
98
|
|
|
99
|
+
def setting(self, name: str, val: int|None) -> int:
|
|
100
|
+
# FORWARD to lang if distinct, else use common defaults
|
|
101
|
+
return self._lang.setting(name, val) if self != self._lang else super().setting(name, val)
|
|
102
|
+
|
|
99
103
|
# language dependent stuff is forwarded to the underlying language if any
|
|
100
104
|
def fast_strlen(self) -> bool:
|
|
101
105
|
return self._lang._fast_strlen
|
|
@@ -66,6 +66,15 @@ class JavaScript(Language):
|
|
|
66
66
|
self._json_esc_table = str.maketrans(_ESC_TABLE)
|
|
67
67
|
self._direct = direct
|
|
68
68
|
self._runtime = runtime
|
|
69
|
+
self._settings |= {
|
|
70
|
+
"mot": 256,
|
|
71
|
+
"mmo": 16,
|
|
72
|
+
"moo": 3,
|
|
73
|
+
"map": 20,
|
|
74
|
+
"par": 0,
|
|
75
|
+
"omu": 2,
|
|
76
|
+
"aun": 0,
|
|
77
|
+
}
|
|
69
78
|
|
|
70
79
|
#
|
|
71
80
|
# file
|
|
@@ -103,6 +103,17 @@ class Language:
|
|
|
103
103
|
self.reindent = False
|
|
104
104
|
self._predefs: set[str] = predefs # implemented by language runtime
|
|
105
105
|
|
|
106
|
+
# code generator settings
|
|
107
|
+
self._settings: dict[str, int] = {
|
|
108
|
+
"mot": 8, # must only threshold
|
|
109
|
+
"mmo": 16, # may must open threshold
|
|
110
|
+
"moo": 3, # may only open threshold (max, untested)
|
|
111
|
+
"map": 12, # map threshold
|
|
112
|
+
"par": 0, # partition threshold
|
|
113
|
+
"omu": 0, # or-must threshold
|
|
114
|
+
"aun": 0, # array unroll size
|
|
115
|
+
}
|
|
116
|
+
|
|
106
117
|
# Hmmm…
|
|
107
118
|
self._lang = self
|
|
108
119
|
|
|
@@ -110,6 +121,10 @@ class Language:
|
|
|
110
121
|
"""Version string in generated code."""
|
|
111
122
|
return self._version.split(".", 1)[0] if self._short_version else self._version
|
|
112
123
|
|
|
124
|
+
def setting(self, name: str, val: int|None = None) -> int:
|
|
125
|
+
"""Language-specific code generation default settings."""
|
|
126
|
+
return self._settings[name] if val is None else val
|
|
127
|
+
|
|
113
128
|
def ident(self, prefix: str) -> Var:
|
|
114
129
|
"""Return a new identifier using prefix."""
|
|
115
130
|
if prefix not in self._idcounts:
|
|
@@ -216,12 +231,20 @@ class Language:
|
|
|
216
231
|
elif name in ("$INT", "$INTEGER", "$I32", "$I64"):
|
|
217
232
|
return self.is_a(var, int)
|
|
218
233
|
elif name in ("$U32", "$U64"):
|
|
219
|
-
return self.and_op(
|
|
220
|
-
|
|
234
|
+
return self.and_op(
|
|
235
|
+
self.is_a(var, int),
|
|
236
|
+
self.num_cmp(self.value(var, int), ">=", self.const(0), False, True)
|
|
237
|
+
)
|
|
221
238
|
elif name in ("$FLOAT", "$F32", "$F64"):
|
|
222
239
|
return self.is_a(var, float)
|
|
223
240
|
elif name == "$NUMBER":
|
|
224
241
|
return self.is_a(var, Number) # type: ignore
|
|
242
|
+
elif name == "$RATE":
|
|
243
|
+
return self.and_op(
|
|
244
|
+
self.is_a(var, float),
|
|
245
|
+
self.num_cmp(self.value(var, float), ">=", self.const(0.0)),
|
|
246
|
+
self.num_cmp(self.value(var, float), "<=", self.const(1.0)),
|
|
247
|
+
)
|
|
225
248
|
elif name == "$STRING":
|
|
226
249
|
return self.is_a(var, str) if not is_str else self.true()
|
|
227
250
|
elif self.str_content_predef(name):
|