Code Monkey home page Code Monkey logo

preforth's Introduction

Bootstrapping Forth

preForth

preForth is a minimal non-interactive Forth kernel that can bootstrap itself and can be used as an easy-to-port basis for a full Forth implementation.

preForth feels like Forth - it's mainly a sublanguage of ANS-Forth - but is significantly reduced in its capabilities.

Features: minimal control structures, no immediate words, strings on stack, few primitives

just

  • Stack
  • Returnstack
  • Only ?exit and recursion as control structures
  • :-definitions
  • optional tail call optimization
  • IO via KEY/EMIT
  • signed single cell decimal numbers (0-9)+
  • character constants via 'c'-notation
  • output single cell decimal numbers

and

  • no immediate words, i.e.
  • no control structures IF ELSE THEN BEGIN WHILE REPEAT UNTIL
  • no defining words
  • no DOES>
  • no memory @ ! CMOVE ALLOT ,
  • no pictured numeric output
  • no input stream
  • no state
  • no base
  • no dictionary, no EXECUTE, not EVALUATE
  • no CATCH and THROW
  • no error handling

Prerequisites:

Just 13 primitives: emit key dup swap drop 0< ?exit >r r> - nest unnest lit

seedForth

seedForth is an extended system with random access memory, control structures, compiling and defining words. Its kernel the so called seedForth bed is built using preForth. Seed Forth bed has about 30 primitives as well as a compiler and interpreter.

seedForth accepts source code in tokenized source code form (.seed files). the seedForth tokenizer reads text source code (.seedsource files) and converts them to token form.

You can create applications by writing the appropriate seedForth text source code, tokenize it using the tokenizer (make xxx.seed) and then feed the token source code into the seedForth bet (cat xxx.seed | ./seedForth) in order to let the application grow.

On of these applications is seedForth/interactive.

seedForth/interactive

seedForth/interactive extends seedForth to become a full featured interactive Forth system. For this it defines a searchable dictionary of (text based) headers and a text based interpreter and compiler. On startup seedForth/interactive accepts Forth source code in text form.

How to use:

An i386-Backend (32Bit) indirect threaded code implementation based on FASM is pre-configured. PreForth initially bootstraps on with gforth or swiftForth. You'll need one of these for the first bootstrap.

cd preForth
make

This will successively compile preForth, seedForth then seedForth/interactive.

If successful issue

$ ./seed

and seedForth/interactive will start up showing

..................................................
.
seedForth/interactive 2.2.0
---------------------------
380005 bytes free

and more test output. Tweek hi.forth as desired.

Inspect sources and generated files.

Have fun. May the Forth be with you.

preforth's People

Contributors

uho avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.