conference logo

Playlist "BOB Konferenz 2025"

A Language Server for your DSL for Fun and Profit

Hannes Siebenhandl

Domain-specific languages (DSL) are well-studied tools for solving problems specific to a domain. Especially in the Haskell Community, DSLs are quite popular due to parser-combinators and succinct definitions of abstract syntax trees (AST). However, it is often difficult to integrate a particular DSL into any modern IDE. This causes a DSL to be harder to use in practice and negatively affects productivity. Sometimes, developers combat this by implementing plugins that introduce syntax highlighting specific to an editor. However, we argue that it is preferable to use existing infrastructure, such as the Language Server Protocol, which provides out-of-the-box IDE support for most editors.

In this talk, we focus on key challenges for implementing a Language Server, as a Language Server simply has different requirements from a parser or an interpreter. We discuss how to approach the design and implementation of a DSL such that we get Language Server support (almost) for free. In particular, we show how to provide advanced IDE features, such as semantics-aware syntax highlighting or automatic refactorings, with minimal effort. To implement this, we augment the AST to retain additional information about the sources, such as parentheses, comments, and whitespace, in a non-intrusive way.

Licensed to the public under https://creativecommons.org/licenses/by/3.0/de