Skip to content

Instantly share code, notes, and snippets.

@Ismael-VC
Last active April 5, 2023 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ismael-VC/b55566e6a7239dd2921db055f52cca78 to your computer and use it in GitHub Desktop.
Save Ismael-VC/b55566e6a7239dd2921db055f52cca78 to your computer and use it in GitHub Desktop.
Uxntal REPL.
( 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
( ... )
&print
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