On this page:
syntax-spec:   A Metalanguage for Hosted DSLs
8.15.0.2

syntax-spec: A Metalanguage for Hosted DSLs🔗ℹ

Michael Ballantyne <michael.ballantyne@gmail.com> Michael Delmonaco <mdelmonacochs@gmail.com>

This package provides a metalanguage for creating hosted DSLs. Hosted DSLs extend the syntax of Racket with their own grammar and have their own static semantics and compilers.

The metalanguage allows programmers to declare a DSL’s grammar, binding rules, and integration points with Racket. Under the hood it produces a macro expander for the DSL that parses, checks name bindings, expands DSL macros, and produces syntax in the DSL’s core language for compilation.

You can implement conventional macros that do all these same things, but it can take a lot of manual effort and a deep knowledge of Racket’s syntax API.

You might find the metalanguage useful when you both:

    Tutorial

      1 Basic Tutorial: State Machine Language

        1.1 Grammar

        1.2 Binding

          1.2.1 Simple binding

          1.2.2 Separate scope and binding forms

          1.2.3 Nested binding

        1.3 Integrating Racket Subexpressions

        1.4 Compilation

          1.4.1 Symbol Tables

        1.5 Macros

      2 Advanced Tutorial: Simply Typed Lambda Calculus

        2.1 Integrating Racket Expressions

        2.2 Adding Definitions

      3 Advanced Tutorial: A Compiler with Multiple Passes

    1 Reference

      1.1 Specifying languages

        1.1.1 Binding classes

        1.1.2 Extension classes

        1.1.3 Nonterminals

          1.1.3.1 Nonterminal options

          1.1.3.2 Productions

        1.1.4 Syntax specs

        1.1.5 Binding specs

        1.1.6 Host interface forms

        1.1.7 Defining macros for DSLs

        1.1.8 Embedding Racket syntax

      1.2 Compiling languages

        1.2.1 Compiling references to DSL bindings within Racket code

        1.2.2 Compiled identifiers vs surface syntax

        1.2.3 Symbol collections

          1.2.3.1 Symbol tables

          1.2.3.2 Symbol sets

        1.2.4 Binding Operations

        1.2.5 Expansion