dash-lang

Crates.iodash-lang
lib.rsdash-lang
version0.2.0
created_at2025-10-14 19:11:42.749382+00
updated_at2025-10-15 14:55:53.560543+00
descriptionA simple interpreted language
homepage
repositoryhttps://github.com/Pjdur/dash-lang
max_upload_size
id1882945
size30,789
Pjdur (Pjdur)

documentation

https://docs.rs/dash-lang

README

Dash

Dash is a lightweight interpreted programming language written in Rust. It supports variables, arithmetic, control flow, functions, and return values — all powered by a custom grammar using Pest. Whether you're building a scripting engine, learning interpreters, or just having fun, Dash is a great place to start.


✨ Features

  • ✅ Variables and arithmetic (let x = 3 + 4)
  • ✅ Control flow: if, while, break, continue
  • ✅ Functions with parameters and return values
  • ✅ Print statements
  • ✅ CLI support for running .dash files
  • ✅ Custom grammar with Pest

🚀 Getting Started

1. Clone the repo

git clone https://github.com/Pjdur/dash-lang.git
cd dash

2. Build and run

cargo run

This runs a default hardcoded script. To run a file:

cargo run -- examples/hello.dash

Or build and run:

cargo build --release
./target/release/Dash examples/hello.dash

📄 Language Syntax

Variables and Arithmetic

let x = 3 + 4
print(x)

Control Flow

let x = 0
while x < 5 {
  print(x)
  let x = x + 1
}

If / Else

if x > 10 {
  print("big")
} else {
  print("small")
}

Functions and Return

fn add(a, b) {
  return a + b
}

let result = add(5, 7)
print(result)

Break / Continue

while x < 10 {
  let x = x + 1
  if x == 5 {
    continue
  }
  if x == 8 {
    break
  }
  print(x)
}

📦 Project Structure

  • src/main.rs — Entry point and CLI
  • lang.pest — Grammar definition
  • Context, Expr, Stmt, Op — Core AST and runtime structures
  • build_expr, build_stmt, exec_stmt, eval_expr — Parser and interpreter logic

🧪 Examples

Create a file like examples/hello.dash:

fn greet(name) {
  print("Hello")
  print(name)
}

greet("World")

Then run:

cargo run -- examples/hello.dash

📚 Documentation

All core functions and data structures are documented with Rust-style /// comments. You can generate docs with:

cargo doc --open

🤝 Contributing

Pull requests are welcome! If you’d like to add features (booleans, arrays, REPL, etc.), improve error handling, or optimize performance, feel free to fork and submit a PR.


📜 License

MIT License. See LICENSE for details.


💬 Credits

Built with ❤️ using Rust and Pest. Inspired by classic interpreter designs and educational language projects.

Commit count: 0

cargo fmt