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.
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 the decompiler by:
Setting up packages and public methods code_generator.Generate and code_formatter.Format.
Updating the MusicXML importer to use these method (and remove the bootstrapped play implementation).
Refactor parser.Token parameters to be public so they can be used outside of the parser.
Alda compiler AST refactor
This PR will wait for a refactor of the Alda parser to include a step to transform into an AST instead of a flat []parser.Token. Then the generator will generate directly to this, and the formatter will get this as input.
The need for an Alda decompiler is twofold:
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 decompileScoreUpdate
structs to Alda code so users can start writing Alda from imported music.gofmt
). Alda may eventually aim to support built-in formatting. This is most easily done by scanning toparser.Token
then formatting back to code. This PR will set up this formatter in the most basic form.This PR sets up the decompiler by:
code_generator.Generate
andcode_formatter.Format
.parser.Token
parameters to be public so they can be used outside of theparser
.Alda compiler AST refactor
This PR will wait for a refactor of the Alda parser to include a step to transform into an AST instead of a flat
[]parser.Token
. Then the generator will generate directly to this, and the formatter will get this as input.