about summary refs log tree commit diff
path: root/users
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-11-22T23·47+0100
committertazjin <mail@tazj.in>2020-11-23T01·15+0000
commit0618ff11ccf50fd6e8a6e0bd7820f19b100ca44a (patch)
treea0dea473f205242b043962bf7b3481439aff59f2 /users
parent312d76acba238d448112e3223fda1e9c5560be6c (diff)
feat(tazjin/rlox): Bootstrap program r/1912
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 <mail@tazj.in>
Tested-by: BuildkiteCI
Diffstat (limited to 'users')
-rw-r--r--users/tazjin/rlox/.gitignore3
-rw-r--r--users/tazjin/rlox/Cargo.lock6
-rw-r--r--users/tazjin/rlox/Cargo.toml9
-rw-r--r--users/tazjin/rlox/README.md7
-rw-r--r--users/tazjin/rlox/src/main.rs23
5 files changed, 48 insertions, 0 deletions
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 <mail@tazj.in>"]
+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();
+    }
+}