sdecl

Small declarative language for Haxe
https://github.com/selibs/sdecl

To install, run:

haxelib install sdecl 1.2.0 

See using Haxelib in Haxelib documentation for more information.

README.md

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
Contributors
smoothie
Version
1.2.0
Published
3 months ago
License
Apache

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

⌂