sdecl
sdecl is a small declarative language for tree-shaped data.
It is designed to be: - compact - fast - easy to parse - convenient for UI markup, config files, and build descriptions
The core of the language provides a typed AST with nodes, metadata, constructor arguments, attributes, and children.
Syntax
App("demo") #root {
title = "Hello"
width = 800
flags = [true, false, null]
@meta(debug)
Button("OK") #ok {
text = "OK"
}
{
visible = true
}
}
Rules:
- Type { ... } creates a node with explicit type
- Type(arg1, arg2) { ... } creates a node with constructor-like arguments
- #name { ... } creates a node with implicit Node type
- { ... } creates a node with implicit type and no name
- @meta and @meta(...) attach metadata to the next node
- attr = value defines an attribute
Supported value kinds:
- null
- true / false
- identifiers
- integers and floats
- quoted strings
- arrays: [a, b, 1]
- objects: { key: value }
Reserved attribute names:
- type
- name
- children
Haxe API
import s.decl.Node;
import s.decl.Value;
var root = Node.parse(source);
var fileRoot = Node.parseFile("example.sdecl");
Each parsed node contains:
- type:String
- name:String
- meta:Array<{name:String, params:Array<Value>}>
- arguments:Array<Value>
- attributes:Map<String, Value>
- children:Array<Node>
Development
Run tests:
haxe build_tests.hxml