Last active
April 5, 2023 23:27
-
-
Save Ismael-VC/b55566e6a7239dd2921db055f52cca78 to your computer and use it in GitHub Desktop.
Uxntal REPL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( hello.tal ) | |
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ] | |
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ] | |
%HALT { #01 .System/halt DEO } | |
%DEBUG { #01 .System/debug DEO } | |
%RTN { JMP2r } | |
%\s { 20 } | |
%\n { 0a } | |
%\0 { 00 } | |
%NL { LIT \n STDOUT } | |
%STDIN { .Console/read DEI } | |
%STDOUT { .Console/write DEO } | |
%IO { .Console/vector DEO2 } | |
|0100 @main ( -> ) | |
banner | |
prompt | |
;repl IO | |
BRK | |
@print-str ( str* -- ) | |
&while | |
LDAk STDOUT | |
INC2 LDAk ?&while | |
POP2 | |
RTN | |
@banner ( -- ) | |
;banner-str print-str | |
RTN | |
@prompt ( -- ) | |
;prompt-str print-str | |
RTN | |
@repl ( -> ) | |
&read | |
STDIN | |
&eval | |
( ... ) | |
STDOUT ( for now just echo ) | |
&loop | |
BRK | |
@banner-str [ | |
"uxntal \s "REPL \s "v0.1.0 \n | |
"Snufkin \s "(2023) \n \0 | |
] | |
@prompt-str "tal> \s \0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment