esc:   Extensible Syntax Compiler
1 Installation
2 Examples

esc: Extensible Syntax Compiler

Erik Silkensen <>

 (require (planet esilkensen/esc:2:=0)) package: base

This is a project for an extensible parsing system that aims to provide a user-friendly method for designing composable DSLs.

Languages are defined in modules by CFGs written in standard BNF notation. DSLs can be built on top of the Racket programming language by writing type-oriented grammar rules as function or macro signatures followed by Racket code for their implementation.

For example, the rule

    Integer ::= "|" s:Set "|" = (set-count s);

defines syntax for set cardinality, which is implemented by Racket’s set-count function.

1 Installation

To try out the tool, first download and install Racket from Then start the Racket interpreter, and enter (require (planet esilkensen/esc)). This installs an esc command to the raco program.

At the command line,

    raco esc [<source-file>] ...

will compile a sequence of extensible syntax files into Typed Racket code.

2 Examples

Included in the examples directory is a module for giving ML-like syntax to several Typed Racket forms (, and another for basic set operations such as the one above (


import ML, Sets;

let A = {1, 2, 3} {

  let B = {2, 3, 4} {

    let C = {3, 4, 5} {

      print |A & C|;

      print A | B & C




The above program ( can be compiled and run with the following commands:

    raco esc

    racket -I typed/racket abc.rkt

The output of the program is


    #<set: 1 2 3 4>