sml

SML { ❄ }

Downloads Questions, bug reports, or just to say hi: sal@mail.swebase.cn 中文 EN

Download SML { ❄ }

All downloads are released under the MulanPSL-2.0 license; source is on the repo. Every language binding calls the Rust cdylib sml/libsml through the C-ABI (c/sml_rs.h v3); the read path traverses the value tree directly, with no JSON round-trip; source packages ship with LICENSE and README, ready to embed into your project.

Download

ItemVersionNotesDownload
VS Code Extension0.4.3 Editor plugin: highlighting / diagnostics / completion / jump / formatting + SML-specific editing Download
Python0.1.0 ctypes binding to the cdylib, zero third-party deps; value-tree traversal Download
Ruby0.1.0 fiddle binding to the cdylib, zero gem deps; value-tree traversal Download
Java0.1.0 JDK Panama FFM binding to the cdylib; value-tree traversal Download
Go0.1.0 cgo binding to the cdylib; value-tree traversal Download
C#0.1.0 P/Invoke binding to the cdylib (not verified locally) Download
C0.6.3 Pure C99 self-contained impl, or the Rust bridge header — pick one Download
C++0.6.3 C++17 zero-dependency impl, or the Rust bridge header — pick one Download
JavaScript0.6.3 Zero-dependency ESM, same parser as the playground Download
Lua0.6.3 Lua binding, shipped as an in-repo reference implementation Download

Debian / Ubuntu packages (libswsml · amd64)

System packages for the Rust cdylib backend (swsml 0.6.3, SONAME libswsml.so.0). Install and go: the shared library is registered with ldconfig, headers land in /usr/include/sml, and pkg-config is wired up. Split by backend into four packages:

PackageVersionNotesDownload
libswsml00.6.3Runtime: Rust cdylib C-ABI (libswsml.so.0), full v1..v4 feature setDownload
libswsml-dev0.6.3C development: sml_rs.h + libswsml.so + pkg-config swsmlDownload
libswsml-cpp00.6.3C++ runtime: RAII wrapper (libswsml_cpp.so.0)Download
libswsml-cpp-dev0.6.3C++ development: sml_rs.hpp + pkg-config swsml_cppDownload
# runtime
sudo dpkg -i libswsml0_0.6.3_amd64.deb libswsml-cpp0_0.6.3_amd64.deb
# development (headers + pkg-config)
sudo dpkg -i libswsml-dev_0.6.3_amd64.deb libswsml-cpp-dev_0.6.3_amd64.deb
# then: gcc app.c $(pkg-config --cflags --libs swsml) -o app
#       g++ -std=c++17 app.cpp $(pkg-config --cflags --libs swsml_cpp) -o app

amd64 only for now; build other architectures with the in-repo packaging/build_deb.sh --arch <arch>. The name deliberately uses libswsml to avoid colliding with Debian’s official libSML / libsml-dev (smart-meter ecosystem). Depends: libc6, libgcc-s1 (C++ packages also need libstdc++6).

Checksums (SHA256)

Verify after downloading. The block below is sha256sum -c-compatible — save it as SHA256SUMS next to the downloaded files and run sha256sum -c SHA256SUMS to check them all at once:

4a325ac778f6c666d47430fd394ad390f74b722440c2563f811ab240ce27375d  sml-lang-0.4.3.vsix
928c37067c834865afd88ee06149587ac1bcdbdab552775ca1c15cbf97ed9af6  sml-python-0.1.0.zip
85250c426e5724ed26371ed7f8690cb7695c40e7e157379d1ab62827ad23a81c  sml-ruby-0.1.0.zip
12a224512fbdb2e60b4fd82ae6912f801990eec50108ae14aad21e7d50ecf1a8  sml-java-0.1.0.zip
4099808da508f1fd8cf4e15948c54aec84690b035255a12a131fe451287a70b2  sml-go-0.1.0.zip
1e9a7b1ca0e87ba7d6554cfee9f709c6acb3723c203cb088f53b0f3921fc02dd  sml-csharp-0.1.0.zip
09ee5772007c106a684cd7b97ac01821863ff8aa371f8a01e71bda38c6621cd1  sml-c-0.6.3.zip
02ef4a95542a6fd6af9443cef58a494cdf3695441ab5a553b9ce916ff109e774  sml-cpp-0.6.3.zip
584d05e7be2958333e09cb20d21f25ebc0e7fecf8ad3da8d733161e4ebb6dd30  sml-javascript-0.6.3.zip
9e6688d1e4326cb3bf63bbf62347f49607b62a0ca7b35ffa0d1ed55ad37c27e9  sml-lua-0.6.3.zip
c5ded19ba858252c4b06ef1d783dba3f70c4d67451c89a98c5063623170f4c74  libswsml0_0.6.3_amd64.deb
06cbb1ed4f255ad8c23b1aba62792dc29b01e345cf74a3a401a4eada9d8c79ba  libswsml-dev_0.6.3_amd64.deb
b51d0fa9e738c3206d32c84745a1a8687f861b74debcd6be0557ffcb7bb3277e  libswsml-cpp0_0.6.3_amd64.deb
e174fa652aff0755d19ad99779ce1b3a1b516d8c6c62422f96f1e7e41aa6dd1b  libswsml-cpp-dev_0.6.3_amd64.deb

Implementation Notes (click to expand)

VS Code Extension · 0.4.3

Provides VSCode with SML syntax highlighting, diagnostics, completion, hover, jump and formatting, plus edit-time capabilities “that only make sense in SML”:

  • Hover: a contract name (@is Server) shows the contract declaration + the actual structure with defaults filled by the parser; a block name (primary {) shows its path (database.primary), the contract it applies and the filled structure

  • Go to definition: @is Server → @contract Server, &base → @base { }

  • include / namespace navigation: F12 on a path jumps to the included file, hover shows “top-level keys of that file”; a namespace alias (as db) hover shows “which keys this namespace actually has”, F12 jumps to the included file; a reference (db.host) hover tells you which file/definition it comes from and F12 jumps there

  • Special colors: select a word → right-click “apply special color”, written into the workspace HL-cfg.sml (travels with the repo, hand-editable); by default it only affects syntax units (contract / fragment / type / key / directive), not same-named text inside comments or strings; it also honors namespace prefixes (@is ui.base.Service references are colored too)

  • Spotlight: light up a word across the whole workspace (status bar shows N places / M files)

  • Self-check: right-click “SML: Self-check” to expand “why nothing happens” line by line into “Output → SML” (extension version, in-package parser fingerprint, command registration, language mode, document validation result, whether jump works)

  • Install: VSCode → Extensions → ... → Install from VSIX, pick the downloaded file

  • Note: the extension folder contains README.md (bilingual) and README.en.md (English)

This build is a repackage: it fixes a fatal bug where the extension failed to activate at all on VS Code 1.13x. If you installed an earlier 0.4.2, please reinstall this file. After install, use right-click “SML: Self-check” to verify the in-package parser fingerprint (should be 96110 B / c7a5054d…).

The extension is not on the Marketplace; only manual VSIX install is provided (Zed users, see editors/zed/README.md in the repo). Contracts (@contract / @is) are supported on Rust, JS, C, C++ and Lua, so semantic errors inside the editor are also reported.

Host Bindings · 0.1.0 (Python / Ruby / Java / Go / C#)
  • Text / file loading (with include expansion)
  • Value-tree traversal (type-preserving: int / float / bool / str / array / object)
  • Rich errors (code_str / line / column / position / source / text)
  • Serialization dumps (object → SML text)
  • Feature gating flags (sandbox)
  • Version / feature query (Version / Features)
  • Path lookup (get_in)
  • Memory discipline (correct free)

The five host bindings call the Rust cdylib through the C-ABI; the read path traverses the value tree directly (type-preserving, rich errors in hand), with no JSON round-trip; only dumps goes through the official bridge object → JSON → sml_dump. C# is not verified locally (no .NET SDK on this machine); its logic is strictly aligned with the other four and can be verified via dotnet run --project bindings/csharp once an SDK is installed.

Reference Implementations · 0.6.3 (C / C++ / JavaScript / Lua)
  • Text / file loading (with include expansion)
  • Value-tree traversal (type-preserving: int / float / bool / str / array / object)
  • Rich errors (code_str / line / column / position / source / text)
  • Serialization dumps (object → SML text)
  • Feature gating flags (sandbox)
  • Version / feature query (Version / Features)
  • Path lookup (get_in)
  • Memory discipline (correct free)

C / C++ are zero-dependency self-contained implementations in the repo (or pick the Rust bridge header sml_rs.*); JavaScript is a zero-dependency ESM, same parser as the playground; Lua is an in-repo reference binding. All four share the same capability surface as the host bindings.

Rust Library & CLI (swsml 0.6.3 · smltools 0.2.2)
  • Rust library: swsml 0.6.3 —— cargo add swsml
  • CLI: smltools 0.2.2 —— cargo install smltools (version independent of the library; smltools was renamed from smlconv, which is no longer updated)

0.6.3 highlights: contract superposition (one block applies multiple contracts, three equivalent spellings); contract-mapping API; contract inference smltools --infer-contract; errors carry location [line N, col M]; five fixes including pattern-quantifier / compile-scale bounds. Full list in CHANGELOG.md (English).