Do not follow this link

~otheb/stf

Statically Typed Forth / Static Toy Forth - toy interpreter for a language vaguely resembling forth
Update readme
Write lexer
Write first design draft

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~otheb/stf
read/write
git@git.sr.ht:~otheb/stf

You can also use your local clone with git send-email.

                                  ### STF ###

Toy language that is a mix of Forth[1] and Magpie[2]. Combines mostly
concatenative syntax and stack-based programming with a relatively simple type
system and multi-methods.

[1] https://en.wikipedia.org/wiki/Forth_(programming_language)
[2] https://magpie-lang.org/index.html

# SYNTAX OVERVIEW

\ this is a line comment
( this is a block comment ( they nest ) )

\ integer literals
123 -123 123u 123ul -123l

\ float literals
1.23 -1.23 .123 -.123 1.23d

\ string literals
"hello there!"

\ conditional
<condition> if <iftrue> end
<condition> if <iftrue> else <iffalse> end

\ conditional loop
while <condition> do <body> end
until <condition> do <body> end

\ iteration
<n> repeat <body> end
<start> <end> loop <body> end
<start> <end> <step> sloop <body> end

\ variables
var <name> \ create
= <name> \ assign

\ functions
fn [{ <types> }] <name> [{ <returns> }] <body> end
\ example (fibonacci)
fn { num } fib { num }
	dup 1 <= if drop 1 else 1 - dup fib swap 1 - fib + end
end

\ blocks for containing locals
do <body> end

\ types
type <name> [{ <interits> }]
	<name> : <type> \ member
	[...]
end

# HELLO WORLD

"hello world!" prln
Do not follow this link