CreatorSiSo/rym
Personal programming language project
Rym Lang or just Rym is a modern, statically typed programming language inspired by Rust, Swift, Python and others that focuses on ease of use and safety. Big thanks go to Robert Nystrom who made his book crafting interpreters open source which enabled me to read it and learn a lot :).
null
nil
undefined
Option<T>
enumResult<T>
func main() -> Result<(), Error>, ?Io {
const msg = "Hello World"
print(msg)
mut num = 2/4 * (10 - 1)
print("Number:", num)
const msg = msg + "!"
print("Combined:", msg, num)
}
In Rym you can unwrap Tryable
values like Option
s or Result
s
const inner = maybe_value()!
// Same as
const inner = maybe_value().unwrap()
Early returns when unwrapping Tryable
s
func main() -> Result<Number, String> {
const number = maybe_error()?
print(number)
// Same as
const inner = match maybe_error() {
Ok(val) => val,
err => return err,
}
print(inner)
}
Tryable chaining
const chained = maybe_error()&.to_string()
// Short form of:
const chained = match maybe_error() {
Ok(val) => Ok(val.to_string()),
err => err,
}
// or:
const chained = maybe_error().and_then(|val| Ok(val.to_string()))
TODO
The project is split into many crates that are part of one Cargo workspace:
crates/rym_span
⇒ Span
crates/rym_tt
⇒ TokenTree, TokenStream
crates/rym_lexer
⇒ Isolated initial lexer
crates/ast
⇒ Ast Types: Spanned, AstVisitor, Token, ...
crates/lex
⇒ produce Tokens from source
crates/parse
⇒ produce ast from tokens
crates/code_gen
⇒ generate optimized code (dead code analysis, ...) or give warnings
crates/tree_walk
⇒ evaluate ast
crates/tests
⇒ integration tests
crates/rymx
⇒ command line tool for executing .rym
files
And some other scripts located in the root directory:
bench.sh
⇒ builds and runs various benchmarks
test.py
⇒ updates and runs all tests
Run python test.py
to update and execute all tests.
This internally runs cargo r --bin gen -- ./crates/tests/src/integration
which includes the source code for all tests into crates/tests/src/integration/mod.rs
.
use insta snapshot testing crate
add benchmarking capabilities
use arena allocator for scopes?
benchmark before & after
use logos lexer generator?
errors
use Spanned<T>
where possible
implement error recovery to jump to next safe expr/stmt
use error codes that link to a more detailed explanation (https://github.com/rust-lang/rust/tree/master/compiler/rustc_error_codes)
true && (break)
currently only returns Error: Expected Literal got RightParen, Span: 14..14
, it should also say something along the lines of: Tip: insert expression or semicolon after break
data types
number
s, string
, char
, bool
(literal) values that come from source code directly:
Literal<u8>
, Literal<f32>
, Literal<string>
, Literal<char>
, Literal<bool>
1
, 2.2
, "Hello World!"
, '\n'
, false
type unions: 0 | 1 | bool
type functions docs/functions.md?