From 0618ff11ccf50fd6e8a6e0bd7820f19b100ca44a Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 23 Nov 2020 00:47:27 +0100 Subject: feat(tazjin/rlox): Bootstrap program This is going to be the first of two interpreters from "Crafting Interpreters". Change-Id: I354ddd2357444648d0245f35d92176dd176525d8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2142 Reviewed-by: tazjin Tested-by: BuildkiteCI --- users/tazjin/rlox/.gitignore | 3 +++ users/tazjin/rlox/Cargo.lock | 6 ++++++ users/tazjin/rlox/Cargo.toml | 9 +++++++++ users/tazjin/rlox/README.md | 7 +++++++ users/tazjin/rlox/src/main.rs | 23 +++++++++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 users/tazjin/rlox/.gitignore create mode 100644 users/tazjin/rlox/Cargo.lock create mode 100644 users/tazjin/rlox/Cargo.toml create mode 100644 users/tazjin/rlox/README.md create mode 100644 users/tazjin/rlox/src/main.rs diff --git a/users/tazjin/rlox/.gitignore b/users/tazjin/rlox/.gitignore new file mode 100644 index 000000000000..29e65519ba35 --- /dev/null +++ b/users/tazjin/rlox/.gitignore @@ -0,0 +1,3 @@ +result +/target +**/*.rs.bk diff --git a/users/tazjin/rlox/Cargo.lock b/users/tazjin/rlox/Cargo.lock new file mode 100644 index 000000000000..d8107726e067 --- /dev/null +++ b/users/tazjin/rlox/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "rlox" +version = "0.1.0" + diff --git a/users/tazjin/rlox/Cargo.toml b/users/tazjin/rlox/Cargo.toml new file mode 100644 index 000000000000..1562e7ecc2a3 --- /dev/null +++ b/users/tazjin/rlox/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "rlox" +version = "0.1.0" +authors = ["Vincent Ambo "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/users/tazjin/rlox/README.md b/users/tazjin/rlox/README.md new file mode 100644 index 000000000000..1d2692d09cc1 --- /dev/null +++ b/users/tazjin/rlox/README.md @@ -0,0 +1,7 @@ +This is an interpreter for the Lox language, based on the book "[Crafting +Interpreters](https://craftinginterpreters.com/)". + +The book's original code uses Java, but I don't want to use Java, so I've +decided to take on the extra complexity of porting it to Rust. + +Note: This implements the first of two Lox interpreters. diff --git a/users/tazjin/rlox/src/main.rs b/users/tazjin/rlox/src/main.rs new file mode 100644 index 000000000000..3f173673a177 --- /dev/null +++ b/users/tazjin/rlox/src/main.rs @@ -0,0 +1,23 @@ +use std::process; +use std::env; + +fn run_file(_file: &str) { + unimplemented!("no file support yet") +} + +fn run_prompt() { + unimplemented!("no prompt support yet") +} + +fn main() { + let mut args = env::args(); + + if args.len() > 1 { + println!("Usage: rlox [script]"); + process::exit(1); + } else if let Some(file) = args.next() { + run_file(&file); + } else { + run_prompt(); + } +} -- cgit 1.4.1