inblossoms /
rox
🧠 简介. Rox is a strongly-typed, tree-walk interpreter, implemented in Rust. Based on the excellent book Crafting Interpreters by Bob Nystrom, this implementation diverges to Rust patterns, focusing on memory safety, stri…
inblossoms /
🧠 简介. Rox is a strongly-typed, tree-walk interpreter, implemented in Rust. Based on the excellent book Crafting Interpreters by Bob Nystrom, this implementation diverges to Rust patterns, focusing on memory safety, stri…
🧠 简介. Rox is a strongly-typed, tree-walk interpreter, implemented in Rust. Based on the excellent book Crafting Interpreters by Bob Nystrom, this implementation diverges to Rust patterns, focusing on memory safety, strict type checking, and a robust error-handling architecture. 🎯 地址. 🪄 贡献参与. 🌟 Usage. 1. REPL Mode (Interactive) Run without arguments to start the interactive shell: bash cargo run javascript var a = "Hello"; print a + " World"; Hello World 2. Script Mode Run a .rox file: bash cargo run -- scripts/fibonacci.rox 📝 Syntax Examples Classes and Inheritance: javascript class Doughnut { cook() { print "Fry until golden brown."; } } class BostonCream < Doughnut { cook() { super.cook(); print "Pipe full of custard."; } } BostonCream().cook(); Closures: javascript fun makeCounter() { var i = 0; fun count() { i = i + 1; print i; } return count; } var counter = makeCounter(); counter(); // "1" counter(); // "2" Bitwise Operations & Control Flow: javascript var flags = 5; // 0101 var mask = 1; // 0001 if ((flags & mask) == 1) { print "Bit is set!"; } for (var i = 0; i < 10; i += 1) { if (i % 2 == 0) continue; print i; } 更多详细内容请参考:Rox
讨论这个产品