No description
- Gleam 95.3%
- Vento 1.2%
- Nix 1.1%
- JavaScript 1.1%
- Just 0.7%
- Other 0.6%
inter
A parser for a simple language.
fact = fn(n) begin
case n of
0 -> 1
n -> n * fact(n - 1)
end
end
You can find more examples of the language itself in the ./mischief/ directory.
Development
gleam run # to enter a REPL
gleam run -- help # see cli options
gleam test # Run the tests
Required dependencies
There is a flake.nix if you have nix + direnv setup.
Otherwise you'll need at least gleam + erlang (or a JavaScript runtime) installed.
If you want to try the bare bones scheme backend you'll also need chicken-scheme.
Design
Passes
Lex↓Parse↓ModuleResolution// TODO: can this happen after lowering to ANF?↓TypeCheck↓ANF↓BackendUniform Function Call Syntax
"hello".print()
"hello".(fn(s) s.split("e"))()
transforms into
print("hello")
(fn(s) split(s, "e"))("hello")
grammar
Lexical grammar can be seen in the lexer.
TODO: Terminals
IDENTIFIER: Lower case name e.g. hello, sqrt, hello_world
module = { statement } ;
statement = assignment | expression ;
assignment = IDENTIFIER [ ":" type ] "=" expression ;
expression = NUMBER | BOOLEAN | TODO