chore(tazjin/rlox): Wire scanner to interpreter to reduce warnings

... they're just noisy at the moment. This isn't complete because it
doesn't thread through scanner errors.

Change-Id: I0f75d2b20fa3f57be1af5d1d8aa8059856855825
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2162
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2020-11-27 18:16:42 +01:00 committed by tazjin
parent 3f6b88bce2
commit 46c6906aaa
2 changed files with 18 additions and 1 deletions

View file

@ -1,4 +1,8 @@
use crate::scanner;
// Run some Lox code and print it to stdout
pub fn run(_code: &str) {
pub fn run(code: &str) {
let chars: Vec<char> = code.chars().collect();
let _tokens = scanner::scan(&chars);
println!("no interpreter yet, sorry")
}

View file

@ -133,3 +133,16 @@ impl<'a> Scanner<'a> {
return self.tokens;
}
}
pub fn scan<'a>(input: &'a [char]) -> Vec<Token<'a>> {
let scanner = Scanner {
source: &input,
tokens: vec![],
errors: vec![],
start: 0,
current: 0,
line: 0,
};
return scanner.scan_tokens();
}