Friday, December 7, 2018

A great compact Forth interpreter

Leif Bruder created an 1100 line version of forth, and it compiles and works.
So, It does not really use linux comman, it is reverse Polish, except for its internal built ins. 

The RVP notation is fine, the Forth interpreter is the default command line control.  and we give it an interface to the linux cconsolloop. Macros crated wiithin the Forth conext will call Console directly with create linux strings. I will create the EXPORT key word which calls console loop internal to Forth. Everything reentrant I hope.  

So tis is simple stuff now.  Console loop starts, loads Xchars, then loads Forth. On calling Forth Init, there is no return, Forth takes over, and Forth can even call LoadModule for further subsystems.

Ts version of Linux Screen is 1300 lines of other peoples code, I am not cheating about the 1300 lines. I get a complete UI base gdb, my Forth can handle that, and I start gdb with a redirect of stdio in sys call. That gets me a gdb subsystem, piped to the Forth. Forth executes gdb commands on queue, picks up the p var output and calls Xchars to place it poperly.

I can initialize Forth with macro wrappers for gcc flags and vars. Forth manages all my paths. I load my gcc subsystem along side my gdb.  Forth sets up all the macros, don't need any environment, just load my personal Forth initialization file.    Then I find the tiny 2-dimensional vi I can get, the simplest of text editors. I adapt it to Xchars, and have that as a  loadable module.  

I am get 2,000 lines of code and including a Forth macro machine backing me up, a small footprint and a full development IDE. It needs no headers, just familiarity with Forth, works on any linux with only libc. Make file is simple:  

gcc forth.c xchars.c console.c -lxcb

No comments: