diff --git a/compiler/parser/src/tokenizer/lexer.rs b/compiler/parser/src/tokenizer/lexer.rs index b1927adace..edb0cf3402 100644 --- a/compiler/parser/src/tokenizer/lexer.rs +++ b/compiler/parser/src/tokenizer/lexer.rs @@ -393,7 +393,7 @@ impl Token { "else" => Token::Else, "false" => Token::False, "field" => Token::Field, - "future" => Token::Future, + "Future" => Token::Future, "for" => Token::For, "function" => Token::Function, "group" => Token::Group, diff --git a/compiler/parser/src/tokenizer/mod.rs b/compiler/parser/src/tokenizer/mod.rs index d5c3428c2d..e083f77f41 100644 --- a/compiler/parser/src/tokenizer/mod.rs +++ b/compiler/parser/src/tokenizer/mod.rs @@ -95,7 +95,7 @@ mod tests { field for function - future + Future group i128 i64 @@ -169,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 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 + 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/tests/expectations/parser/program/async_basic.out b/tests/expectations/parser/program/async_basic.out new file mode 100644 index 0000000000..0671926aa4 --- /dev/null +++ b/tests/expectations/parser/program/async_basic.out @@ -0,0 +1,164 @@ +--- +namespace: Parse +expectation: Pass +outputs: + - imports: {} + stubs: {} + program_scopes: + test: + program_id: "{\"name\":\"test\",\"network\":\"\\\"{\\\\\\\"id\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"aleo\\\\\\\",\\\\\\\"span\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"lo\\\\\\\\\\\\\\\":0,\\\\\\\\\\\\\\\"hi\\\\\\\\\\\\\\\":0}\\\\\\\"}\\\"\"}" + consts: [] + structs: [] + mappings: + - - Yo + - identifier: "{\"id\":\"2\",\"name\":\"Yo\",\"span\":\"{\\\"lo\\\":34,\\\"hi\\\":36}\"}" + key_type: + Integer: U32 + value_type: + Integer: U32 + span: + lo: 26 + hi: 49 + id: 3 + functions: + - - main + - annotations: [] + is_async: true + variant: Transition + identifier: "{\"id\":\"4\",\"name\":\"main\",\"span\":\"{\\\"lo\\\":72,\\\"hi\\\":76}\"}" + input: [] + output: + - Internal: + mode: None + type_: + Future: + inputs: [] + span: + lo: 82 + hi: 88 + id: 5 + output_type: + Future: + inputs: [] + block: + statements: + - Definition: + declaration_type: Let + place: + Identifier: "{\"id\":\"6\",\"name\":\"f\",\"span\":\"{\\\"lo\\\":103,\\\"hi\\\":104}\"}" + type_: + Future: + inputs: [] + value: + Call: + function: + Identifier: "{\"id\":\"7\",\"name\":\"finalize_main\",\"span\":\"{\\\"lo\\\":115,\\\"hi\\\":128}\"}" + arguments: + - Literal: + Integer: + - U32 + - "1" + - span: + lo: 129 + hi: 133 + - 8 + - Literal: + Integer: + - U32 + - "1" + - span: + lo: 135 + hi: 139 + - 9 + program: test + span: + lo: 115 + hi: 140 + id: 10 + span: + lo: 99 + hi: 140 + id: 11 + - Return: + expression: + Identifier: "{\"id\":\"12\",\"name\":\"f\",\"span\":\"{\\\"lo\\\":157,\\\"hi\\\":158}\"}" + span: + lo: 150 + hi: 159 + id: 13 + span: + lo: 89 + hi: 165 + id: 14 + span: + lo: 55 + hi: 165 + id: 15 + - - finalize_main + - annotations: [] + is_async: true + variant: Standard + identifier: "{\"id\":\"16\",\"name\":\"finalize_main\",\"span\":\"{\\\"lo\\\":186,\\\"hi\\\":199}\"}" + input: + - Internal: + identifier: "{\"id\":\"17\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":200,\\\"hi\\\":201}\"}" + mode: None + type_: + Integer: U32 + span: + lo: 200 + hi: 201 + id: 18 + - Internal: + identifier: "{\"id\":\"19\",\"name\":\"b\",\"span\":\"{\\\"lo\\\":207,\\\"hi\\\":208}\"}" + mode: None + type_: + Integer: U32 + span: + lo: 207 + hi: 208 + id: 20 + output: + - Internal: + mode: None + type_: + Future: + inputs: [] + span: + lo: 217 + hi: 223 + id: 21 + output_type: + Future: + inputs: [] + block: + statements: + - Expression: + expression: + Access: + AssociatedFunction: + variant: "{\"id\":\"22\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":234,\\\"hi\\\":241}\"}" + name: "{\"id\":\"23\",\"name\":\"set\",\"span\":\"{\\\"lo\\\":243,\\\"hi\\\":246}\"}" + arguments: + - Identifier: "{\"id\":\"24\",\"name\":\"Yo\",\"span\":\"{\\\"lo\\\":247,\\\"hi\\\":249}\"}" + - Identifier: "{\"id\":\"25\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":251,\\\"hi\\\":252}\"}" + - Identifier: "{\"id\":\"26\",\"name\":\"b\",\"span\":\"{\\\"lo\\\":254,\\\"hi\\\":255}\"}" + span: + lo: 234 + hi: 256 + id: 27 + span: + lo: 234 + hi: 257 + id: 28 + span: + lo: 224 + hi: 263 + id: 29 + span: + lo: 171 + hi: 263 + id: 30 + span: + lo: 2 + hi: 265 diff --git a/tests/tests/parser/program/async_basic.leo b/tests/tests/parser/program/async_basic.leo new file mode 100644 index 0000000000..bf9d665060 --- /dev/null +++ b/tests/tests/parser/program/async_basic.leo @@ -0,0 +1,17 @@ +/* +namespace: Parse +expectation: Pass +*/ + +program test.aleo { + mapping Yo: u32 => u32; + + async transition main() -> Future { + let f: Future = finalize_main(1u32, 1u32); + return f; + } + + async function finalize_main(a:u32, b:u32) -> Future { + Mapping::set(Yo, a, b); + } +} \ No newline at end of file