B7) From BP3 to SuperCollider
Anatomy of the Transpiler
You now know what an AST is, how BP3 grammars derive musical sequences, and how SuperCollider orchestrates patterns. But how do we concretely move from one to the other?
Where does this article fit in?
This article is the convergence point of the previous series. It brings together the AST (Abstract Syntax Tree — L4) from the L series, SuperCollider patterns (I3) from the I series, and all the BP3 formalism detailed in B1 to B6. This is where theory meets implementation: we dissect the bp2sc transpiler, which transforms BP3 code into playable SuperCollider code.
Sidebar: Transpiler vs. Compiler
A compiler translates a source language into a lower-level language (C to assembly, for example). A transpiler (or source-to-source compiler) translates between two languages at the same level of abstraction. Here, BP3 and SuperCollider are both high-level languages dedicated to music. We are therefore translating from a generative formalism to a pattern formalism — this is indeed transpilation.
Why is it important?
Understanding the transpiler means understanding the bridge between two worlds: that of formal grammar (BP3) and that of sound synthesis (SuperCollider). Without this bridge, a BP3 grammar remains inert text — rules on paper. With it, every rule transforms into a stream of musical events.
The most telling analogy: imagine a simultaneous translator at a conference. The speaker talks in BP3 (grammar, weights, modes) and the translator must render the exact same speech in SuperCollider (patterns, events, routines). The fidelity of the translation is crucial: one error and the music no longer corresponds to the composer’s intention.
But this translator does not work word-for-word. They first decompose the speech into units of meaning (parsing), build an intermediate representation (the AST), and then reformulate it in the target language. This is exactly what our transpiler does in five steps.
The idea in one sentence
The bp2sc transpiler transforms BP3 code into SuperCollider code in five distinct phases — lexer (lexical analyzer), line classifier, parser (syntactic analyzer), validation, and emitter (code generator) — each with a unique responsibility.
Step-by-step explanation
1. The complete pipeline
The transpiler follows a five-phase pipeline:

Figure 1 — Pipeline of the bp2sc transpiler in five phases. Orange nodes represent data (source and target), cyan nodes represent processors (transformations).
Why five phases and not just one? For the same reason a house isn’t built in a single step: each phase has a specific responsibility, and this separation allows for testing and debugging each step independently.
Sidebar: Separation of Concerns
In software engineering, the principle of separation of concerns states that each module should do one thing and do it well. A five-phase pipeline means five independently testable modules:
- The lexer/classifier reads the raw text and identifies the type of each line (comment, header, mode, preamble, rule)
2