DSL Demo Examples

Each phase of the DSL roadmap introduces languages built for a specific domain: grammars, macros, hardware, intermediate representations, GPU kernels, statistics, and constraint solvers. Click View to inspect each annotated snippet in the code viewer.

For open-source compiler and DSL codebases to study at scale, see Study Projects; for official installers and browser playgrounds, see References & Downloads.

Implementation Languages (Phase 3)

Languages and grammar tools used to build parsers, compilers, and embedded DSLs.

#LanguageDescriptionLink
1ANTLR 4Expression grammar with operator precedence and labeled AST alternatives.View
2RacketHygienic syntax-rules macro defining a declarative rule-matching DSL.View
3OCamlAlgebraic data type and exhaustive pattern-matching evaluator for a small AST.View

Execution Models (Phase 4)

Low-level assemblers, hardware description languages, and compiler intermediate representations.

#LanguageDescriptionLink
4FASMFlat assembler macro expanding into a 64-bit Linux syscall sequence.View
5Verilog4-bit synchronous up-counter with reset and enable using non-blocking flip-flop assignments.View
6LLVM IRStatic Single Assignment (SSA) loop using phi nodes to sum 1..n.View

AI & Scientific DSLs (Phases 5–6)

Domain-specific languages for GPU kernels, multiple dispatch, and statistical modeling.

#LanguageDescriptionLink
7TritonBlock-tiled GPU vector addition kernel with boundary masking.View
8JuliaMultiple dispatch over an abstract type hierarchy with vectorized broadcasting.View
9RData-frame subsetting and linear regression over the built-in mtcars dataset.View

Logic & Symbolic Languages (Phase 7)

Declarative rules, answer-set constraints, and Lisp-family data pipelines.

#LanguageDescriptionLink
10PrologFacts and recursive reachability rules over a directed graph.View
11Clingo (ASP)Answer Set Programming choice rules and constraints for 3-coloring a graph.View
12ClojureImmutable data transformation pipeline using the ->> threading macro.View
Practice move: open the ANTLR grammar alongside the OCaml evaluator and trace how a parsed expression tree lowers to an algebraic type and evaluates.