16Bitt / xforth

A portable forth environment written in C, with a simple interface for patching in more capabilities.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XForth

." Hello world!"

Overview

Xforth is intended to ease the use of FORTH on modern systems. It has a tiny codebase, and adding more native features easily is a priority. It is not ANSI compliant, however it is designed in a way that I believe to be superior, in both minimalism and ease of use.

Goals

  • Simplicity
  • Efficiency
  • Minimalism

Prerequisites

This project requires GNU make, gcc, and ruby. All of the language is written in C, however the extension mechanism uses ruby to parse the C files.

Building

Simply type make. To rapidly test new additions, make run will build and start the interpreter. To install (unix-like only), sudo make install.

Running

A simple frontend is provided in frontend/xforth.rb. To run after installation, simply try xforth repl. If you add another entry point in the C code, you can use that as your entry point instead of repl.

Extending The Language

Though described in much more details in doc/extend.txt, a simple example is:

//This code will add a new word named rot to the language via C

//g r rot rot
void rot(){
	//^Note that the bracket trails the function name
	unsigned int a, b, c;
	a = pop();
	b = pop();
	c = pop();
	push(c);
	push(b);
	push(a);
}

Using the Language

( if you've ever used forth before, you'll feel right at home)
." This will print this string"
1 2 + . ( This will add these two numbers and print them)

Xforth vs Gforth

This is not a replacement for Gforth, however it is intended to make interactions with modern OSs easier. Support for real files etc. is in the works, and I plan to release a fork with sockets eventually.

Happy Hacking!

About

A portable forth environment written in C, with a simple interface for patching in more capabilities.


Languages

Language:C 73.7%Language:Ruby 22.0%Language:Forth 2.7%Language:Makefile 1.6%