Looking for a simple forth compiler (producing asm/executables, not compiling forth words) to learn from, preferably in C family language

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/Forth

Our great sponsors
  • Scout APM - Less time debugging, more time building
  • OPS - Build and Run Open Source Unikernels
  • SonarQube - Static code analysis for 29 languages.
  • stoneknifeforth

    a tiny self-hosted Forth implementation

    Title effectively says it all. The only thing I have found is StoneKnife Forth (implementation is in tinyboot1.tbf1) but this file is implemented in the same dialect of forth it implements, which due to being minimal makes it difficult to read and comprehend efficiently (I also can't find the origin of some words such as 'byte' used in the code but not implemented by the interpreter). I would prefer something in the C family to look at but anything should do as long as it's clean enough that I could use it as a reference to reimplement the compiler without much difficulty. Thank you in advance for any help with what is seemingly quite a narrow request.

  • r4

    :r4 concatenative programming language with ideas from ColorForth.

    I have a vm in c for my forth, I have a compiler to asm (generate FASM output) but in the same lenguage, really a forth compiler is a simple program, there are a 1:1 correspondence in code genaration and words. here the 32bits source https://github.com/phreda4/r4/blob/master/r4/System/r4i86.txt here the 64bits with some optimizations: https://github.com/phreda4/r3d4/blob/master/r3/sys/r3asm0.r3 I hope this help

  • Scout APM

    Less time debugging, more time building. Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development.

  • r3d4

    r3 programing language for 64 bits Windows/Linux/Mac/Rasberry Pi 4

    I have a vm in c for my forth, I have a compiler to asm (generate FASM output) but in the same lenguage, really a forth compiler is a simple program, there are a 1:1 correspondence in code genaration and words. here the 32bits source https://github.com/phreda4/r4/blob/master/r4/System/r4i86.txt here the 64bits with some optimizations: https://github.com/phreda4/r3d4/blob/master/r3/sys/r3asm0.r3 I hope this help

  • jonesforth

    Mirror of JONESFORTH

    JonesForth which is a very well documented forth written directly in x86 assembly. It contains very clear descriptions about the inner and outer interpreter and related functionality. Even though itnis not C, the techniques shown here can easily be transferred to a C program.

  • able-forth

    A Forth-like programming language that targets the AbleVM

    I would consider adding Able Forth to the list. The Able Forth compiler targets the AbleVM, but in every other respect, it's a native code compiler (there's no reason Able Forth couldn't be made to emit native code for a physical machine). The default AbleVM core was designed to make the Able Forth compiler simple; it implements a 0-operand dual-stack virtual machine with ample general-purpose and base+offset address registers. Able is open source, in production use and under active development. If you decide it's interesting and you have any questions we're here to help.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts