Tokenize transition keyword

This commit is contained in:
Pranav Gaddamadugu 2022-10-03 08:16:55 -07:00
parent b92fefddc4
commit 62b16cfa51
4 changed files with 8 additions and 1 deletions

View File

@ -427,6 +427,7 @@ impl Token {
"self" => Token::SelfLower,
"string" => Token::String,
"struct" => Token::Struct,
"transition" => Token::Transition,
"true" => Token::True,
"u8" => Token::U8,
"u16" => Token::U16,

View File

@ -109,6 +109,7 @@ mod tests {
string
struct
test
transition
true
u128
u64
@ -159,7 +160,7 @@ mod tests {
assert_eq!(
output,
r#""test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" test_ident 12345 address async bool const else false field finalize for function group i128 i64 i32 i16 i8 if in input let mut return scalar self string struct test true u128 u64 u32 u16 u8 console ! != && ( ) * ** + , - -> => _ . .. / : ; < <= = == > >= [ ] { { } } || ? @ // test
r#""test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" test_ident 12345 address async bool const else false field finalize for function group i128 i64 i32 i16 i8 if in input let mut return scalar self string struct test transition true u128 u64 u32 u16 u8 console ! != && ( ) * ** + , - -> => _ . .. / : ; < <= = == > >= [ ] { { } } || ? @ // test
/* test */ // "#
);
});

View File

@ -132,6 +132,7 @@ pub enum Token {
SelfLower,
Static,
Struct,
Transition,
// For imports.
Leo,
@ -177,6 +178,7 @@ pub const KEYWORD_TOKENS: &[Token] = &[
Token::Static,
Token::String,
Token::Struct,
Token::Transition,
Token::True,
Token::U8,
Token::U16,
@ -228,6 +230,7 @@ impl Token {
Token::Static => sym::Static,
Token::String => sym::string,
Token::Struct => sym::Struct,
Token::Transition => sym::transition,
Token::True => sym::True,
Token::U8 => sym::u8,
Token::U16 => sym::u16,
@ -344,6 +347,7 @@ impl fmt::Display for Token {
Return => write!(f, "return"),
Static => write!(f, "static"),
Struct => write!(f, "struct"),
Transition => write!(f, "transition"),
Leo => write!(f, "leo"),
Eof => write!(f, "<eof>"),
}

View File

@ -215,6 +215,7 @@ symbols! {
std,
Struct: "struct",
test,
transition,
Type: "type",
public,