L4
L4 is a Forth interpreter written in Common Lisp. The aim is to implement a useful subset of the ANS Forth programming language, but some work is still needed.

L4 currently passes all tests in John Hayes' test suite and is able to execute Sokoban and Tetris games.

Source code: http://www.common-lisp.net/~heller/l4-0.1.tar.gz

License: MIT-LICENSE

Quick assessment (2023-06-09)

  • Portable Common Lisp, except for the Unix-specific use of stty.
  • Implement the shell routine for more Common Lisp implementations.
  • Compiles without warnings, and passes all of the included tests.
  • Switch to the L4 directory in order to load the system (l4.lisp).
  • Use the forth command to boot up, then test as seen below.

L4> forth
loading kernel.fs...
loading kernel.fs...done
ok test
loading test/tester.fs...
loading test/tester.fs...done
loading test/coretest.fs...
TESTING CORE WORDS
TESTING BASIC ASSUMPTIONS
TESTING BOOLEANS: INVERT AND OR XOR
TESTING 2* 2/ LSHIFT RSHIFT
TESTING COMPARISONS: 0= = 0< < > U< MIN MAX
TESTING STACK OPS: 2DROP 2DUP 2OVER 2SWAP ?DUP DEPTH DROP DUP OVER ROT SWAP
TESTING >R R> R@
TESTING ADD/SUBTRACT: + - 1+ 1- ABS NEGATE
TESTING MULTIPLY: S>D * M* UM*
TESTING DIVIDE: FM/MOD SM/REM UM/MOD */ */MOD / /MOD MOD
TESTING HERE , @ ! CELL+ CELLS C, C@ C! CHARS 2@ 2! ALIGN ALIGNED +! ALLOT
TESTING CHAR [CHAR] [ ] BL S"
TESTING ' ['] FIND EXECUTE IMMEDIATE COUNT LITERAL POSTPONE STATE
TESTING IF ELSE THEN BEGIN WHILE REPEAT UNTIL RECURSE
TESTING DO LOOP +LOOP I J UNLOOP LEAVE EXIT
TESTING DEFINING WORDS: : ; CONSTANT VARIABLE CREATE DOES> >BODY
TESTING EVALUATE
TESTING SOURCE >IN WORD
TESTING <# # #S #> HOLD SIGN BASE >NUMBER HEX DECIMAL
TESTING FILL MOVE
TESTING OUTPUT: . ." CR EMIT SPACE SPACES TYPE U.
YOU SHOULD SEE THE STANDARD GRAPHIC CHARACTERS:
 !"#$%&'()*+,-./0123456789:;<=>?@
ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`
abcdefghijklmnopqrstuvwxyz{|}~
YOU SHOULD SEE 0-9 SEPARATED BY A SPACE:
0 1 2 3 4 5 6 7 8 9
YOU SHOULD SEE 0-9 (WITH NO SPACES):
0123456789
YOU SHOULD SEE A-G SEPARATED BY A SPACE:
A B C D E F G
YOU SHOULD SEE 0-5 SEPARATED BY TWO SPACES:
0  1  2  3  4  5
YOU SHOULD SEE TWO SEPARATE LINES:
LINE 1
LINE 2
TESTING DICTIONARY SEARCH RULES
loading test/coretest.fs...done
loading test/postpone.fs...
testing postpone (
testing postpone +loop
testing postpone ."
you should see this first.
you should see this later.
testing postpone ;
testing postpone abort"
testing postpone begin
testing postpone do
testing postpone does>
testing postpone else
testing postpone if
testing postpone literal
testing postpone loop
testing postpone postpone
testing postpone recurse
testing postpone repeat
testing postpone S"
testing postpone then
testing postpone until
testing postpone while
testing postpone [
testing postpone [']
testing postpone [char]
loading test/postpone.fs...done
loading test/coremore.fs...
loading test/coremore.fs...done
loading test/deferred.fs...
loading test/deferred.fs...done
ok