Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low-level self-hosting compiler #19

Open
ForNeVeR opened this issue Feb 21, 2015 · 2 comments
Open

Low-level self-hosting compiler #19

ForNeVeR opened this issue Feb 21, 2015 · 2 comments
Assignees

Comments

@ForNeVeR
Copy link
Member

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?

@hagane
Copy link
Contributor

hagane commented Dec 18, 2015

That would be very Lisp. Go forth with my blessings. I'll see if i can be of assistance.

@ForNeVeR
Copy link
Member Author

You have considered this very thoroughly. Thanks for your answer, capn!

@ForNeVeR ForNeVeR self-assigned this Dec 23, 2015
@ForNeVeR ForNeVeR mentioned this issue Apr 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants