Call for compiler hackers

by smitchell2on 2/28/2017, 7:58 PMwith 0 comments

I've created some compiler related tasks on RosettaCode. The goal is to create a simple compiler in small pieces: Scanner, Parser, Code Generator, and Virtual Machine Interpreter tasks have been created.

    Scanner
        http://rosettacode.org/wiki/Compiler/lexical_analyzer
    Parser
        http://rosettacode.org/wiki/Compiler/syntax_analyzer
    Code Generator
        http://rosettacode.org/wiki/Compiler/code_generator
    Virtual Machine Interpreter
        http://rosettacode.org/wiki/Compiler/virtual_machine_interpreter
In order to keep the actual solutions smallish, the language is necessarily very simple - a Tiny (mostly) subset of C, with only integer variables.

    /*
     Simple prime number generator
     */
    count = 1;
    n = 1;
    limit = 100;
    while (n < limit) {
        k=3;
        p=1;
        n=n+2;
        while ((k*k<=n) && (p)) {
            p=n/k*k!=n;
            k=k+2;
        }
        if (p) {
            print(n, " is prime\n");
            count = count + 1;
        }
    }
    print("Total primes found: ", count, "\n");
There are currently implementations of all the main tasks in Algol W, AWK, C, Phix, Python and Scheme.

I'm especially interested in seeing implementations in other languages, including Java, C++, C#, Haskell, OCaml, Clojure, Racket, Erlang, Pascal, Nim, PHP, Javascript, Julia, F# and any others you can think of.

0