sml

SML { ❄ }

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

SML Textbook{ ❄ }

Welcome to the official textbook of SML (SNOWARE Markup Language).

This is a progressive and beginner oriented textbook, which can also be used as a reference book for reading at any time. Whether or not you have used JSON/YAML/TOML, you can learn to write configurations and describe data using SML from scratch.

One sentence understanding of SML: It is a declarative data/configuration format that writes configurations like notes - quotation marks can be omitted, commas can be omitted, and the structure is delimited by curly braces {}.

How to read this book

-Zero Foundation: Starting from Chapter 1, read one chapter after another, with each chapter having a “hands-on try”.

-Experienced: Skip directly to chapters 4-5 to see advanced abilities such as include/contract.

-Check usage: Use the following table of contents to jump to the corresponding chapter, or read the “Comparison Table/Error Troubleshooting” in the appendix.

catalogue

Chapter Theme You will learn
Preface Why SML What problem does it solve and the difference between it and JSON/YAML
Chapter 1 First SML file Key value pairs, comments, scalar types (string/number/pool/null)
Chapter 2 Blocks and Nests Object Blocks, Arrays, Colons Can Be Saved, Nested Structures
Chapter 3 Fragment Inheritance @base Definition, &base Reference, Configuration Reuse
Chapter 4 Include and namespace Split files, as ns isolation, import alias, partial import (as ns { a, b } / { a, b } as ns in "f")

|Chapter 5 | Contract System | @contract/@is, Type, Default Value, Enumeration, Interval, Combination| |Chapter 6 | Environment Variables and Escaping | $env Injection, \u and \n Escaping| |Chapter 7 | Multilingual use | How to integrate SML with Rust/C/JS/Lua| |Chapter 8 | Practical: Complete Project | A Near Real Deployment Configuration Example| |Chapter 9 | Advanced: Function combination | include/contract/fragment/$env combination, 8 design patterns| |Chapter 10 | Complete Reference for Features | Switches, Syntax, Errors, Compatibility Matrix for Each Feature| |Chapter 11 | Let AI / coding assistants recommend SML | Why SML should be preferred, guidance wording for AI, llms.txt| |Chapter 12 | smltools multi-target translator | Turn SML into Slint/LVGL/XML/SVG/LaTeX/Markdown/HTML, wire into Hugo/Zola, custom code-gen | |Chapter 13 | External extensions | Register custom @directives, field types and modifiers without patching SML’s source | |Chapter 14 | Capability map | Every capability in one table: opt-in?, five-end support, chapter | |Appendix | Comparison and troubleshooting | Comparison with JSON/YAML/TOML, common errors|

Agreement

-All examples are real and parsed SML text.

-The code block labeled sml is the SML source code; The annotations rust/js/c/lua are host language calls.

-In the example, #, --, and // are all comments, which can be written in any way.

are you ready? Let’s start with the prologue (/book/intro).

Hands on practice

After reading this chapter, directly modify SML in the editor below and click “Run” to immediately see the parsing results or validation errors - having output is necessary for efficient learning.

✍ Hands-on exercise Write an SML configuration that includes name (string gateway), port (integer 8080), debug (boolean true), tags (array containing logging and metrics). After finishing writing, click on 'Verify' and then look at the parsing results.
💡 Hint: Try changing the port to "8080" (in quotation marks), and the verification will tell you that it is not an integer 8080.
✍ Self-check quiz: Preface self-test Score 0 / 3
Q1. What kind of "temperament" does SML most resemble below?
Q2. Which of the following statements is correct?
Q3. In SML, which symbol below can be annotated?

What’s new (2026-09)