Skip to main content
dsl-lang

Editor support for your own DSL

A language server for .dsl files: domain-specific languages made of calls with arguments and trailing blocks. Describe yours in a schema, and every editor highlights, checks and completes it.

services.dsl
// Services and what they may use
service("orders") {
replicas(3)
uses("community.flock.payments.PaymentClient")
routes {
post("/orders", auth = true)
}
}

Highlighting for any DSL

The colors go by the shape of a file, not by the names in it: a call with a block is a keyword, any other call a function.

Checks against a schema

A JSON file says which keywords your DSL has and where they go. Anything else is an error, right in the editor.

Completion

The editor offers the keywords that fit at the cursor, with their descriptions, from the same schema.

Outline and folding

The calls and their blocks, as an outline and as breadcrumbs. Blocks, argument lists and comments fold.

The same parser in your tool

The libraries for Java and npm read a script exactly as the editor does: calls, arguments and blocks.

Runs everywhere

One server in Kotlin Multiplatform, as a native executable, a jar and a Node.js script. Nothing else to install.

A schema makes it your language

Put services.json in a .dsl folder, or let your tool bring it through its plugin of Gradle or Maven or in its npm package. Every services.dsl is then checked against it.

.dsl/services.json
{
"root": ["service"],
"keywords": {
"service": { "block": ["replicas", "uses", "routes"] },
"replicas": { "description": "How many run." },
"uses": {},
"routes": { "block": ["get", "post"] },
"get": {},
"post": {}
}
}
services.dsl
service("orders") {
// Unknown keyword 'replica'.
// Allowed here: replicas, uses, routes
replica(3)
// 'post' is not allowed in 'service'.
post("/orders")
}

In your editor

The extension for VS Code and the plugin for the IDEs of JetBrains come with the server. Every other editor starts it with one command.