2024-09-15 04:20:23 +01:00
# fddl Programming Language
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
**fddl** is a small, experimental programming language, built in Rust, designed to explore language implementation concepts. It's a blend of ideas from various languages but remains unique, with its own syntax and quirks.
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
This project is both a learning experience and a passion project, where the goal is to build a working language from scratch, while embracing some of the core features I enjoy from other languages.
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
## Why fddl?
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
For years, I’ ve tried to learn various programming languages, and while I could master the basics, the real-world projects often eluded me. Rust, however, clicked for me, and fddl was born out of this journey. fddl is my attempt to combine the aspects I appreciate from many languages into something uniquely my own.
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
---
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
## Current Features
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
- **Custom Syntax**: fddl introduces unique operators and keywords to make programming more intuitive and fun.
- **Lexer**: A working lexer that tokenizes fddl scripts into understandable pieces of the language.
- **Tilde Operator**: Includes a custom `~` and `~=` operator for creative syntax possibilities.
---
2024-09-15 04:01:16 +01:00
## Getting Started
2024-09-16 05:37:24 +01:00
To start experimenting with fddl, you can run it in two ways:
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
### Run the REPL (Interactive Mode)
2024-09-15 04:01:16 +01:00
```sh
cargo run
```
2024-09-16 05:37:24 +01:00
### Run a fddl Script
2024-09-15 04:01:16 +01:00
```sh
cargo run path/to/script.fddl
```
2024-09-16 05:37:24 +01:00
---
2024-09-15 04:01:16 +01:00
## Examples
2024-09-16 05:37:24 +01:00
Here are a couple of examples showcasing the current capabilities of fddl:
### Hello World
```fddl
2024-09-15 21:00:46 +01:00
func main() {
2024-09-16 05:37:24 +01:00
print("hello, world in fddl");
}
2024-09-15 21:00:46 +01:00
```
2024-09-16 05:37:24 +01:00
### Simple Math Module and Variable Declaration
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
```fddl
# This is a sample module
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
module math {
# Computes the square of a number
2024-09-15 04:01:16 +01:00
func square(x) => x ^ 2;
}
define $number := 5;
print(`The square of $number is ${math.square($number)}`);
```
2024-09-16 05:37:24 +01:00
(Note: This feature is under development, and string interpolation is planned for a future update.)
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
---
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
## Roadmap and Next Steps
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
fddl is very much a work in progress, with lots of planned improvements and additions. Here's a breakdown of what’ s done and what’ s coming up:
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
- **Lexer**:
- [x] Built and tested for basic syntax and operators.
- [x] Supports single-line and documentation comments.
- [ ] Add support for more complex syntax and features.
- **Parser**:
- [ ] Currently a placeholder. Implement parsing for function calls, expressions, etc.
- **Compiler**:
- [ ] Currently a placeholder. Implement the compiler to execute parsed code.
- **Comments**:
- [x] Added support for single-line and documentation comments.
- [ ] Implement multi-line comments.
- [ ] Implement document building comments.
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
- **Error Handling**:
- [ ] Replace basic error reporting with a more robust error handling mechanism.
2024-09-15 04:01:16 +01:00
2024-09-16 05:37:24 +01:00
- **String Interpolation**:
- [ ] Implement string interpolation using backticks with `$variable` syntax.
- **Testing**:
- [x] Added initial lexer tests.
- [ ] Expand tests to cover more syntax and edge cases.
2024-09-15 04:01:16 +01:00
---
2024-09-16 05:37:24 +01:00
## Running the Project
2024-09-15 04:01:16 +01:00
Make sure your project compiles and the tests pass:
```bash
cargo build
cargo test
2024-09-16 05:37:24 +01:00
```
## License
This project is licensed under the MIT License.