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 <mail@tazj.in>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2020-11-23 00:47:27 +01:00 committed by tazjin
parent 312d76acba
commit 0618ff11cc
5 changed files with 48 additions and 0 deletions

3
users/tazjin/rlox/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
result
/target
**/*.rs.bk

6
users/tazjin/rlox/Cargo.lock generated Normal file
View file

@ -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"

View file

@ -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]

View file

@ -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.

View file

@ -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();
}
}