about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/bytecode/compiler.rs
diff options
context:
space:
mode:
Diffstat (limited to 'users/tazjin/rlox/src/bytecode/compiler.rs')
-rw-r--r--users/tazjin/rlox/src/bytecode/compiler.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/users/tazjin/rlox/src/bytecode/compiler.rs b/users/tazjin/rlox/src/bytecode/compiler.rs
index 95b111dba824..1ab42c705ab4 100644
--- a/users/tazjin/rlox/src/bytecode/compiler.rs
+++ b/users/tazjin/rlox/src/bytecode/compiler.rs
@@ -116,6 +116,10 @@ fn rule_for<T: Iterator<Item = Token>>(token: &TokenKind) -> ParseRule<T> {
             ParseRule::new(Some(Compiler::literal), None, Precedence::None)
         }
 
+        TokenKind::Bang => {
+            ParseRule::new(Some(Compiler::unary), None, Precedence::None)
+        }
+
         _ => ParseRule::new(None, None, Precedence::None),
     }
 }
@@ -168,6 +172,7 @@ impl<T: Iterator<Item = Token>> Compiler<T> {
 
         // Emit operator instruction
         match kind {
+            TokenKind::Bang => self.emit_op(OpCode::OpNot),
             TokenKind::Minus => self.emit_op(OpCode::OpNegate),
             _ => unreachable!("only called for unary operator tokens"),
         }