parser2
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Keyword {
|
||||
Let,
|
||||
Fn,
|
||||
}
|
||||
|
||||
impl Keyword {
|
||||
pub fn parse(ident: &str) -> Option<Self> {
|
||||
Some(match ident {
|
||||
"let" => Self::Let,
|
||||
"fn" => Self::Fn,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Keyword> for Token {
|
||||
fn from(value: Keyword) -> Self {
|
||||
Token::Keyword(value)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user