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-12-06T13·21+0100
committertazjin <mail@tazj.in>2020-12-06T14·30+0000
commit5fcff11eae107b76177a581dc604ac0408213b02 (patch)
treea17e08bfd4a55017c9a578b1cddf623080b97c4c /users/tazjin/rlox/src/scanner.rs
parenta8371b01df1b1d16f682e6685cc62fcba4bc54d2 (diff)
feat(tazjin/rlox): Implement parsing up to unary expressions r/1987
... with the exception of parenthesised expressions, because error
threading is not implemented yet.

Change-Id: I8d455d85e647548d5b71cbfd3d078f4970dab7fb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2232
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.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/users/tazjin/rlox/src/scanner.rs b/users/tazjin/rlox/src/scanner.rs
index eeb247d9bd53..fde43975316f 100644
--- a/users/tazjin/rlox/src/scanner.rs
+++ b/users/tazjin/rlox/src/scanner.rs
@@ -1,6 +1,6 @@
 use crate::errors::{Error, ErrorKind};
 
-#[derive(Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq)]
 pub enum TokenKind {
     // Single-character tokens.
     LeftParen,
@@ -29,22 +29,22 @@ pub enum TokenKind {
     Identifier(String),
     String(String),
     Number(f64),
+    True,
+    False,
+    Nil,
 
     // Keywords.
     And,
     Class,
     Else,
-    False,
     Fun,
     For,
     If,
-    Nil,
     Or,
     Print,
     Return,
     Super,
     This,
-    True,
     Var,
     While,
 
@@ -52,7 +52,7 @@ pub enum TokenKind {
     Eof,
 }
 
-#[derive(Debug)]
+#[derive(Clone, Debug)]
 pub struct Token<'a> {
     pub kind: TokenKind,
     pub lexeme: &'a [char],