6 votes

Looking for a simple language to build a compiler for

I've recently built a brainfuck just-in-time compiler and I'm looking for my next project. I think compiling a more complicated (and more easily written) language would build on what I've learned so far. Rather than design my own language from the ground up, I'd prefer to work with a toy language that already has existing programs and a spec. This would both save me some work and give me more solid ground to build upon.

6 comments

  1. [2]
    stu2b50
    Link
    Scheme! It's a classic, and writing a scheme interpreter is part of SICP. And it's practical (sort of). Reddit use to run from a lisp, after all!

    Scheme! It's a classic, and writing a scheme interpreter is part of SICP.

    And it's practical (sort of). Reddit use to run from a lisp, after all!

    8 votes
    1. teaearlgraycold
      Link Parent
      That does make the parser quite simple!

      That does make the parser quite simple!

      1 vote
  2. Adys
    Link
    Give Lua a shot. Its source code is tiny, in C, extremely embeddable etc. It should be a good match for your requirements.

    Give Lua a shot. Its source code is tiny, in C, extremely embeddable etc. It should be a good match for your requirements.

    4 votes
  3. joplin
    Link
    When I was in school, we built a Pascal compiler. It was pretty straightforward and taught us all the parts of writing a simple compiler from lexing to semantic processing.

    When I was in school, we built a Pascal compiler. It was pretty straightforward and taught us all the parts of writing a simple compiler from lexing to semantic processing.

    3 votes
  4. jcdl
    Link
    Turing is an interesting one that I've tried (and failed) to reimplement successfully. The documentation I linked is for the OOP version of Turing, but there's a simpler spec without classes out...

    Turing is an interesting one that I've tried (and failed) to reimplement successfully. The documentation I linked is for the OOP version of Turing, but there's a simpler spec without classes out there too.

    I'm curious, how are you going about writing your parser and are you targeting LLVM or doing it more traditionally?

    2 votes