Good languages to write a compiler for

前端 未结 7 1836
忘掉有多难
忘掉有多难 2020-12-30 16:01

I\'m thinking of writing a compiler in haskell, and just to gain some knowledge and experience, I will try to implement compilers for existing languages. Could someone give

相关标签:
7条回答
  • 2020-12-30 16:26

    Scheme is often used for this. There's even a tutorial called Write Yourself a Scheme in 48 hours for Haskell.

    0 讨论(0)
  • 2020-12-30 16:32

    As far as I know one of the easiest languages to compile is Forth. I think it's quite achievable to write a compiler for Forth in Forth even for a relative novice.

    0 讨论(0)
  • 2020-12-30 16:44

    Oberon-2. Like Lua has short context-free grammar.

    P.S. Here you can find Oberon-2 compiler written in Objective Caml.

    0 讨论(0)
  • 2020-12-30 16:51

    The simplest languages to write compilers for are existing "esoteric languages", like brainfuck, because they have the smallest instruction set and the simplest grammar. You can try your hand at a more complex language, but it's better to get the fundamentals down with something simple before moving any further.

    0 讨论(0)
  • 2020-12-30 16:51

    PL/0 is a simple language that was created to teach compiler construction. Samuel Williams wrote a compiler for it in Python (along with a virtual machine) for the benefit of students: http://www.oriontransfer.co.nz/learn/pl0-language-tools/index

    0 讨论(0)
  • 2020-12-30 16:53

    Pascal could be a good start - you can compile it in a single pass. A subset of Lisp might be useful in order to grasp the idea of the lambda lifting. ML or even a subset of Haskell might help you in understanding the type inference. Consider using LLVM as your back-end, it will save you some time on implementing boring stuff.

    0 讨论(0)
提交回复
热议问题