about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/scanner.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-11-27T17·16+0100
committertazjin <mail@tazj.in>2020-11-27T17·29+0000
commit46c6906aaa4ca0fa16a1fbbcc5993d621d2fb7a7 (patch)
tree3812583711288e8b2b566dda219d4a933501f397 /users/tazjin/rlox/src/scanner.rs
parent3f6b88bce231cfdc00fc7521fcb83d7114ad9142 (diff)
chore(tazjin/rlox): Wire scanner to interpreter to reduce warnings r/1927
... 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
Diffstat (limited to 'users/tazjin/rlox/src/scanner.rs')
-rw-r--r--users/tazjin/rlox/src/scanner.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/users/tazjin/rlox/src/scanner.rs b/users/tazjin/rlox/src/scanner.rs
index 659f280de72b..edd85496a73e 100644
--- a/users/tazjin/rlox/src/scanner.rs
+++ b/users/tazjin/rlox/src/scanner.rs
@@ -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();
+}