List of DSL Patterns
My book on Domain Specific Languages uses a pattern structure to organize the concepts that I use to describe DSLs. Here is a list of the patterns in that book. Each is linked to a page for each pattern. The pages don’t contain very much detail, little more than an indication of the relevant chapter in the book. My main purpose for these is to provide a reference URI for each pattern.
Arrange blocks of code in a data structure to implement an alternative computational model.
Alter the lexing behavior from within the parser.
Data about program elements, such as classes and methods, which can be processed during compilation or execution.
Formally define the syntax of a programming language.
Use a class and its fields to implement a symbol table in order to support type-aware autocompletion in a statically typed language.
A block of code that can be represented as an object (or first-class data structure) and placed seamlessly into the flow of code by allowing it to reference its lexical scope.
Incrementally create an immutable object with a builder that stores constructor arguments in fields.
Use a variable to hold context required during a parse.
Represent a combination of conditional statements in a tabular form.
Translate source text by breaking it up into chunks (usually lines) and then parsing each chunk.
A list of tasks linked by dependency relationships. To run a task, you invoke its dependencies, running those tasks as prerequisites.
Handle messages without defining them in the receiving class.
Embed interpreter actions into the grammar, so that executing the parser causes the text to be directly interpreted to produce the response.
Embed output production code into the parser, so that the output is produced gradually as the parse runs.
An object that minimizes code in a templating system by providing all needed functions to that templating mechanism.
An object, or family of objects, that provides a fluent interface over a normal command-query API.
Embed some foreign code into an external DSL to provide more elaborate behavior than can be specified in the DSL.
A combination of function calls as a sequence of statements.
Separate generated code from non-generated code by inheritance.
Add methods to program literals.
Represent language expression with a literal list.
Represent an expression as a literal map.
Transform input text into a different text before language processing using Templated Generation .
Make modifier methods return the host object, so that multiple modifiers can be invoked in a single expression.
Hardcode all logic into the generated code so that there's no explicit representation of the Semantic Model .
Generate code with an explicit simulacrum of the semantic model of the DSL, so that the generated code has generic-specific separation.
Express statement subelements of a function call by putting them into a closure in an argument.
Compose functions by nesting function calls as arguments of other calls.
An operator expression that can recursively contain the same form of expression (for example, arithmetic and Boolean expressions).
Use newlines as statement separators.
Collects errors and other messages to report back to the caller.
Place the DSL script so that bare references will resolve to a single object.
Capture the parse tree of a code fragment to manipulate it with DSL processing code.
Create a top-down parser by a composition of parser objects.
Build a parser driven by a grammar file as a DSL.
Organize logic through a set of production rules, each having a condition and an action.
Create a top-down parser using control flow for grammar operators and recursive functions for nonterminal recognizers.
Implement a lexical analyzer using a list of regular expressions.
The model that's populated by a DSL.
Model a system as a set of explicit states with transitions between them.
A location to store all identifiable objects during a parse to resolve references.
Translate source text by defining a grammar and using that grammar to structure translation.
Generate output by handwriting an output file and placing template callouts to generate variable portions.
Perform simple textual substitutions before more serious processing.
Generate code by writing a transformer that navigates the input model and produces output.
The parser creates and returns a syntax tree representation of the source text that is manipulated later by tree-walking code.