Skip to content

qiwenmin/t4th

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

T4th - Tiny Forth

T4th is short for Tiny Forth. This is a project for learning purposes, aiming to implement a Forth interpreter in Python that includes all core and core ext words according to the Forth 2012 Standard, and to pass the relevant test cases.

t4th $ echo 'words' | make run
python main.py
T4th version 0.1.0 [ Free memory 63957 ]

USER-WORD-BEGIN 2VARIABLE ABORT" TO VALUE ACTION-OF IS DEFER@ DEFER! DEFER
ENDOF ENDCASE OF CASE BUFFER: S>HERE SIGN #> #S # HOLDS HOLD UD/MOD <#
HLD 2R> 2>R [IF] [THEN] ." PARSE-NAME XT-SKIP ISNOTSPACE? ISSPACE? FILL
/STRING C" S" COUNT [CHAR] SPACES SPACE ?DUP MAX MIN ['] UNTIL AGAIN
BEGIN >BODY BL <FALSE> <TRUE> FALSE TRUE CONSTANT VARIABLE 2! 2@ CELL+
CHAR+ C! C, C@ ALIGNED ALIGN CELLS CHARS ALLOT +! U> > <> = ABS NEGATE
*/ S>D 2/ 2* 1- 1+ REPEAT WHILE THEN ELSE IF >RESOLVE >MARK 2SWAP 2OVER
2DROP 2DUP TUCK NIP -ROT ROT DECIMAL HEX HERE \ RESTORE-INPUT SAVE-INPUT
SOURCE >NUMBER TYPE WORD PARSE REFILL ACCEPT KEY K J I UNLOOP LEAVE +LOOP
LOOP ?DO DO [ELSE] 0BRANCH BRANCH FIND EXECUTE ' [ ] CHAR (LITERAL)
LITERAL DOES> CREATE (CREATE) COMPILE, [COMPILE] POSTPONE IMMEDIATE
RECURSE EXIT ; :NONAME : DOCOL COMPARE U< 0< 0= < LSHIFT RSHIFT XOR OR
AND INVERT SM/REM */MOD FM/MOD UM/MOD UM* M* /MOD MOD / * - + R@ R>
>R MOVE , @ ! PICK OVER SWAP DROP DUP DEPTH CR EMIT U. . .S ( FORGET
WORDS ENVIRONMENT? PAD-END PAD >IN STATE BASE DP EVALUATE ABORT BYE .VM

About

T4th is short for Tiny Forth. This is a project for learning purposes, aiming to implement a Forth interpreter in Python that includes all core and core ext words according to the Forth 2012 Standard, and to pass the relevant test cases.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors