Skip to content

Instantly share code, notes, and snippets.

@gingerBill
Last active April 16, 2017 10:56
Show Gist options
  • Save gingerBill/7aabfede8e832ebcea7522b92da50103 to your computer and use it in GitHub Desktop.
Save gingerBill/7aabfede8e832ebcea7522b92da50103 to your computer and use it in GitHub Desktop.
Plug-in System for a Compiler (Idea for Odin)

One of the original goals in Odin was metaprogramming. However, as development progressed, it has come clear that this is such a broad term which could mean anything.

The kinds of metaprogramming originally conceived are compile time execution, AST modification, and "semantic macros".

Here is the new idea: allow the user to "plug-in" their own metaprogramming functionality as a stage in the compiler. With the specific stages being:

  • File loading (get text into memory)
  • Tokenizing/Lexing
  • Parsing
  • Type checking
  • SSA generation and optimization
  • Code generation

At each stage, the use could do numerous different operations. Here are some examples, respectively:

  • C-style preprocessor
  • Token swapping/modifying
  • AST modification/generation
  • Documentation generation, type modification
  • Custom optimizations for specific platforms
  • Custom optimizations for specific platforms

This would leave the language as a base which could be extended by the user. This would mean numerous dialects would be produced but the base language "should" work in all of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment