On this page:
Metaprogramming in Rhombus
8.18.0.18

Metaprogramming in Rhombus🔗

This tutorial is about syntax and macros in Rhombus. We won’t assume that you’ve used Rhombus before, but we also won’t dwell much on the everyday-programming part of the language, since we expect you can pick that up easily as we go. Instead, we’ll get into the nuts and bolts of Rhombus’s approach to parsing, syntactic extension, and language creation.

    Setup

    1 Crash Course

      1.1 Exercise

      1.2 Exercise

      1.3 Exercise

    2 Shrubbery Notation

      2.1 S-Expressions as Inspiration

      2.2 Shrubbery Goals

      2.3 Shrubbery Abstract Syntax

      2.4 Shrubbery Syntax Details

        2.4.1 Separators and Terminators

        2.4.2 Required and Optional Newlines

        2.4.3 Indentation Rules and Variations

        2.4.4 Two More Tricks

      2.5 Exercise

    3 Post-Shrubbery Parsing

      3.1 Patterns and Templates

      3.2 Shorthands and Syntax Classes

      3.3 Parsing-Time Expressions

      3.4 Definition Macros

      3.5 Exercise

    4 Enforestation

      4.1 Defining Operators

      4.2 Expression Macros

      4.3 Exercise

      4.4 Exercise

    5 Spaces

      5.1 Binding Macros

      5.2 Parsing in Specific Spaces

      5.3 Macro Patterns

      5.4 Exercise

      5.5 Exercise

    6 Implicit Forms

      6.1 Exercise

    7 Whole Languages

      7.1 Modules and Macros

      7.2 Modules and Spaces

      7.3 Modules and Languages

      7.4 Exercise