beef331 / website

Code for the official Nim programming language website
https://nim-lang.org
18 stars 1 forks source link

Nim0, a subset of Nim language, with a compiler to a 32-bits RISC CPU and a runtime emulator #19

Closed pmetras closed 3 years ago

pmetras commented 3 years ago

Name: Nim0, a subset of Nim language, with a compiler to a 32-bits RISC CPU and a runtime emulator

Author: Pierre Métras

image

Nim0 is a toy language similar to Nim but much more limited (no fancy feature X; replace X by generics, templates, closures, imports, etc.). But it comes with a one-pass compiler to 32-bit RISC instructions and an emulator, and a few examples to show what you can do with it. In fact, the interesting part in Nim0 is not the language itself but the compiler source in less than 4000 lines of commented code, with references to Niklaus Wirth's Compiler Construction book that you can follow while reading the book, even if the book talks about Oberon-0. When you have completed the book and added a few features to Nim0 compiler, you'll be ready to jump into hacking Nim compiler.

Want to try it? Look at the simple instructions and detailed example at https://pmetras.gitlab.io/nim0/.