token: reserve "and", "or", "in" as keywords

This commit is contained in:
2025-10-16 01:37:24 -04:00
parent b5d552376e
commit f47de24cfb
2 changed files with 6 additions and 0 deletions

View File

@@ -235,6 +235,7 @@ impl<'t> Lexer<'t> {
let token = self.produce(TKind::Identifier);
Ok(Token {
kind: match lexeme {
"and" => TKind::And,
"as" => TKind::As,
"break" => TKind::Break,
"const" => TKind::Const,
@@ -244,11 +245,13 @@ impl<'t> Lexer<'t> {
"fn" => TKind::Fn,
"for" => TKind::For,
"if" => TKind::If,
"in" => TKind::In,
"let" => TKind::Let,
"loop" => TKind::Loop,
"macro" => TKind::Macro,
"match" => TKind::Match,
"mod" => TKind::Module,
"or" => TKind::Or,
"pub" => TKind::Public,
"return" => TKind::Return,
"struct" => TKind::Struct,

View File

@@ -56,6 +56,7 @@ impl std::fmt::Display for Lexeme {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TKind {
Comment,
And,
As,
Break,
Const,
@@ -65,11 +66,13 @@ pub enum TKind {
Fn,
For,
If,
In,
Let,
Loop,
Macro,
Match,
Module,
Or,
Public,
Return,
Struct,