Skip to main content

Module parser

Module parser 

Source
Expand description

Hand-rolled S-expression parser for the Refrain DSL.

Grammar (informal):

refrain := "(" "refrain" IDENT stage* ")"
stage   := "(" stage-kind pattern+ ")"
stage-kind := "territorialize" | "deterritorialize" | "reterritorialize"
pattern := ATOM | "(" op-head pattern* ")"
op-head := "note" | "loop" | "dy/dx" | "quotient" | IDENT

Sequences of patterns inside a stage become Pattern::Seq. Unknown function-like forms become Op::Call { head, args } so the parser does not have to be updated for every future operator.

Functionsยง

parse