misc/kforth: Start over.

This commit is contained in:
Kyle Isom 2018-03-02 08:47:56 -08:00
parent 7c5297118a
commit a1149654d4
7 changed files with 91 additions and 0 deletions

23
Makefile Normal file
View File

@ -0,0 +1,23 @@
CXXSTD := c++14
CXXFLAGS := -std=$(CXXSTD) -Wall -Werror -O0 -g
LDFLAGS := -static
OBJS := linux/io.o \
io.o \
system.o \
parser.o \
word.o \
dict.o \
kforth.o
TARGET := kforth
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) $(LDFLAGS) -o $@ $(OBJS)
clean:
rm -f $(OBJS) $(TARGET)
install: $(TARGET)
cp $(TARGET) ~/bin
chmod 0755 ~/bin/$(TARGET)

14
default/defs.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef __KF_PLATFORM_DEFAULT_H__
#define __KF_PLATFORM_DEFAULT_H__
#include <stdint.h>
typedef int KF_INT;
typedef uintptr_t KF_ADDR;
constexpr static size_t STACK_SIZE = 48 / sizeof(KF_INT);
constexpr static size_t DICT_SIZE = 4096;
constexpr static size_t ARENA_SIZE = 256;
#endif // __KF_PLATFORM_DEFAULT_H__

12
defs.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef __KF_DEFS_H__
#define __KF_DEFS_H__
#if PLATFORM == PC
#include "pc/defs.h"
#else
#include "default/defs.h"
#endif
#endif __KF_DEFS_H__

View File

@ -13,6 +13,7 @@ Contents:
part-0x05 part-0x05
part-0x06 part-0x06
part-0x07 part-0x07
part-0x08
Indices and tables Indices and tables
================== ==================

18
doc/part-0x08.rst Normal file
View File

@ -0,0 +1,18 @@
Write You a Forth, 0x08
-----------------------
:date: 2018-03-01 19:31
:tags: wyaf, forth
After reading some more in Threaded Interpreted Languages (TIL_ from now on),
I've decided to start over.
.. _TIL: http://wiki.c2.com/?ThreadedInterpretiveLanguage
Some design choices that didn't really work out:
+ the system structure
+ not making it easier to test building for different platforms
+ my linked list approach to the dictionary
+ my class-based approach to words

14
pc/defs.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef __KF_PLATFORM_PC_H__
#define __KF_PLATFORM_PC_H__
#include <stdint.h>
typedef int32_t KF_INT;
typedef uintptr_t KF_ADDR;
constexpr static size_t STACK_SIZE = 65535;
constexpr static size_t DICT_SIZE = 65535;
constexpr static size_t ARENA_SIZE = 65535;
#endif // __KF_PLATFORM_PC_H__

9
stack.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef __KF_STACK_H__
#define __KF_STACK_H__
static
#endif // __KF_STACK_H__