From 863a54391cf4a4d336b20fb2b1057d3a34479fa8 Mon Sep 17 00:00:00 2001 From: evan-schott <53463459+evan-schott@users.noreply.github.com> Date: Mon, 12 Feb 2024 22:40:10 -0800 Subject: [PATCH] Add "Future", "Await", "Async", remove "Finalize", "then" tokens --- compiler/parser/src/tokenizer/lexer.rs | 4 ++-- compiler/parser/src/tokenizer/mod.rs | 5 ++--- compiler/parser/src/tokenizer/token.rs | 14 ++++++-------- compiler/span/src/symbol.rs | 2 ++ 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/compiler/parser/src/tokenizer/lexer.rs b/compiler/parser/src/tokenizer/lexer.rs index 506b2ac8ae..b1927adace 100644 --- a/compiler/parser/src/tokenizer/lexer.rs +++ b/compiler/parser/src/tokenizer/lexer.rs @@ -384,6 +384,7 @@ impl Token { "assert" => Token::Assert, "assert_eq" => Token::AssertEq, "assert_neq" => Token::AssertNeq, + "async" => Token::Async, "block" => Token::Block, "bool" => Token::Bool, "console" => Token::Console, @@ -392,7 +393,7 @@ impl Token { "else" => Token::Else, "false" => Token::False, "field" => Token::Field, - "finalize" => Token::Finalize, + "future" => Token::Future, "for" => Token::For, "function" => Token::Function, "group" => Token::Group, @@ -418,7 +419,6 @@ impl Token { "self" => Token::SelfLower, "string" => Token::String, "struct" => Token::Struct, - "then" => Token::Then, "transition" => Token::Transition, "true" => Token::True, "u8" => Token::U8, diff --git a/compiler/parser/src/tokenizer/mod.rs b/compiler/parser/src/tokenizer/mod.rs index 6942e78a22..d5c3428c2d 100644 --- a/compiler/parser/src/tokenizer/mod.rs +++ b/compiler/parser/src/tokenizer/mod.rs @@ -93,9 +93,9 @@ mod tests { else false field - finalize for function + future group i128 i64 @@ -118,7 +118,6 @@ mod tests { string struct test - then transition true u128 @@ -170,7 +169,7 @@ mod tests { assert_eq!( output, - r#""test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" test_ident 12345 address as assert assert_eq assert_neq async bool const else false field finalize for function group i128 i64 i32 i16 i8 if in inline input let mut private program public return scalar self signature string struct test then transition 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 as assert assert_eq assert_neq async bool const else false field for function future group i128 i64 i32 i16 i8 if in inline input let mut private program public return scalar self signature string struct test transition true u128 u64 u32 u16 u8 console ! != && ( ) * ** + , - -> => _ . .. / : ; < <= = == > >= [ ] { { } } || ? @ // test /* test */ // "# ); }); diff --git a/compiler/parser/src/tokenizer/token.rs b/compiler/parser/src/tokenizer/token.rs index aa7cebdefb..2d30fe714a 100644 --- a/compiler/parser/src/tokenizer/token.rs +++ b/compiler/parser/src/tokenizer/token.rs @@ -113,13 +113,14 @@ pub enum Token { Assert, AssertEq, AssertNeq, + Async, Console, Const, Constant, Else, - Finalize, For, Function, + Future, If, Import, In, @@ -134,7 +135,6 @@ pub enum Token { Return, SelfLower, Struct, - Then, Transition, // Meta Tokens @@ -155,6 +155,7 @@ pub const KEYWORD_TOKENS: &[Token] = &[ Token::Assert, Token::AssertEq, Token::AssertNeq, + Token::Async, Token::Bool, Token::Console, Token::Const, @@ -162,9 +163,9 @@ pub const KEYWORD_TOKENS: &[Token] = &[ Token::Else, Token::False, Token::Field, - Token::Finalize, Token::For, Token::Function, + Token::Future, Token::Group, Token::I8, Token::I16, @@ -187,7 +188,6 @@ pub const KEYWORD_TOKENS: &[Token] = &[ Token::Scalar, Token::String, Token::Struct, - Token::Then, Token::Transition, Token::True, Token::U8, @@ -220,7 +220,6 @@ impl Token { Token::Else => sym::Else, Token::False => sym::False, Token::Field => sym::field, - Token::Finalize => sym::finalize, Token::For => sym::For, Token::Function => sym::function, Token::Group => sym::group, @@ -246,7 +245,6 @@ impl Token { Token::SelfLower => sym::SelfLower, Token::String => sym::string, Token::Struct => sym::Struct, - Token::Then => sym::then, Token::Transition => sym::transition, Token::True => sym::True, Token::U8 => sym::u8, @@ -349,13 +347,14 @@ impl fmt::Display for Token { Assert => write!(f, "assert"), AssertEq => write!(f, "assert_eq"), AssertNeq => write!(f, "assert_neq"), + Async => write!(f, "async"), Console => write!(f, "console"), Const => write!(f, "const"), Constant => write!(f, "constant"), Else => write!(f, "else"), - Finalize => write!(f, "finalize"), For => write!(f, "for"), Function => write!(f, "function"), + Future => write!(f, "future"), If => write!(f, "if"), Import => write!(f, "import"), In => write!(f, "in"), @@ -368,7 +367,6 @@ impl fmt::Display for Token { Return => write!(f, "return"), SelfLower => write!(f, "self"), Struct => write!(f, "struct"), - Then => write!(f, "then"), Transition => write!(f, "transition"), Block => write!(f, "block"), Leo => write!(f, "leo"), diff --git a/compiler/span/src/symbol.rs b/compiler/span/src/symbol.rs index d60e4ba391..cec9833d4b 100644 --- a/compiler/span/src/symbol.rs +++ b/compiler/span/src/symbol.rs @@ -202,6 +202,7 @@ symbols! { to_x_coordinate, to_y_coordinate, verify, + Await: "await", // types address, @@ -213,6 +214,7 @@ symbols! { i32, i64, i128, + Future: "future", record, scalar, signature,