Wednesday 27 July 2011

Success := It comes to me

So, I realized that my previous musings of library and language separation are quite irrelevant. After all, I already was describing systems of compile-time function manipulation. So one simple idiom later, and those problems are, well, clearly resolved.

GenerateCode(function) {
    // Generate your own code from the contents of function here
    // And emit the result as output from the process
    // completely by-passing the main compiler
    // Alternatively, compile for JVM or CLR or whatever you feel like
}

main() {
    GenerateCode(real_main);
}

real_main() {
   // Really run the program here
}

Meta-programming is so powerful.

In other news, the parser construction is going a lot more solidly. I grabbed Bison 2.5 using Cygwin, and it's considerably more impressive than it's previous version. Adding a var keyword quickly resolved my ambiguity problems (turns out you can't function call and function define in the same scope, so all I had to do was disambiguate variables from everything else). All I'm doing now is wrapping up actually creating the AST, making sure the lexer has been updated with all the changes, and then it's time to semantically analyze, and by that, I mean get meta-programming. After that, all that's left is code generation, and probably updating for everything I notice I've forgotten. For example, right now, I've got no initialization lists in constructors, whoops.

I've actually been seriously considering implementing for JVM and CLR. They would hardly be the most maintainable Java/C# code you ever saw, but I think I can make it work. It would certainly increase the probability of the language being adopted. I even think that it can be implemented as a library, which would be so sick.

Oh lord, I might actually succeed.

3 comments:

  1. Could you give me the Bison 2.5 executable for Cygwin please?

    Thanks in advance
    Bert.kreisel@optum.de

    ReplyDelete
  2. Not really. I'm pretty sure that it has to be specifically configured and installed on your system, you can't just send over the .exe.

    ReplyDelete
  3. I have newest cygwin with bison 2.4.2-1 installed. I could copy the data directory from the bison 2.5 sources to cygwin\usr\share\bison. But I m not able to compile the sources.

    Thanks anyway
    Bert.kreisel@optum.de

    ReplyDelete