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, typed values, attributes, and children.
App("demo") #root {
title = "Hello"
width = 800
flags = [true, false, null]
position = { x: 10 y: 20 }
@meta(debug)
Button("OK") #ok {
text = "OK"
}
{
visible = true
}
}
Rules:
Type { ... }creates a node with explicit typeType(arg1, arg2) { ... }creates a node with constructor-like arguments#name { ... }creates a node with implicitNodetype{ ... }creates a node with implicit type and no name@metaand@meta(...)attach metadata to the next nodeattr = valuedefines an attributefoo.bar { ... }is parsed as a single dotted node type
Supported value kinds:
nulltrue/false- identifiers
- integers and floats
- quoted strings
- arrays:
[a, b, 1] - objects:
{ key: value }
Supported number forms:
- decimal integers:
0,10,-1 - decimal floats:
1.2,2.,-.5 - decimal exponent form:
4.5e1,-5.e2 - binary integers:
0b10 - octal integers:
0o23 - hexadecimal integers:
0x10 - base-prefixed numbers with exponent:
0o23e2
Reserved attribute names:
typenamechildren
import s.decl.Node;
import s.decl.Value;
var root = Node.parse(source);
var fileRoot = Node.parseFile("example.sdecl");Each parsed node contains:
type:Stringname:Stringmeta:Array<{name:String, params:Array<Value>}>arguments:Array<Value>attributes:Map<String, Value>children:Array<Node>
Value supports:
VNullVBoolVIdentVIntVFloatVStringVArrayVObject
Run tests:
haxe build_tests.hxml