Skip to content

Low-level self-hosting compiler #19

@ForNeVeR

Description

@ForNeVeR

Well, there wasn't any activity for a while, but it's time to evolve!

I have an idea of implementing the lowest-level self-hosted lisp compiler based on CLR. A base variant should be able to interpret and compile raw CIL code in a s-expression way. For example, code like this:

(.assembly Hello
 (.method (public static void) Main ()
  .entrypoint
  ldstr "Hello, world!"
  call (`void System.Console::WriteLine(string)`)
  ret))

should generate assembly like the one produced by this CIL code:

.assembly Hello {}
.method public static void Main() cil managed
{
     .entrypoint
     .maxstack 1
     ldstr "Hello, world!"
     call void [mscorlib]System.Console::WriteLine(string)
     ret
}

We'll have the following development stages then:

  1. First of all, we should create a (relatively) simple F# program able to process and compile simple snippets of naggum code that can be 1-to-1 mapped to CIL instructions such as in example above. This ability will be the core of our language.
  2. Implement a macro expansion engine based on the same concepts (macros may simply be compiled before the compile time to some dynamic assembly and their code executed at compile time). Core set of macros should include helpers such as class, assembly, try-filter-catch-finally-fault and others useful constructs that may be supported by CLR and CIL.
  3. We'll call the resulting program (still C#-based) as "stage 1" and use it to compile the future naggum binaries.
  4. Reimplement stage 1 compiler in naggum itself. At this stage the language should already be able to meaningfully present all concepts needed for the rewrite. It will be our stage 2 compiler (and a brilliant success).

@hagane, what would you say? Maybe you had some another plans on this?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions