json-model-compiler 2.0.55__tar.gz → 2.0.57__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.57/.github/workflows/docs.yml +34 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/.github/workflows/sanity.yml +5 -1
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/.gitignore +3 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/API.md +15 -2
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/BACKLOG.md +7 -6
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/BENCH.md +36 -39
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/DEV.md +9 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/Makefile +13 -3
- {json_model_compiler-2.0.55/json_model_compiler.egg-info → json_model_compiler-2.0.57}/PKG-INFO +1 -1
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/PUBS.md +6 -12
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/VERSION.md +40 -3
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/about.sh +10 -4
- json_model_compiler-2.0.57/bench.sh +33 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/__init__.py +2 -0
- json_model_compiler-2.0.57/json_model/data/VERSION +1 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/jmc.pod +10 -0
- json_model_compiler-2.0.57/json_model/data/perl_exe.pl +1 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/irep.py +14 -4
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/language.py +5 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/perl.py +14 -5
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/predefs.py +1 -1
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/c/json-model.c +6 -4
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/lib/JSON/JsonModel.pm +15 -6
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/script.py +150 -55
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/xstatic.py +131 -47
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57/json_model_compiler.egg-info}/PKG-INFO +1 -1
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model_compiler.egg-info/SOURCES.txt +2 -0
- json_model_compiler-2.0.55/json_model/data/VERSION +0 -1
- json_model_compiler-2.0.55/json_model/data/perl_exe.pl +0 -1
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/.gitmodules +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/DESIGN.md +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/DOC.md +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/HOWTO.md +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/INTEGRATION.md +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/MANIFEST.in +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/README.md +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/SPEC.md +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/TUTO.md +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/README.md +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/analyze.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/clang.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/convert.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/clang_entry.c +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/clang_free.c +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/clang_init.c +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/clang_pcre2_fun.c +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/clang_re2_fun.c +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/java_free.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/java_init.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/javascript_exe.js +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/javascript_foot.js +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/javascript_free.js +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/javascript_head.js +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/javascript_init.js +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/javascript_main.js +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/perl_entry.pl +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/perl_free.pl +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/perl_init.pl +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/perl_main.pl +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/perl_pkg.pl +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/plpgsql_entry.sql +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/python_entry.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/python_exe.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/python_free.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/python_init.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/data/python_main.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/export.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/java.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/javascript.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/model.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/mtypes.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/objops.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/optim.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/plpgsql.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/python.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/recurse.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/regex.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/resolver.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/Makefile +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/__init__.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/c/Makefile +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/c/json-model.h +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/c/main.c +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/.gitignore +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/Makefile +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/README.md +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/env.sh +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/json_model/Checker.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/json_model/GSON.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/json_model/JSON.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/json_model/JSONP.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/json_model/Jackson.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/json_model/Main.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/json_model/ModelChecker.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/json_model/Path.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/json_model/Report.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/json_model/Runtime.java +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/java/pom.xml +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/js/README.md +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/js/index.js +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/js/main.js +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/js/package.json +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/.gitignore +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/Changes +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/LICENSE +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/MANIFEST +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/Makefile.PL +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/README +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/env.sh +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/ignore.txt +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/t/00-load.t +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/t/manifest.t +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/t/pod-coverage.t +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/t/pod.t +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/pl/xt/boilerplate.t +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/sql/META.json +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/sql/Makefile +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/sql/json_model--2.0.sql +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/sql/json_model.control +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/support.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/runtime/types.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/submodel.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/ts_export.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/url_cache.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model/utils.py +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model_compiler.egg-info/dependency_links.txt +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model_compiler.egg-info/entry_points.txt +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model_compiler.egg-info/not-zip-safe +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model_compiler.egg-info/requires.txt +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/json_model_compiler.egg-info/top_level.txt +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/package.json +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/pyproject.toml +0 -0
- {json_model_compiler-2.0.55 → json_model_compiler-2.0.57}/setup.cfg +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: JMC Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
- post
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v7
|
|
15
|
+
with:
|
|
16
|
+
submodules: true # for JSTS sources
|
|
17
|
+
- name: Install dependencies
|
|
18
|
+
run: apt install cloc make
|
|
19
|
+
- name: Build site
|
|
20
|
+
run: make _site
|
|
21
|
+
- name: Upload documentation artifact
|
|
22
|
+
id: deployment
|
|
23
|
+
uses: actions/upload-pages-artifact@v5
|
|
24
|
+
# with: path: _site
|
|
25
|
+
deploy:
|
|
26
|
+
environment:
|
|
27
|
+
name: github-pages
|
|
28
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
needs: build
|
|
31
|
+
steps:
|
|
32
|
+
- name: Deploy to GitHub Pages
|
|
33
|
+
id: deployment
|
|
34
|
+
uses: actions/deploy-pages@v5
|
|
@@ -11,7 +11,11 @@ jobs:
|
|
|
11
11
|
- name: Checkout project
|
|
12
12
|
uses: actions/checkout@v7
|
|
13
13
|
- name: Set up Python
|
|
14
|
-
uses: actions/setup-python@
|
|
14
|
+
uses: actions/setup-python@v7
|
|
15
|
+
with:
|
|
16
|
+
python-version: '3.13'
|
|
17
|
+
# NOTE google-re2 / bazel error on freethreaded true
|
|
18
|
+
# freethreaded: true
|
|
15
19
|
- name: Install Package Stuff
|
|
16
20
|
run: make dev.py
|
|
17
21
|
- name: Sanity Check
|
|
@@ -74,7 +74,7 @@ person.check_model_free()
|
|
|
74
74
|
As the JSON Model compiler is written in Python, it can be invoked directly for generating
|
|
75
75
|
a validation function.
|
|
76
76
|
|
|
77
|
-
Currently,
|
|
77
|
+
Currently, three functions are available:
|
|
78
78
|
|
|
79
79
|
- `model_checker_from_json`: generate a model from a JSON value which must be a valid model.
|
|
80
80
|
|
|
@@ -83,8 +83,12 @@ Currently, two functions are available:
|
|
|
83
83
|
|
|
84
84
|
This function expects a URL as a first parameter, which should dowload a JSON model possibly
|
|
85
85
|
as JSON or YAML.
|
|
86
|
+
- `ir_checker_from_file`: generate a model checker from a JSON intermediate representation.
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
This function expects a file path as a first parameter, or `-` for standard input, holding
|
|
89
|
+
an IR as generated with `jmc -C -F json`. See compiler option `--from-ir` about its limitations.
|
|
90
|
+
|
|
91
|
+
The following named parameters are available to both model functions:
|
|
88
92
|
|
|
89
93
|
- `auto`: boolean, whether to automatically map url to local path, default is _False_;
|
|
90
94
|
this feature is mostly for testing.
|
|
@@ -111,6 +115,15 @@ is_person = jm.model_checker_from_url("./Person.model.json")
|
|
|
111
115
|
print("hobbes is a person:", is_person({"name": "Hobbes", "birth": "2020-07-29"}))
|
|
112
116
|
```
|
|
113
117
|
|
|
118
|
+
Or, starting from a previously generated IR, eg with `jmc -C -F json -o Person.ir.json Person.model.json`:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
import json_model as jm
|
|
122
|
+
|
|
123
|
+
is_person = jm.ir_checker_from_file("./Person.ir.json")
|
|
124
|
+
print("hobbes is a person:", is_person({"name": "Hobbes", "birth": "2020-07-29"}))
|
|
125
|
+
```
|
|
126
|
+
|
|
114
127
|
## JavaScript API
|
|
115
128
|
|
|
116
129
|
Model compilation to JavaScript generates either a module (`.mjs`) or a node script (`.js`),
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## Current Tasks
|
|
4
4
|
|
|
5
|
-
- [ ]
|
|
5
|
+
- [ ] pr: switch cristalina to post after release
|
|
6
|
+
- [ ] docker: install missing `Algorithm::LUHN` for perl JSB
|
|
6
7
|
- [ ] bench: case failures handling needs some fixing
|
|
7
|
-
- [ ]
|
|
8
|
-
- [ ] tests:
|
|
8
|
+
- [ ] tests: allow to skip some tests with make, depending on available runtimes
|
|
9
|
+
- [ ] tests: automate bench launch with a cron job?
|
|
9
10
|
- [ ] tests: check more bad urls (eg bad %-escape)
|
|
10
11
|
- [ ] tests: check pydantic generated classes
|
|
11
12
|
- [ ] static: use combined type test and value extraction when available?
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
- [ ] perf: keep only one java run?
|
|
36
37
|
- [ ] perf: check median hack for run times
|
|
37
38
|
- [ ] perf: show schema to model conversion times
|
|
38
|
-
- [ ] pr: better document optimizations, eg add
|
|
39
|
+
- [ ] pr: better document optimizations, eg add compiler optimization page
|
|
39
40
|
- [ ] optim: collect and display stats about what works
|
|
40
41
|
- [ ] c-backend: improve unique with hash using int set?
|
|
41
42
|
- [ ] c-backend: improve str hash?
|
|
@@ -146,8 +147,8 @@
|
|
|
146
147
|
- [x] model: write a model for MCP
|
|
147
148
|
- [x] tests: add a few tests for MCP model
|
|
148
149
|
- [x] export: generate ts interfaces
|
|
149
|
-
- [
|
|
150
|
-
- [
|
|
150
|
+
- [x] model: fix IR model and tests
|
|
151
|
+
- [x] front: IR re-entrance
|
|
151
152
|
- [ ] tests: generate valid (pseudo-random) values
|
|
152
153
|
- [ ] tests: generate invalid minimal, maximal, pseudo-random values
|
|
153
154
|
- [ ] tests: generate invalid values on each constraint
|
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
# JSON Model Compiler Benchmark Artifacts
|
|
2
2
|
|
|
3
3
|
The purpose of this benchmark is to compare JSON value validation performance for
|
|
4
|
-
the
|
|
5
|
-
of the syntax used to express these constraints.
|
|
4
|
+
the same constraints, independently of the syntax used to express these constraints.
|
|
6
5
|
|
|
7
6
|
These artifacts compare
|
|
8
|
-
[JSON Model Compiler (
|
|
9
|
-
[JSON Schema Utils (
|
|
7
|
+
[JSON Model Compiler (JMC)](https://github.com/clairey-zx81/json-model) generated code using the
|
|
8
|
+
[JSON Schema Utils (JSU)](https://hub.docker.com/repository/docker/zx80/json-schema-utils)
|
|
10
9
|
schema to model converter in C, JS, Java (GSON, Jackson and JSONP using Johnzon) and Python with
|
|
11
|
-
[Sourcemeta Blaze CLI (
|
|
10
|
+
[Sourcemeta Blaze CLI (SBC)](https://github.com/sourcemeta/jsonschema) using test cases and values
|
|
12
11
|
from [JSON Schema Benchmark](https://github.com/sourcemeta-research/jsonschema-benchmark).
|
|
13
12
|
|
|
14
13
|
## Recent Artifacts
|
|
15
14
|
|
|
16
|
-
Overall, depending on the chosen metrics,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- [2026072200](benchmarks/2026072200.md) clang, predefs, jsu 0.9.13/jmc 2.0.52 vs sbc 16.2.1, 11 runs, 1000 iterations.
|
|
24
|
-
- [2026071700](benchmarks/2026071700.md) clang, predefs, jsu 0.9.13/jmc 2.0.52 vs sbc 16.2.0, 11 runs, 1000 iterations.
|
|
25
|
-
- [2026071302](benchmarks/2026071302.md) clang, predefs, jsu 0.9.13/jmc 2.0.52 vs sbc 16.1.0, 11 runs, 1000 iterations.
|
|
26
|
-
- [2026071000](benchmarks/2026071000.md) clang, no predefs, jsu 0.9.12/jmc 2.0.51 vs sbc 16.1.0, 11 runs, 1000 iterations.
|
|
27
|
-
- [2026070900](benchmarks/2026070900.md) clang, no predefs, jsu 0.9.11/jmc 2.0.51 vs sbc 16.1.0, 11 runs, 1000 iterations.
|
|
28
|
-
- [2026062200](benchmarks/2026062200.md) clang, no predefs, jsu 0.9.11/jmc 2.0.51 vs sbc 16.0.0, 11 runs, 1000 iterations.
|
|
29
|
-
- [2026062102](benchmarks/2026062102.md) clang, no predefs, jsu 0.9.10/jmc 2.0.50 vs sbc 16.0.0, 11 runs, 1000 iterations.
|
|
15
|
+
Overall, depending on the chosen metrics, JMC with the C backend is 50-100% faster
|
|
16
|
+
than Blaze on average to validate JSON values in these artifacts.
|
|
17
|
+
|
|
18
|
+
BENCHES
|
|
19
|
+
|
|
20
|
+
Options: _content_ validate string contents (format/predef), _fix_ improved models (bug fixes)
|
|
21
|
+
or _no_ for strictly schema compatible models.
|
|
30
22
|
|
|
31
23
|
## Benchmarking Script
|
|
32
24
|
|
|
@@ -43,17 +35,17 @@ It is typically started on a large host with the
|
|
|
43
35
|
which will spawn the necessary containers:
|
|
44
36
|
|
|
45
37
|
```sh
|
|
46
|
-
JMC=latest JMC_OPTS="--
|
|
47
|
-
nohup ./start_bench.sh latest -p
|
|
38
|
+
JMC=latest JMC_OPTS="--predef --cc=clang" \
|
|
39
|
+
nohup ./start_bench.sh latest -p 12 -l 1000 -r 5 -c &
|
|
48
40
|
# in the generated directory, look for the summary markdown and radar json files.
|
|
49
41
|
```
|
|
50
42
|
|
|
51
43
|
The main script options are:
|
|
52
44
|
|
|
53
|
-
- `-p PARA` parallelism (
|
|
45
|
+
- `-p PARA` parallelism (less that the number of available cores, default is _8_)
|
|
54
46
|
- `-l LOOP` loop iterations for performance average (at least _1000_, the default)
|
|
55
47
|
- `-r RUNS` number of runs (odd number, default is _3_)
|
|
56
|
-
-
|
|
48
|
+
- `-c` validate contents (default is _not_)
|
|
57
49
|
|
|
58
50
|
## Benchmarking Conditions
|
|
59
51
|
|
|
@@ -77,41 +69,43 @@ the run stops as soon as possible.
|
|
|
77
69
|
Note that performance figures **must** be taken with a pinch of salt, please consider
|
|
78
70
|
the following caveats, and others:
|
|
79
71
|
|
|
80
|
-
-
|
|
72
|
+
- Do you value latency or throuput or resource consumption? the answer is not so obvious,
|
|
81
73
|
probably you should prefer a high throuput _if_ the latency is good enough, but these
|
|
82
74
|
benchmark actually measure raw latency.
|
|
83
|
-
-
|
|
75
|
+
- Test cases may or may not be representative of specific use cases,
|
|
84
76
|
especially wrt schema/model and value sizes.
|
|
85
|
-
-
|
|
77
|
+
- The overall load on the test host can impact measures, as well as power control
|
|
86
78
|
features which adjust the cpu frequency in real time, thus the frequency may be set
|
|
87
79
|
explicitely, and effort are made to cap the load to limit its impact on measures.
|
|
88
80
|
- Relying on hyper-threading can reduce performance for simple one thread tasks,
|
|
89
81
|
so it is often disabled.
|
|
90
|
-
-
|
|
82
|
+
- The measure overhead is estimated and deduced from the performance figures by default,
|
|
91
83
|
which leads to potentially fuzzy results when testing very small values.
|
|
92
|
-
-
|
|
84
|
+
- Compilers, libraries and other design and updates can have dramatic effects:
|
|
93
85
|
for faster parsing, a library may use linked-list for properties, which means
|
|
94
86
|
that retrieving a given property value will cost more than a library which uses
|
|
95
87
|
a hash table which is more costly to build.
|
|
96
|
-
-
|
|
88
|
+
- Before version _16.0_, blaze does _not_ implement checking string values (eg dates, url…),
|
|
97
89
|
so these checks may be disactivated (see _Contents_ in _Parameters_) for fairness,
|
|
98
90
|
reducing the results significance.
|
|
99
|
-
-
|
|
91
|
+
- Blaze uses its own special-purpose JSON representation which include a precomputed
|
|
100
92
|
custom hash for string comparisons, aleviating the need to actually compare strings
|
|
101
93
|
in most cases.
|
|
102
|
-
-
|
|
94
|
+
- Blaze is a C++ library, if interfaced from another language, the cost of translating
|
|
103
95
|
the JSON representation to this library should be taken into account;
|
|
104
96
|
in contrast, jmc uses native JSON representations in the target ecosystem and generate
|
|
105
97
|
validation code around it.
|
|
106
|
-
-
|
|
98
|
+
- Due to intrinsic limitations of the underlying libraries and the quality of models or schemas,
|
|
107
99
|
some results may differ, mostly for good reasons: regex incompatibilities, stricter
|
|
108
100
|
model definitions compared to lax schemas…
|
|
109
|
-
-
|
|
101
|
+
- It is unclear whether JIT optimizations (eg Java and JS) may work around the
|
|
110
102
|
benchmarking loops and report undue very fast performances, eg on the GeoJSON case.
|
|
111
|
-
-
|
|
103
|
+
- Some execution environment (eg Java) take advantage of parallelism with threads (possibly
|
|
112
104
|
for the garbage collector and JIT), which may or may not be a blessing: it can reduce
|
|
113
105
|
the apparent latency (eg the gc runs in another thread) but have a detrimental overall
|
|
114
106
|
effect on throughput and costs as more cpu ressources are spent on the same task.
|
|
107
|
+
- Test values are mostly valid, which is representative of a typical use case, but
|
|
108
|
+
the tool accuracy should be asserted elsewhere with failing cases.
|
|
115
109
|
|
|
116
110
|
## Other Artifacts
|
|
117
111
|
|
|
@@ -127,13 +121,16 @@ It should be noted that benchmarking conditions are quite different compared to
|
|
|
127
121
|
1. There is no loop to compute an average performance, but an initial _cold_ one-shot measure,
|
|
128
122
|
a warming phase loop (up to 1000 rounds, kept under 10 seconds) and a _hot_ one-shot measure:
|
|
129
123
|
This may tend to mask effects from occasional GC runs.
|
|
130
|
-
2.
|
|
124
|
+
2. Performance data are collected on all tests taken together: this is less favorable to cache
|
|
125
|
+
effects, and makes it impossible to investigate individual test figures.
|
|
126
|
+
3. The benchmark focuses on schema conformance, including (buggy) schemas which
|
|
131
127
|
are mostly dead code: It rejects tools which do not validate all strictly conformant
|
|
132
128
|
values, even if these values would be rejected by the target application.
|
|
133
129
|
The model used are strictly converted from schemas, native models are not used
|
|
134
130
|
even if available and schemas are not fixed for typical errors (eg misplaced keywords).
|
|
135
|
-
3. Three schemas (`krakend`, `stale` and `yamllint`) in the test suites have been
|
|
136
|
-
[edited](https://github.com/sourcemeta-research/jsonschema-benchmark/commit/ad109eb210c0939bd8393da28d8212f75c1c2d92),
|
|
137
|
-
especially to deal corner cases issues with `$ref` under version 7 and prior,
|
|
138
|
-
thus do not conform to the initial official schemas.
|
|
139
131
|
4. The benchmark _removes_ format assertions before testing schemas.
|
|
132
|
+
|
|
133
|
+
Notably, three schemas (`krakend`, `stale` and `yamllint`) in the test suites have been
|
|
134
|
+
[edited](https://github.com/sourcemeta-research/jsonschema-benchmark/commit/ad109eb210c0939bd8393da28d8212f75c1c2d92),
|
|
135
|
+
as a work around corner cases issues with `$ref` under version 7 and prior,
|
|
136
|
+
thus do not conform to the initial official schemas.
|
|
@@ -132,6 +132,15 @@ make clean.js js # regenerate js stuff (and other languages)
|
|
|
132
132
|
make foo.CLEAN foo.ALL # clean/regenerate all stuff for case "foo"
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
+
### Tests in Docker Image
|
|
136
|
+
|
|
137
|
+
C, Java, JS, Perl and Python tests can run inside the docker image.
|
|
138
|
+
Some tests are skip, especially PL/pgSQL and JSON Schema Test Suite tests.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
jmc exec make -C /app/json-model/tests check
|
|
142
|
+
```
|
|
143
|
+
|
|
135
144
|
## Code Doc
|
|
136
145
|
|
|
137
146
|
Read sources…
|
|
@@ -23,6 +23,7 @@ venv/.init:
|
|
|
23
23
|
|
|
24
24
|
venv/.dev: venv/.init
|
|
25
25
|
pip install -e .[dev]
|
|
26
|
+
[ -d ../json-schema-utils ] && pip intall -e ../json-schema-utils
|
|
26
27
|
touch $@
|
|
27
28
|
|
|
28
29
|
venv/.dist: venv/.dev
|
|
@@ -66,7 +67,8 @@ clean.js:
|
|
|
66
67
|
|
|
67
68
|
.PHONY: clean.site
|
|
68
69
|
clean.site:
|
|
69
|
-
$(RM) site/MODELS.md site/JMC.md site/ABOUT.md .about.md
|
|
70
|
+
$(RM) site/MODELS.md site/JMC.md site/ABOUT.md site/BENCH.md .about.md
|
|
71
|
+
$(RM) -r _site
|
|
70
72
|
|
|
71
73
|
.PHONY: clean.py
|
|
72
74
|
clean.py:
|
|
@@ -154,8 +156,11 @@ site/MODELS.md: Makefile models/
|
|
|
154
156
|
site/JMC.md: json_model/data/jmc.pod
|
|
155
157
|
pod2markdown $< > $@
|
|
156
158
|
|
|
159
|
+
site/BENCH.md: ./bench.sh
|
|
160
|
+
./$< > $@
|
|
161
|
+
|
|
157
162
|
# generate twice to include the about page in the counts
|
|
158
|
-
site/ABOUT.md: ./about.sh site/JMC.md site/MODELS.md
|
|
163
|
+
site/ABOUT.md: ./about.sh site/JMC.md site/MODELS.md site/BENCH.md
|
|
159
164
|
./$< > $@
|
|
160
165
|
./$< > .about.md
|
|
161
166
|
mv .about.md $@
|
|
@@ -166,6 +171,11 @@ jmc.1: json_model/data/jmc.pod dev
|
|
|
166
171
|
year=$$(date +%Y)
|
|
167
172
|
pod2man $< | sed "s/^\.TH JMC 1.*/.TH JMC 1 $$year \"v$$version\" \"User Documentation\"/" > $@
|
|
168
173
|
|
|
174
|
+
_site: build.site
|
|
175
|
+
cp -rL site _site
|
|
176
|
+
find _site -type d -print | xargs chmod a+rx
|
|
177
|
+
find _site -type f -print | xargs chmod a+r
|
|
178
|
+
|
|
169
179
|
.PHONY: www
|
|
170
180
|
www: build.site
|
|
171
181
|
# http://localhost:3000
|
|
@@ -178,7 +188,7 @@ www: build.site
|
|
|
178
188
|
-include local.mk
|
|
179
189
|
|
|
180
190
|
.PHONY: build.site
|
|
181
|
-
build.site: site/MODELS.md site/JMC.md site/ABOUT.md
|
|
191
|
+
build.site: site/MODELS.md site/JMC.md site/ABOUT.md site/BENCH.md
|
|
182
192
|
|
|
183
193
|
.PHONY: publish.site
|
|
184
194
|
publish.site: build.site
|
|
@@ -40,27 +40,21 @@ JSON Model design and implementation are discussed in research papers and report
|
|
|
40
40
|
JSON Model compiler and runtimes are distributed through the packages published for
|
|
41
41
|
each language ecosystem:
|
|
42
42
|
|
|
43
|
-
- [JSON Model Compiler Python Package](https://pypi.org/project/json-model-compiler/)
|
|
44
|
-
|
|
43
|
+
- [JSON Model Compiler Python Package](https://pypi.org/project/json-model-compiler/)
|
|
45
44
|
Ready to use JSON Model compiler and runtime for a Python environment, from _PyPI_.
|
|
46
45
|
|
|
47
|
-
- [JSON Model Compiler Container Image `docker.io/zx80/jmc`](https://hub.docker.com/r/zx80/jmc)
|
|
48
|
-
|
|
46
|
+
- [JSON Model Compiler Container Image `docker.io/zx80/jmc`](https://hub.docker.com/r/zx80/jmc)
|
|
49
47
|
Ready to use JSON Model compiler and runtimes (Python, C, JavaScript, Perl, Java)
|
|
50
48
|
as a Docker image, from _Docker Hub_.
|
|
51
49
|
|
|
52
|
-
- [JSON Model JavaScript Runtime](https://www.npmjs.com/package/json_model_runtime)
|
|
53
|
-
|
|
50
|
+
- [JSON Model JavaScript Runtime](https://www.npmjs.com/package/json_model_runtime)
|
|
54
51
|
JS runtime for generated code, from _npm Registry_.
|
|
55
52
|
|
|
56
|
-
- [JSON Model PL/pgSQL Runtime](https://pgxn.org/dist/json_model/)
|
|
57
|
-
|
|
53
|
+
- [JSON Model PL/pgSQL Runtime](https://pgxn.org/dist/json_model/)
|
|
58
54
|
PL/pgSQL runtime for generated code, from _PGXN_.
|
|
59
55
|
|
|
60
|
-
- [JSON Model Perl Runtime](https://metacpan.org/pod/JSON::JsonModel)
|
|
61
|
-
|
|
56
|
+
- [JSON Model Perl Runtime](https://metacpan.org/pod/JSON::JsonModel)
|
|
62
57
|
Perl runtime for generated code, from _CPAN_.
|
|
63
58
|
|
|
64
|
-
- [JSON Model Java Runtime](https://central.sonatype.com/artifact/org.json-model/json-model)
|
|
65
|
-
|
|
59
|
+
- [JSON Model Java Runtime](https://central.sonatype.com/artifact/org.json-model/json-model)
|
|
66
60
|
Java runtime for generated code, from _Maven Central_.
|
|
@@ -1,11 +1,48 @@
|
|
|
1
1
|
# JSON Model Compiler Versions
|
|
2
2
|
|
|
3
|
+
## 2.0.57 on 2026-08-18
|
|
4
|
+
|
|
5
|
+
- bench: improve reporting text
|
|
6
|
+
- bench: add tests on HT and Hz when starting bench
|
|
7
|
+
- pr: improve bench and about pages
|
|
8
|
+
- models: improve jmc-related models
|
|
9
|
+
- tests: merge testing files against a model in a directory
|
|
10
|
+
- tests: add jmc-bench model test
|
|
11
|
+
- bench: ensure fix/no-fix consistency
|
|
12
|
+
- dev: improve dev environment init
|
|
13
|
+
- tests: run tests inside docker image
|
|
14
|
+
- perl: fix bad double post condition
|
|
15
|
+
- perl: report error location
|
|
16
|
+
- tests: enable reporting with perl
|
|
17
|
+
- perl: fix uncleaned reports on pass
|
|
18
|
+
- perl: fix encoding of error message to use utf8
|
|
19
|
+
- perl: fix non deterministic output linked to `each`
|
|
20
|
+
- perl: fix model escaping in error messages
|
|
21
|
+
- bench: add cron job performance script
|
|
22
|
+
- bench: report summary speedup in radar labels
|
|
23
|
+
- pr: generate `BENCH.md` page links
|
|
24
|
+
- tests: test token push
|
|
25
|
+
- pr: create deployment script and cron and test
|
|
26
|
+
|
|
27
|
+
## 2.0.56 on 2026-08-07
|
|
28
|
+
|
|
29
|
+
- bench: use local models instead of fetching urls
|
|
30
|
+
- bench: add option to change the bench reference
|
|
31
|
+
- bench: rework presentation and comments
|
|
32
|
+
- bench: allow to only keep Java with GSON lib
|
|
33
|
+
- bench: add option to change standard comments depending on test conditions
|
|
34
|
+
- bench: add option to skip showing _best_ row in performance summary
|
|
35
|
+
- bench: when comparing to a reference, count betters
|
|
36
|
+
- front: ~allow to load `.errors.json` file to filter out expected errors~
|
|
37
|
+
- pr: improved pages and descriptions
|
|
38
|
+
- pr: improve demonstration models comments and indentation
|
|
39
|
+
- predef: allow amqp URLs
|
|
40
|
+
- model: update and test `jmc-ir.model.json`
|
|
41
|
+
- front: allow IR re-entrance, including tests
|
|
42
|
+
|
|
3
43
|
## 2.0.55 on 2026-07-31
|
|
4
44
|
|
|
5
45
|
- front: try again to display a relevant version under dev
|
|
6
|
-
- perf: improve generated reports
|
|
7
|
-
- model: add example model for JMC benchmark radar data
|
|
8
|
-
- pr: check `json-model.org` SEO - listed on Google console but some pages are not indexed
|
|
9
46
|
- models: add model for `*.errors.json` files
|
|
10
47
|
- tests: use `.errors.json` file to manage value errors, instead of rough counts
|
|
11
48
|
- tests: use `.errors.json` file to manage ts export errors
|
|
@@ -124,9 +124,13 @@ cloc --md \
|
|
|
124
124
|
json_model/runtime \
|
|
125
125
|
| sed -n -e '/SUM/s/\([0-9][0-9]*\)/**\1**/g;s/SUM:/**Total**/;/^$/,$p' | grep -v '^-[-|]*$'
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
n_valid_models=$(ls tests/[mr]*/*.model.json | wc -l)
|
|
128
|
+
n_invalid_models=$(ls tests/bads/*.model.json | wc -l)
|
|
129
|
+
n_models=$(( $n_valid_models + $n_invalid_models ))
|
|
128
130
|
n_values=$(cat tests/[mrb]*/*.values.json | egrep '(true|false)' | wc -l)
|
|
129
131
|
n_value_files=$(ls tests/[mrb]*/*.values.json | wc -l)
|
|
132
|
+
n_error_files=$(ls tests/[mrb]*/*.errors.json | wc -l)
|
|
133
|
+
# == $n_valid_models?
|
|
130
134
|
n_schemas=$(echo tests/[mrb]*/*.schema.json | wc -w)
|
|
131
135
|
n_test_schemas=$(grep '^ "schema": {' tests/JSON-Schema-Test-Suite/tests/*/*.json | wc -l)
|
|
132
136
|
n_test_files=$(ls tests/JSON-Schema-Test-Suite/tests/*/*.json | wc -l)
|
|
@@ -134,7 +138,8 @@ model_locs=$(cat tests/[mrb]*/*.model.json | wc -l)
|
|
|
134
138
|
n_eg_models=$(ls models/*.model.json | wc -l)
|
|
135
139
|
eg_models_locs=$(cat models/*.model.json | wc -l)
|
|
136
140
|
|
|
137
|
-
|
|
141
|
+
# valid models are re-counted for IR checks
|
|
142
|
+
all_values=$(( $n_values + $n_models + $n_valid_models + $n_value_files + $n_error_files + $n_schemas + $n_test_schemas + $n_test_files ))
|
|
138
143
|
|
|
139
144
|
cat <<EOF
|
|
140
145
|
|
|
@@ -149,9 +154,10 @@ on a set of test vectors.
|
|
|
149
154
|
- number of test JSON models: _${n_models}_
|
|
150
155
|
- total test JSON model locs: _${model_locs}_
|
|
151
156
|
- number of test vector JSON values: _${n_values}_
|
|
152
|
-
- all tested JSON values (including models, generated schemas and test suite schemas): _${all_values}_
|
|
157
|
+
- all tested JSON values (including models, generated schemas and IR, and test suite schemas): _${all_values}_
|
|
153
158
|
|
|
154
|
-
Example models cover typical use cases and demonstrate
|
|
159
|
+
[Example models](https://json-model.org/MODELS) cover typical use cases and demonstrate
|
|
160
|
+
JSON Model power and ease of expression.
|
|
155
161
|
|
|
156
162
|
- number of example models: _${n_eg_models}_
|
|
157
163
|
- total example model locs: _${eg_models_locs}_
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#! /bin/bash
|
|
2
|
+
#
|
|
3
|
+
# generate BENCH.md page with links to available benchmarks
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
PYPI="https://pypi.org/project"
|
|
7
|
+
|
|
8
|
+
get_version()
|
|
9
|
+
{
|
|
10
|
+
local what=$1 file=$2
|
|
11
|
+
local line=$(grep "$what version:" < $file)
|
|
12
|
+
line=${line#*:\*\* }
|
|
13
|
+
line=${line%% *}
|
|
14
|
+
echo $line
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
sed -ne '1,/BENCHES/p' < BENCH.md | grep -v '^BENCHES$'
|
|
18
|
+
|
|
19
|
+
for artifact in $(ls site/benchmarks/*.md | sort -r) ; do
|
|
20
|
+
link=${artifact#site/}
|
|
21
|
+
name=${link#benchmarks/}
|
|
22
|
+
name=${name%.md}
|
|
23
|
+
jsu=$(get_version jsu $artifact)
|
|
24
|
+
jmc=$(get_version jmc $artifact)
|
|
25
|
+
sbc=$(get_version jsonschema-cli $artifact)
|
|
26
|
+
message=""
|
|
27
|
+
[ "$(grep 'content:.*yes' $artifact)" ] && message+="content" || message+="no content"
|
|
28
|
+
[ "$(grep 'JSU_OPT.*--no-id' $artifact)" ] && message+=", no id"
|
|
29
|
+
[ "$(grep 'fix:.*yes' $artifact)" ] && message+=", fix" || message+=", no fix"
|
|
30
|
+
echo "- Artifact [$name]($link) [JMC $jmc]($PYPI/json-model-compiler/$jmc/)/[JSU $jsu]($PYPI/json-schema-utils/$jsu/) vs [SBC $sbc](https://github.com/sourcemeta/jsonschema/releases/tag/v$sbc), $message."
|
|
31
|
+
done
|
|
32
|
+
|
|
33
|
+
sed -ne '/BENCHES/,$p' < BENCH.md | grep -v '^BENCHES$'
|
|
@@ -8,6 +8,7 @@ from .script import (
|
|
|
8
8
|
jmc_script, jmc_version,
|
|
9
9
|
model_from_json, model_from_url, model_from_str,
|
|
10
10
|
model_checker, model_checker_from_url, model_checker_from_json,
|
|
11
|
+
ir_checker_from_file,
|
|
11
12
|
)
|
|
12
13
|
|
|
13
14
|
__ALL__ = [
|
|
@@ -15,4 +16,5 @@ __ALL__ = [
|
|
|
15
16
|
jmc_script, jmc_version,
|
|
16
17
|
model_from_json, model_from_url, model_from_str,
|
|
17
18
|
model_checker, model_checker_from_url, model_checker_from_json,
|
|
19
|
+
ir_checker_from_file,
|
|
18
20
|
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.0.57
|
|
@@ -119,6 +119,16 @@ Accept JSON with objects containing duplicated properties.
|
|
|
119
119
|
|
|
120
120
|
Allow some extensions to help with JSU back-end implementation.
|
|
121
121
|
|
|
122
|
+
=item B<--from-ir>/B<-fir>
|
|
123
|
+
|
|
124
|
+
Read a JSON intermediate representation, as generated with C<-C -F json>, instead of a
|
|
125
|
+
JSON model, so that only code generation (C<-C>) is available.
|
|
126
|
+
|
|
127
|
+
The entry name and package are taken from the IR, and reporting must have been enabled
|
|
128
|
+
when it was generated. An IR generated with C<-F json> targets a generic back-end: the
|
|
129
|
+
regenerated code may differ from a direct compilation, and PL/pgSQL is not supported.
|
|
130
|
+
Pass the tuning options when generating the IR for a closer match.
|
|
131
|
+
|
|
122
132
|
=back
|
|
123
133
|
|
|
124
134
|
=head2 Processing
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#! /usr/bin/perl -CDSA
|
|
@@ -1119,11 +1119,11 @@ def optimizeIR(code: list[Jsonable], *, shortcuts: dict[str, str], partial: bool
|
|
|
1119
1119
|
|
|
1120
1120
|
|
|
1121
1121
|
def _t2s(tvar: type|None) -> str:
|
|
1122
|
-
"""Type to
|
|
1122
|
+
"""Type to IR type name conversion."""
|
|
1123
1123
|
if tvar is None or tvar is type(None):
|
|
1124
1124
|
return "null"
|
|
1125
1125
|
elif tvar is bool:
|
|
1126
|
-
return "
|
|
1126
|
+
return "bool"
|
|
1127
1127
|
elif tvar is int:
|
|
1128
1128
|
return "integer"
|
|
1129
1129
|
elif tvar is float:
|
|
@@ -1209,8 +1209,11 @@ class IRep(Language):
|
|
|
1209
1209
|
def esc(self, s: str) -> StrExpr:
|
|
1210
1210
|
return _j("esc", s=s)
|
|
1211
1211
|
|
|
1212
|
+
def esc_msg(self, s: str) -> StrExpr:
|
|
1213
|
+
return Language.esc(self, s)
|
|
1214
|
+
|
|
1212
1215
|
def json_cst(self, j: Jsonable) -> JsonExpr:
|
|
1213
|
-
return _j("jc",
|
|
1216
|
+
return _j("jc", j=j)
|
|
1214
1217
|
|
|
1215
1218
|
def const(self, c: Jsonable) -> Expr:
|
|
1216
1219
|
return _j("cst", c=c)
|
|
@@ -1490,7 +1493,7 @@ def _s2t(tname: str|None) -> type:
|
|
|
1490
1493
|
"""String to type reconversion."""
|
|
1491
1494
|
match tname:
|
|
1492
1495
|
case None|"null": return None
|
|
1493
|
-
case "bool"
|
|
1496
|
+
case "bool": return bool
|
|
1494
1497
|
case "int"|"integer": return int
|
|
1495
1498
|
case "float"|"number": return float
|
|
1496
1499
|
case "Number": return Number
|
|
@@ -1669,6 +1672,13 @@ def _eval(jv: Jsonable, gen: Language) -> Block|Expr:
|
|
|
1669
1672
|
# probably a string, eg a variable name
|
|
1670
1673
|
return jv
|
|
1671
1674
|
|
|
1675
|
+
def ir_evaluate(ir: Jsonable, lang: Language) -> str:
|
|
1676
|
+
"""Generate the target language source code from a full code JSON IR."""
|
|
1677
|
+
code = _eval(ir, lang)
|
|
1678
|
+
assert isinstance(code, list), "full code JSON IR"
|
|
1679
|
+
|
|
1680
|
+
return lang.code_to_str(lang.filter_code(code))
|
|
1681
|
+
|
|
1672
1682
|
def evaluate(ir: Code, lang: Language) -> Code:
|
|
1673
1683
|
code = Code(lang, ir._entry, ir._executable, ir._package, ir._mark)
|
|
1674
1684
|
code._predefs = ir._predefs
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
|
+
import json
|
|
2
3
|
from .mtypes import Jsonable, JsonScalar, Number, TestHint, Conditionals, Block
|
|
3
4
|
from .mtypes import Var, JsonExpr, BoolExpr, IntExpr, NumExpr, StrExpr, PathExpr, Expr
|
|
4
5
|
from .predefs import BOOL_MODEL_PREDEFS, INT_MODEL_PREDEFS, FLOAT_MODEL_PREDEFS, STR_MODEL_PREDEFS
|
|
@@ -571,6 +572,10 @@ class Language:
|
|
|
571
572
|
'"'
|
|
572
573
|
)
|
|
573
574
|
|
|
575
|
+
def esc_msg(self, s: str) -> StrExpr:
|
|
576
|
+
"""Escape string for inclusion in a report message."""
|
|
577
|
+
return json.dumps(s)
|
|
578
|
+
|
|
574
579
|
def skip(self) -> Block:
|
|
575
580
|
"""Skip one line."""
|
|
576
581
|
return [ "" ]
|