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, "self" => Token::SelfLower,
"string" => Token::String, "string" => Token::String,
"struct" => Token::Struct, "struct" => Token::Struct,
"transition" => Token::Transition,
"true" => Token::True, "true" => Token::True,
"u8" => Token::U8, "u8" => Token::U8,
"u16" => Token::U16, "u16" => Token::U16,

View File

@ -109,6 +109,7 @@ mod tests {
string string
struct struct
test test
transition
true true
u128 u128
u64 u64
@ -159,7 +160,7 @@ mod tests {
assert_eq!( assert_eq!(
output, 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 */ // "# /* test */ // "#
); );
}); });

View File

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

View File

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