Skip to content

SebaB29/RustTheForth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚙️ Rust the Forth

📜 Table of Contents

✨ Features

  • Integer arithmetic: +, -, *, /
  • Stack manipulation: DUP, DROP, SWAP, OVER, ROT
  • Word definition: : <word> <body> ;
  • Output operations: ., EMIT, CR, ." message"
  • Boolean logic: =, <, >, AND, OR, NOT
  • Conditional execution: IF ... THEN, IF ... ELSE ... THEN
  • Stack saved to stack.fth after execution
  • Error messages for common issues: stack-underflow, division-by-zero, invalid-word, etc.

🔧 Technologies

  • Language: Rust (version 1.85)
  • Tooling: Cargo
  • Testing: cargo test (unit + integration tests)
  • Linting: Clippy (no warnings)
  • Formatting: cargo fmt
  • Documentation: cargo doc
  • Platform: Unix / Linux only

❗ No crates, .unwrap(), .expect(), panic!(), exit() or unsafe blocks allowed.

▶️ Usage

Build the project:

cargo build --release

Run the interpreter with a .fth file:

cargo run -- path/to/file.fth

Optionally, set a custom stack size in bytes (default: 128 KB):

cargo run -- path/to/file.fth stack-size=262144

Example .fth File

: HELLO CR ." Hello, World!" ;
HELLO

Output:

Hello, World!

Final stack is saved to stack.fth.

🧪 Testing

Run all unit and integration tests:

cargo test

📄 License

This project is released under the MIT License. See LICENSE for details.

📚 About This Project

This interpreter was developed as part of an individual academic exercise for the subject Taller de Programación I (1C 2025).
The goal was to replicate core features of the Forth-79 standard using only Rust's standard library, without external dependencies, and following strict memory and error-handling guidelines.

For more details, please refer to the enunciado.pdf file.

About

Trabajo Práctico de la materia Taller de Programación (TA045)

Topics

Resources

License

Stars

Watchers

Forks

Languages