alda-lang / alda

A music programming language for musicians. :notes:
https://alda.io
Eclipse Public License 2.0
5.59k stars 286 forks source link

Start of Alda Decompiler (Generator & Formatter) #361

Closed Scowluga closed 3 years ago

Scowluga commented 3 years ago

The need for an Alda decompiler is twofold:

  1. With the start of interoperability, we are now able to import MusicXML into Alda IR (ScoreUpdate). Although we can do lots of stuff from this representation like output to JSON or play, we can't actually obtain Alda code itself from it. The decompiler will serve to decompile ScoreUpdate structs to Alda code so users can start writing Alda from imported music.
  2. Many great languages come with great formatters (ex gofmt). Alda may eventually aim to support built-in formatting. This is most easily done by scanning to parser.Token then formatting back to code. This PR will set up this formatter in the most basic form.

This PR sets up both the generator and formatter with simple / partial implementations.

Scowluga commented 3 years ago

Closing this pull request to split it into 3 PRs:

  1. Code generator
  2. Code formatter
  3. Usage in MusicXML importer

The discussion here will remain if we want to reference it.