diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ab9e689 --- /dev/null +++ b/Makefile @@ -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) diff --git a/default/defs.h b/default/defs.h new file mode 100644 index 0000000..5ccb461 --- /dev/null +++ b/default/defs.h @@ -0,0 +1,14 @@ +#ifndef __KF_PLATFORM_DEFAULT_H__ +#define __KF_PLATFORM_DEFAULT_H__ + +#include + +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__ \ No newline at end of file diff --git a/defs.h b/defs.h new file mode 100644 index 0000000..d4847b8 --- /dev/null +++ b/defs.h @@ -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__ \ No newline at end of file diff --git a/doc/index.rst b/doc/index.rst index 1792dca..07991af 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -13,6 +13,7 @@ Contents: part-0x05 part-0x06 part-0x07 + part-0x08 Indices and tables ================== diff --git a/doc/part-0x08.rst b/doc/part-0x08.rst new file mode 100644 index 0000000..bd437dc --- /dev/null +++ b/doc/part-0x08.rst @@ -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 + diff --git a/pc/defs.h b/pc/defs.h new file mode 100644 index 0000000..050aded --- /dev/null +++ b/pc/defs.h @@ -0,0 +1,14 @@ +#ifndef __KF_PLATFORM_PC_H__ +#define __KF_PLATFORM_PC_H__ + +#include + +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__ \ No newline at end of file diff --git a/stack.h b/stack.h new file mode 100644 index 0000000..a41a1ce --- /dev/null +++ b/stack.h @@ -0,0 +1,9 @@ +#ifndef __KF_STACK_H__ +#define __KF_STACK_H__ + + + +static + + +#endif // __KF_STACK_H__ \ No newline at end of file