token: Add new keywords in preparation for grammar update

This commit is contained in:
John 2024-01-06 14:32:56 -06:00
parent 77f7623041
commit 15d7565703

View File

@ -77,18 +77,22 @@ pub enum Type {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Keyword { pub enum Keyword {
Break, Break,
Cl,
Continue, Continue,
Else, Else,
Enum,
False, False,
For, For,
Fn, Fn,
If, If,
In, In,
Let, Let,
Mod,
Mut, Mut,
Return, Return,
SelfKw, SelfKw,
SelfTy, SelfTy,
Struct,
Super, Super,
True, True,
While, While,
@ -167,18 +171,22 @@ impl Display for Keyword {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
Self::Break => "break".fmt(f), Self::Break => "break".fmt(f),
Self::Cl => "cl".fmt(f),
Self::Continue => "continue".fmt(f), Self::Continue => "continue".fmt(f),
Self::Else => "else".fmt(f), Self::Else => "else".fmt(f),
Self::Enum => "enum".fmt(f),
Self::False => "false".fmt(f), Self::False => "false".fmt(f),
Self::For => "for".fmt(f), Self::For => "for".fmt(f),
Self::Fn => "fn".fmt(f), Self::Fn => "fn".fmt(f),
Self::If => "if".fmt(f), Self::If => "if".fmt(f),
Self::In => "in".fmt(f), Self::In => "in".fmt(f),
Self::Let => "let".fmt(f), Self::Let => "let".fmt(f),
Self::Mod => "mod".fmt(f),
Self::Mut => "mut".fmt(f), Self::Mut => "mut".fmt(f),
Self::Return => "return".fmt(f), Self::Return => "return".fmt(f),
Self::SelfKw => "self".fmt(f), Self::SelfKw => "self".fmt(f),
Self::SelfTy => "Self".fmt(f), Self::SelfTy => "Self".fmt(f),
Self::Struct => "struct".fmt(f),
Self::Super => "super".fmt(f), Self::Super => "super".fmt(f),
Self::True => "true".fmt(f), Self::True => "true".fmt(f),
Self::While => "while".fmt(f), Self::While => "while".fmt(f),
@ -191,18 +199,22 @@ impl FromStr for Keyword {
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s { Ok(match s {
"break" => Self::Break, "break" => Self::Break,
"cl" => Self::Cl,
"continue" => Self::Continue, "continue" => Self::Continue,
"else" => Self::Else, "else" => Self::Else,
"enum" => Self::Enum,
"false" => Self::False, "false" => Self::False,
"for" => Self::For, "for" => Self::For,
"fn" => Self::Fn, "fn" => Self::Fn,
"if" => Self::If, "if" => Self::If,
"in" => Self::In, "in" => Self::In,
"let" => Self::Let, "let" => Self::Let,
"mod" => Self::Mod,
"mut" => Self::Mut, "mut" => Self::Mut,
"return" => Self::Return, "return" => Self::Return,
"self" => Self::SelfKw, "self" => Self::SelfKw,
"Self" => Self::SelfTy, "Self" => Self::SelfTy,
"struct" => Self::Struct,
"super" => Self::Super, "super" => Self::Super,
"true" => Self::True, "true" => Self::True,
"while" => Self::While, "while" => Self::While,