Domain-specific languages can improve ease-of-use, expressiveness and verifiability, but defining and using different DSLs within a single application remains difficult.
We introduce an approach for embedding DSLs in a common host language where the type of a piece of domain-specific code can specify which grammar governs it. Because this grammar is type-specific, but the block is delimited by the host language, we can guarantee that link-time conflicts cannot arise. These grammars can recursively include top-level expressions using special entry tokens that guarantee that the composition of the type-specific language and the host language is also sound. We argue that this approach occupies a previously-unexplored sweet spot providing high expressiveness and ease-of-use while guaranteeing safety. We introduce the design, provide examples, sketch the safety theorems and describe an ongoing implementation of this strategy in the Wyvern programming language.
Joint work with Jonathan Aldrich, Darya Kurilova, Benjamin Chung, Ligia Nistor and Alex Potanin.
Presented in Partial Fulfillment of the CSD Speaking Skills Requirement.