test.mty (938B)
fn is_alpha :: (>= 'a' && <= 'z') || (>= 'A' && <= 'z')
fx main ::
with []Token tokens
with contents = read_file filename | split
@ match
'+' => tokens += (Token){.type = PLUS}
'-' => tokens += (Token){.type = MINUS}
is_alpha => tokens += parse @+
??? => throw("unknown token")
fx main :: print "hello" // "hello"
fx main :: with "hello" print // hello
fx main :: with "hello" | split @ print // [h e l l o]
fx sub :: T1 - T2
fx main :: print "hello, world!"
fx add :: int, int -> int = A + B
fx sub :: int, int -> int = A - B
fx err :: str =
fprintf(std.err, str)
exit 1
// terse, readable, reliable, enjoyable
use lexer
fx main :: int =
filename := std.args[1]
contents := std.read_file(filename)
tokens := lexer.lex(contents)
print_tokens(tokens)
ns lexer
fx lex :: str contents =
@[contents]
| ignore_whitespace
| parse_idents
| parse_chars
fn parse_idents :: char x =
static str word = ""