Algorithmic Origami
Journey In Creating A Programmable Origami Simulator


Mation-spec - An English-like DSL for Commands and Specifications

As mentioned previously in Programmable Origami, the foldMation commands are structured and parsed using a custom domain specific language (DSL). To suit the application's needs, it must to be both well structured and be English like. After searching for a tool that is up to the task and found none, I have created one myself and open sourced it at mation-spec.

Goals

The goal isn't to create a specification language that is just for origami folding. If that was the case, it could have been just a bunch of if statements. The goal is to create a specification simple yet powerful and flexible engough to be the standard for command-like specifications and configurations that reads like English, a tool that doesn't exists yet.

Core Features are:

Example

  steps: [
    move a;
    move [1,2] [3 -4]; // comma optional in an array/list
    turn { x:1, y:2 };
    turn { x:1  y:2 }; // comma optional in an object/map
    do [
      fold points:[3] 90 over-edges:[16];
      unfold points:[0] 90 over-edges:[18];
    ];
  ]

(Near perfect syntax highlighting acheived by setting the language to rust)

Translates to:

{
  steps: [
    move: 'a',
    move: [[1, 2], [3, -4]],
    turn: {x:1, y:2 },
    turn: {x:1, y:2 },
    do: [
      ['fold', { points: [3] }, 90, { 'over-edges': [16] }],
      ['unfold', { points: [0] }, 90, { 'over-edges': [18] }],
    ],
  ]
}

Have a usecase for it? Love to hear what you think. Source with more details and examples at mation-spec