4 ms·
I assume that you mean a code generator for Idris 2. I think the easiest way to get going is to start from an existing code generator. Idris 2 currently suppor
by Zigma 6y ago
I assume that you mean a code generator for Idris 2.
I think the easiest way to get going is to start from an existing code generator. Idris 2 currently supports: Chez Scheme, Racket, Gambit Scheme and JavaScript. Pick the language you are most familiar with.
The files that are relevant to the Chez Scheme code generator are located here (similar locations for the other code generators): https://github.com/idris-lang/Idris2/blob/master/src/Compiler/Scheme/Chez.idr https://github.com/idris-lang/Idris2/blob/master/src/Compile..., https://github.com/idris-lang/Idris2/blob/master/src/Compiler/Scheme/Common.idr https://github.com/idris-lang/Idris2/blob/master/src/Compile..., https://github.com/idris-lang/Idris2/blob/master/support/chez/support.ss https://github.com/idris-lang/Idris2/blob/master/support/che...
The current code generators are based on an intermediate representations called `NamedCExp`, defined here: https://github.com/idris-lang/Idris2/blob/master/src/Core/CompileExpr.idr#L62-L107 https://github.com/idris-lang/Idris2/blob/master/src/Core/Co...
`NamedCExp` describe various forms an expression can take. These need to be translated into the target language. For example `NmApp` represents calling a function with the given arguments. You don't need to implement everything to make a proof of concept.
The following document describe how to add a new code generator (It does not go into details of building it): https://idris2.readthedocs.io/en/latest/backends/custom.html https://idris2.readthedocs.io/en/latest/backends/custom.html
You can see an overview of the different intermediate representations here: https://github.com/chrrasmussen/Idris2-Erlang/blob/master/docs/intermediaterepresentations.md https://github.com/chrrasmussen/Idris2-Erlang/blob/master/do...
(Note that ErlExpr and AbstractFormat is specific to the Erlang code generator)
If you have more questions, you are welcome to join the Idris community at any of the locations listed here: https://www.idris-lang.org https://www.idris-lang.org