Petal is a hobby programming language with a compiler transpiler (to C) written in Rust. A LLVM (or maybe
Cranelift) compiler backend will be added in the future.
- Basic function declarations (parameters, return types)
- Signed and unsigned integer types
- Variable declarations
- Function calls (arguments)
- Basic type-checking
- Variable assignment
- Named function call arguments (
myFunc(value: i32))- Make positional parameters the default, with
~signifying a named parameter.
- Make positional parameters the default, with
- Booleans
- Control flow (if, while)
- Equality operands (
==,!=) - Smart type inference for integers
- For example,
i64 a = 5;should compile, but it does not as5is always treated as ani32. It should be inferred to be ani64(if the literal fits in the width).
- For example,
- Multiple module support
- Private module members by default (expose via
publickeyword) - Name mangling
- Private module members by default (expose via
- References
- User defined types (
type CString = &u8) - Structures
- Member access
- Member function declarations
- Member function calls
- Optionals (
type Optional<T> = { is_present: bool, value: T })- Short-hand via type modifiers, e.g.
?i32. - Smart casting
- Short-hand via type modifiers, e.g.
- Basic generics
- Generic functions
- Member functions of generic types (
func <T> Foo<T>.bar()) - Generic type argument inference
- Enums
- Tagged unions?
- Arrays
- IR
- ...
- Website/playground REPL
- LLVM or Cranelift backend
Anyone is open to making a pull request! Before you do, please ensure that the feature you are adding is documented on a GitHub issue, and has been approved by @caoimhebyrne.
I request that any code submissions are not entirely AI written. If you are going to use AI tools on this project, then:
- Ensure that you understand the code that it is producing.
- Guide the AI using your existing knowledge and ideas.
This project is licensed under the Apache License 2.0 license.
