From 61253031b49d5490f4c3f238198afa44e0870fdb Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Thu, 22 Jul 2021 22:17:33 -0700 Subject: [PATCH 1/7] countdown loops --- compiler/src/statement/iteration/iteration.rs | 8 ++++++- tests/compiler/statements/reverse_loop.leo | 19 +++++++++++++++++ .../compiler/statements/reverse_loop.leo.out | 21 +++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/compiler/statements/reverse_loop.leo create mode 100644 tests/expectations/compiler/compiler/statements/reverse_loop.leo.out diff --git a/compiler/src/statement/iteration/iteration.rs b/compiler/src/statement/iteration/iteration.rs index fb3750c451..d9bb4184d0 100644 --- a/compiler/src/statement/iteration/iteration.rs +++ b/compiler/src/statement/iteration/iteration.rs @@ -53,7 +53,13 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { .to_usize() .ok_or_else(|| StatementError::loop_index_const(&span))?; - for i in from..to { + let iter: Box> = if from < to { + Box::new(from..to) + } else { + Box::new((to..from).rev()) + }; + + for i in iter { // Store index in current function scope. // For loop scope is not implemented. let variable = statement.variable.borrow(); diff --git a/tests/compiler/statements/reverse_loop.leo b/tests/compiler/statements/reverse_loop.leo new file mode 100644 index 0000000000..52b24c0bf4 --- /dev/null +++ b/tests/compiler/statements/reverse_loop.leo @@ -0,0 +1,19 @@ +/* +namespace: Compile +expectation: Pass +input_file: inputs/dummy.in +*/ + +function main(k: bool) -> bool { + let reverse: u32 = 0; + for i in 10..0 { + reverse += i; + } + + let forward: u32 = 0; + for x in 0..10 { + forward += x; + } + + return reverse == forward && k; +} \ No newline at end of file diff --git a/tests/expectations/compiler/compiler/statements/reverse_loop.leo.out b/tests/expectations/compiler/compiler/statements/reverse_loop.leo.out new file mode 100644 index 0000000000..42b439b56d --- /dev/null +++ b/tests/expectations/compiler/compiler/statements/reverse_loop.leo.out @@ -0,0 +1,21 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 1 + num_constraints: 1 + at: 042610d0fd1fe6d6ac112138f8755752f44c7d2a00f1b5960574d6da5cda393f + bt: e97756698880ab7555a959a5fb5c6b4e15bd64612aa677adbfe2d0bd91f0a83c + ct: cf1cbb66a638b4860a516671fb74850e6ccf787fe6c4c8d29e9c04efe880bd05 + output: + - input_file: inputs/dummy.in + output: + registers: + r0: + type: bool + value: "true" + initial_ast: 2de2209f674d98d4c079ab820b1e154ab47cf45a0413a8b0643b322afb836518 + canonicalized_ast: 780fd70bae5c39651481e3966332f3759fd4b80a03cabc812682aa0e5aebb0b7 + type_inferenced_ast: 4256bce9f7fa10cd6265340993d77abc18eff6f71cb6eb13a0e064c310b75658 From 68fd0433b69629e0063dd9a802dd9af99d1f2877 Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Thu, 22 Jul 2021 23:04:13 -0700 Subject: [PATCH 2/7] trying to debug why circleci and codecov fail --- compiler/src/test.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/src/test.rs b/compiler/src/test.rs index bcb16331c6..5d7d7eb2a6 100644 --- a/compiler/src/test.rs +++ b/compiler/src/test.rs @@ -231,6 +231,8 @@ impl Namespace for CompileNamespace { .unwrap_or_else(|_| "Error converting ast to string.".to_string()), ); + std::fs::remove_dir_all(std::path::Path::new("/tmp/output")).expect("Error failed to clean up output dir."); + let final_output = CompileOutput { circuit: last_circuit.unwrap(), output: output_items, From 4b4247427b0c11bd1945b0fc1097cdfab13c6344 Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Fri, 23 Jul 2021 00:13:35 -0700 Subject: [PATCH 3/7] debug ci differences --- .circleci/config.yml | 2 +- .github/workflows/ci.yml | 2 +- compiler/src/test.rs | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3582b41796..bfddf2febb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,7 +53,7 @@ jobs: - run: name: Build and run tests no_output_timeout: 30m - command: cargo test --all + command: cargo test --all -- --nocapture - persist_to_workspace: root: ~/ paths: project/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f0d7c2e18..f4a79ca5c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: test - args: --all --features ci_skip + args: --all --features ci_skip -- --nocapture env: CARGO_INCREMENTAL: "0" diff --git a/compiler/src/test.rs b/compiler/src/test.rs index 5d7d7eb2a6..426604cd54 100644 --- a/compiler/src/test.rs +++ b/compiler/src/test.rs @@ -211,6 +211,13 @@ impl Namespace for CompileNamespace { output, }); } + if test.name.contains("reverse") { + println!( + "debug print initial ast {:?}", + Ast::from_json_file("/tmp/output/initial_ast.json".into()) + .unwrap_or_else(|_| Ast::new(Program::new("Error reading initial theorem.".to_string()))) + ); + } let initial_ast: String = hash( Ast::from_json_file("/tmp/output/initial_ast.json".into()) From 6d08e8920f9423084c979778a26dce1036fd6e15 Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Fri, 23 Jul 2021 00:26:10 -0700 Subject: [PATCH 4/7] debug json --- compiler/src/test.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/src/test.rs b/compiler/src/test.rs index 426604cd54..6d5f81c7a0 100644 --- a/compiler/src/test.rs +++ b/compiler/src/test.rs @@ -216,6 +216,7 @@ impl Namespace for CompileNamespace { "debug print initial ast {:?}", Ast::from_json_file("/tmp/output/initial_ast.json".into()) .unwrap_or_else(|_| Ast::new(Program::new("Error reading initial theorem.".to_string()))) + .to_json_string() ); } From b69dd4e27799172a25ca0242d6c62764b29999f7 Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Fri, 23 Jul 2021 00:34:52 -0700 Subject: [PATCH 5/7] remove debug, realized it was crlf vs lf whoops --- .circleci/config.yml | 2 +- .github/workflows/ci.yml | 2 +- compiler/src/test.rs | 8 -------- .../compiler/compiler/statements/reverse_loop.leo.out | 6 +++--- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bfddf2febb..3582b41796 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,7 +53,7 @@ jobs: - run: name: Build and run tests no_output_timeout: 30m - command: cargo test --all -- --nocapture + command: cargo test --all - persist_to_workspace: root: ~/ paths: project/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4a79ca5c7..8f0d7c2e18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: test - args: --all --features ci_skip -- --nocapture + args: --all --features ci_skip env: CARGO_INCREMENTAL: "0" diff --git a/compiler/src/test.rs b/compiler/src/test.rs index 6d5f81c7a0..5d7d7eb2a6 100644 --- a/compiler/src/test.rs +++ b/compiler/src/test.rs @@ -211,14 +211,6 @@ impl Namespace for CompileNamespace { output, }); } - if test.name.contains("reverse") { - println!( - "debug print initial ast {:?}", - Ast::from_json_file("/tmp/output/initial_ast.json".into()) - .unwrap_or_else(|_| Ast::new(Program::new("Error reading initial theorem.".to_string()))) - .to_json_string() - ); - } let initial_ast: String = hash( Ast::from_json_file("/tmp/output/initial_ast.json".into()) diff --git a/tests/expectations/compiler/compiler/statements/reverse_loop.leo.out b/tests/expectations/compiler/compiler/statements/reverse_loop.leo.out index 42b439b56d..bb4416faf3 100644 --- a/tests/expectations/compiler/compiler/statements/reverse_loop.leo.out +++ b/tests/expectations/compiler/compiler/statements/reverse_loop.leo.out @@ -16,6 +16,6 @@ outputs: r0: type: bool value: "true" - initial_ast: 2de2209f674d98d4c079ab820b1e154ab47cf45a0413a8b0643b322afb836518 - canonicalized_ast: 780fd70bae5c39651481e3966332f3759fd4b80a03cabc812682aa0e5aebb0b7 - type_inferenced_ast: 4256bce9f7fa10cd6265340993d77abc18eff6f71cb6eb13a0e064c310b75658 + initial_ast: 75fbb3ed1613fbf39ce803ff903befe209b26a953ba8db1d68e35066655d96e6 + canonicalized_ast: a96cae2c9e347245e07c63b5c94cf43497063c3f548c615627da4b1775e9a17b + type_inferenced_ast: dc663974ed1cce7b15c35eda29c9b1af5426eafddbd108b5a03cd7071ad4a6bc From 1d72107119d736831fe8981cd9c479ec7c896295 Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Fri, 23 Jul 2021 15:14:37 -0700 Subject: [PATCH 6/7] inclusive range --- asg/src/reducer/reconstructing_reducer.rs | 1 + asg/src/statement/iteration.rs | 3 ++ ast/src/reducer/canonicalization.rs | 1 + ast/src/reducer/reconstructing_reducer.rs | 1 + ast/src/statements/iteration.rs | 6 ++-- compiler/src/statement/iteration/iteration.rs | 9 +++--- parser/src/parser/statement.rs | 2 ++ tests/compiler/statements/all_loops.leo | 29 +++++++++++++++++++ tests/compiler/statements/reverse_loop.leo | 19 ------------ .../compiler/circuits/pedersen_mock.leo.out | 6 ++-- .../compiler/function/iteration.leo.out | 6 ++-- .../function/iteration_repeated.leo.out | 6 ++-- .../compiler/statements/all_loops.leo.out | 21 ++++++++++++++ .../compiler/statements/for_loop.leo.out | 6 ++-- .../statements/iteration_basic.leo.out | 6 ++-- .../statements/iteration_variable.leo.out | 6 ++-- .../parser/parser/statement/iteration.leo.out | 4 +++ 17 files changed, 89 insertions(+), 43 deletions(-) create mode 100644 tests/compiler/statements/all_loops.leo delete mode 100644 tests/compiler/statements/reverse_loop.leo create mode 100644 tests/expectations/compiler/compiler/statements/all_loops.leo.out diff --git a/asg/src/reducer/reconstructing_reducer.rs b/asg/src/reducer/reconstructing_reducer.rs index cf4e617ec4..755c2eed1c 100644 --- a/asg/src/reducer/reconstructing_reducer.rs +++ b/asg/src/reducer/reconstructing_reducer.rs @@ -341,6 +341,7 @@ pub trait ReconstructingReducerStatement<'a>: ReconstructingReducerExpression<'a variable: input.variable, start: Cell::new(start), stop: Cell::new(stop), + inclusive: input.inclusive, body: Cell::new(body), }) } diff --git a/asg/src/statement/iteration.rs b/asg/src/statement/iteration.rs index 5e080acc75..04d327606e 100644 --- a/asg/src/statement/iteration.rs +++ b/asg/src/statement/iteration.rs @@ -39,6 +39,7 @@ pub struct IterationStatement<'a> { pub variable: &'a Variable<'a>, pub start: Cell<&'a Expression<'a>>, pub stop: Cell<&'a Expression<'a>>, + pub inclusive: bool, pub body: Cell<&'a Statement<'a>>, } @@ -93,6 +94,7 @@ impl<'a> FromAst<'a, leo_ast::IterationStatement> for &'a Statement<'a> { variable, stop: Cell::new(stop), start: Cell::new(start), + inclusive: statement.inclusive, body: Cell::new( scope .context @@ -114,6 +116,7 @@ impl<'a> Into for &IterationStatement<'a> { variable: self.variable.borrow().name.clone(), start: self.start.get().into(), stop: self.stop.get().into(), + inclusive: self.inclusive, block: match self.body.get() { Statement::Block(block) => block.into(), _ => unimplemented!(), diff --git a/ast/src/reducer/canonicalization.rs b/ast/src/reducer/canonicalization.rs index 9ca30d2aa2..4c78012c30 100644 --- a/ast/src/reducer/canonicalization.rs +++ b/ast/src/reducer/canonicalization.rs @@ -382,6 +382,7 @@ impl Canonicalizer { variable: iteration.variable.clone(), start, stop, + inclusive: iteration.inclusive, block, span: iteration.span.clone(), }) diff --git a/ast/src/reducer/reconstructing_reducer.rs b/ast/src/reducer/reconstructing_reducer.rs index 28277b470d..9bac0a88c7 100644 --- a/ast/src/reducer/reconstructing_reducer.rs +++ b/ast/src/reducer/reconstructing_reducer.rs @@ -359,6 +359,7 @@ pub trait ReconstructingReducer { variable, start, stop, + inclusive: iteration.inclusive, block, span: iteration.span.clone(), }) diff --git a/ast/src/statements/iteration.rs b/ast/src/statements/iteration.rs index a935f959f3..a97941ac55 100644 --- a/ast/src/statements/iteration.rs +++ b/ast/src/statements/iteration.rs @@ -24,16 +24,18 @@ pub struct IterationStatement { pub variable: Identifier, pub start: Expression, pub stop: Expression, + pub inclusive: bool, pub block: Block, pub span: Span, } impl fmt::Display for IterationStatement { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let eq = if self.inclusive { "=" } else { "" }; write!( f, - "for {} in {}..{} {}", - self.variable, self.start, self.stop, self.block + "for {} in {}..{}{} {}", + self.variable, self.start, eq, self.stop, self.block ) } } diff --git a/compiler/src/statement/iteration/iteration.rs b/compiler/src/statement/iteration/iteration.rs index d9bb4184d0..af4ffde859 100644 --- a/compiler/src/statement/iteration/iteration.rs +++ b/compiler/src/statement/iteration/iteration.rs @@ -53,10 +53,11 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { .to_usize() .ok_or_else(|| StatementError::loop_index_const(&span))?; - let iter: Box> = if from < to { - Box::new(from..to) - } else { - Box::new((to..from).rev()) + let iter: Box> = match (from < to, statement.inclusive) { + (true, true) => Box::new(from..=to), + (true, false) => Box::new(from..to), + (false, true) => Box::new((to..=from).rev()), + (false, false) => Box::new((to..from).rev()), }; for i in iter { diff --git a/parser/src/parser/statement.rs b/parser/src/parser/statement.rs index f4ec7ea566..d60d3e12bb 100644 --- a/parser/src/parser/statement.rs +++ b/parser/src/parser/statement.rs @@ -217,6 +217,7 @@ impl ParserContext { self.expect(Token::In)?; let start = self.parse_expression()?; self.expect(Token::DotDot)?; + let inclusive = self.eat(Token::Assign).is_some(); self.fuzzy_struct_state = true; let stop = self.parse_conditional_expression()?; self.fuzzy_struct_state = false; @@ -227,6 +228,7 @@ impl ParserContext { variable: ident, start, stop, + inclusive, block, }) } diff --git a/tests/compiler/statements/all_loops.leo b/tests/compiler/statements/all_loops.leo new file mode 100644 index 0000000000..994d0f8264 --- /dev/null +++ b/tests/compiler/statements/all_loops.leo @@ -0,0 +1,29 @@ +/* +namespace: Compile +expectation: Pass +input_file: inputs/dummy.in +*/ + +function main(k: bool) -> bool { + let reverse: u32 = 0; + for i in 10..0 { + reverse += i; + } + + let forward: u32 = 0; + for x in 0..10 { + forward += x; + } + + let reverse_inclusive: u32 = 0; + for a in 10..=0 { + reverse_inclusive += a; + } + + let forward_inclusive: u32 = 0; + for b in 0..=10 { + forward_inclusive += b; + } + + return (reverse == forward) && (reverse_inclusive == forward_inclusive) && k; +} \ No newline at end of file diff --git a/tests/compiler/statements/reverse_loop.leo b/tests/compiler/statements/reverse_loop.leo deleted file mode 100644 index 52b24c0bf4..0000000000 --- a/tests/compiler/statements/reverse_loop.leo +++ /dev/null @@ -1,19 +0,0 @@ -/* -namespace: Compile -expectation: Pass -input_file: inputs/dummy.in -*/ - -function main(k: bool) -> bool { - let reverse: u32 = 0; - for i in 10..0 { - reverse += i; - } - - let forward: u32 = 0; - for x in 0..10 { - forward += x; - } - - return reverse == forward && k; -} \ No newline at end of file diff --git a/tests/expectations/compiler/compiler/circuits/pedersen_mock.leo.out b/tests/expectations/compiler/compiler/circuits/pedersen_mock.leo.out index 5e87294e05..bec7e9cfc6 100644 --- a/tests/expectations/compiler/compiler/circuits/pedersen_mock.leo.out +++ b/tests/expectations/compiler/compiler/circuits/pedersen_mock.leo.out @@ -16,6 +16,6 @@ outputs: r0: type: bool value: "true" - initial_ast: e04195ede456babe4121950806163d2cc8c1e4b0180a37969099749ae3dfc3b9 - canonicalized_ast: a8673bb8b05eb0289435b8b2335402f022df9ff46db523707cc61eca1b9679ad - type_inferenced_ast: afeabed72941728dc8a8cc0ed27d1e8170f7dd477275be29e794b6c28142f2a7 + initial_ast: c983e5e79b4325ac133ac1a5ff0b1655c646111389991286322b8c16c5833837 + canonicalized_ast: 8dcb714238ef7e9fd3c66a7a12ec4621bb4e9ac5994f1c692215a9f93463ce9e + type_inferenced_ast: ebd34799bd1c6936ca5032812d2466bade58df616cc06e3c6e57151a06b78601 diff --git a/tests/expectations/compiler/compiler/function/iteration.leo.out b/tests/expectations/compiler/compiler/function/iteration.leo.out index 78b352d66f..16dc886ac5 100644 --- a/tests/expectations/compiler/compiler/function/iteration.leo.out +++ b/tests/expectations/compiler/compiler/function/iteration.leo.out @@ -16,6 +16,6 @@ outputs: r0: type: bool value: "true" - initial_ast: 7dcfb3d46fc2a3f91d57f21db97e0d3829d0ac438a09fe0beaaa83aa0c545947 - canonicalized_ast: 33ffbf095e9050dd55b3e5cae0518f47b61689a7cefb5dd2d454ff6c4bb2fc9c - type_inferenced_ast: a6cff2181d7642f4a729d2301708c97956fc60322c8680a7d2d71296f4e7a5c6 + initial_ast: 96155896f4993bd97a8e15281e92c4e9352ed02343bccddb9c3cd0f8ca55b408 + canonicalized_ast: ae4a2dfa82f00621192f117bea664e58768d57376b68a90ce0e15c5bc9535e22 + type_inferenced_ast: 2452ad985e23efbc07a94f2945d406a959aca68ec37e9c349a30edcc12839c04 diff --git a/tests/expectations/compiler/compiler/function/iteration_repeated.leo.out b/tests/expectations/compiler/compiler/function/iteration_repeated.leo.out index 5a58598d01..8056fc7df4 100644 --- a/tests/expectations/compiler/compiler/function/iteration_repeated.leo.out +++ b/tests/expectations/compiler/compiler/function/iteration_repeated.leo.out @@ -16,6 +16,6 @@ outputs: r0: type: bool value: "true" - initial_ast: cb4033ff1a05ae4b09fd9bbbeddd11b0fddececb98f96c7aef2ebb3069748870 - canonicalized_ast: 6607510f1df2682091711014cb0b1db8b786707accbab9c1760d710bed32ca17 - type_inferenced_ast: 4b5f83f6029a04c1fbce48e596ac2d7d0d97b87489b05656ff8773b04d2597fd + initial_ast: 55bf6a745bd0da1684239dd5f624a5ead1d5644c15f25e3099ff40c71ce23317 + canonicalized_ast: 929e1e876d7dd5d04ae39dd8d4b0b3fa3f0e8783e39056941115fff337a0ef84 + type_inferenced_ast: bc6903d0764db54fd4938835120ab6fa02575b1b896828876153bb30da28a19a diff --git a/tests/expectations/compiler/compiler/statements/all_loops.leo.out b/tests/expectations/compiler/compiler/statements/all_loops.leo.out new file mode 100644 index 0000000000..ead54a1743 --- /dev/null +++ b/tests/expectations/compiler/compiler/statements/all_loops.leo.out @@ -0,0 +1,21 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 1 + num_constraints: 1 + at: 042610d0fd1fe6d6ac112138f8755752f44c7d2a00f1b5960574d6da5cda393f + bt: e97756698880ab7555a959a5fb5c6b4e15bd64612aa677adbfe2d0bd91f0a83c + ct: cf1cbb66a638b4860a516671fb74850e6ccf787fe6c4c8d29e9c04efe880bd05 + output: + - input_file: inputs/dummy.in + output: + registers: + r0: + type: bool + value: "true" + initial_ast: 7ecd56e44c6b1cb4f702a2712a2a7fe3bf564dac26a70e1f14151a688fb24769 + canonicalized_ast: 360ecac21f95b0e1d949d49458f2c4557446d01db08333d6f25621ef47a78a66 + type_inferenced_ast: 853fdefe080011aaa35363e827a527ab7ce6c7e93cd568c8a150211fa6e402fe diff --git a/tests/expectations/compiler/compiler/statements/for_loop.leo.out b/tests/expectations/compiler/compiler/statements/for_loop.leo.out index 4cedf331b1..3f9284533d 100644 --- a/tests/expectations/compiler/compiler/statements/for_loop.leo.out +++ b/tests/expectations/compiler/compiler/statements/for_loop.leo.out @@ -16,6 +16,6 @@ outputs: a: type: bool value: "true" - initial_ast: 8374ac96fbf6d918998ebe6ccb88842f2141efbc721314ff1b98a6e57c30ac8c - canonicalized_ast: 031149b98d685b26166d621c2206142438479414eeae8db5f92927aabca5d684 - type_inferenced_ast: 94959ec2fc0be13f8943a54261f6c23c6585773bc14936ee68a3f7289cc8bd26 + initial_ast: cce56dc8d678cd645e8fb3043aeb95bd24f94640e08219f00b7b9db66498ec29 + canonicalized_ast: 914f4ba5fc0c5148f1e105af4f857b8b12d29a609d47a366c73fd3d2f8eda3bf + type_inferenced_ast: 02b16a3b3a7e7c7ca4803292ea1f5410f293f2000f21c0a5245f2e5273561f06 diff --git a/tests/expectations/compiler/compiler/statements/iteration_basic.leo.out b/tests/expectations/compiler/compiler/statements/iteration_basic.leo.out index 18852b93e4..34b078aed4 100644 --- a/tests/expectations/compiler/compiler/statements/iteration_basic.leo.out +++ b/tests/expectations/compiler/compiler/statements/iteration_basic.leo.out @@ -16,6 +16,6 @@ outputs: a: type: bool value: "true" - initial_ast: 2af258377cc5af8e1bed75bed8dd57d2ecb969f71b8081a321a946df782ead97 - canonicalized_ast: 8733ab382dd7d3d506f999dd6b34442200e447cb530cc6d8115da6267b176f2e - type_inferenced_ast: 6f4c12b70f5fb244fbca65cb32e68c88ced6bf289afb7b1639257bb8de9a4bbb + initial_ast: 1c9abdc059f6649b381be12d435129702a048f941b5766212105d9f20c6479cf + canonicalized_ast: 5a8d9b146b28300345c3f0878f712ccc7a545534dc820d22180ec7bff8b96713 + type_inferenced_ast: 259654bcec24b6110db951fef9ee504455219c9e1860cc96b30d18ecf8fc2ead diff --git a/tests/expectations/compiler/compiler/statements/iteration_variable.leo.out b/tests/expectations/compiler/compiler/statements/iteration_variable.leo.out index 0bd6e7c478..74a9d729cf 100644 --- a/tests/expectations/compiler/compiler/statements/iteration_variable.leo.out +++ b/tests/expectations/compiler/compiler/statements/iteration_variable.leo.out @@ -16,6 +16,6 @@ outputs: a: type: bool value: "true" - initial_ast: 5223011087228b526071851038df390424ca442c4b21e0001cdf14bf8c63cf2c - canonicalized_ast: ab0a3a3caa5250c522c9eaa4b4bee5e36c179f856b02c2cdf94b4798344daf3d - type_inferenced_ast: 5825d1694362e1dab8710cbfa4feb608f968a98052a01fa36c152e06c1bd2cc4 + initial_ast: 3ac3ba48fb628fff67489c5d1502c3e0aaf9e197bf54d8c544fc79d9c83e3e16 + canonicalized_ast: c081654e7bd5edbfc1653444e73bc2f5e5b4e887f3e99dbb54f26cbfa37d84e1 + type_inferenced_ast: 23cddd23376a87be6e293bb4eae4470c9e450984bace87dc7386a5bf37081af0 diff --git a/tests/expectations/parser/parser/statement/iteration.leo.out b/tests/expectations/parser/parser/statement/iteration.leo.out index 4fa2b3b899..045effafff 100644 --- a/tests/expectations/parser/parser/statement/iteration.leo.out +++ b/tests/expectations/parser/parser/statement/iteration.leo.out @@ -24,6 +24,7 @@ outputs: col_stop: 14 path: test content: "for x in 0..7 {}" + inclusive: false block: statements: [] span: @@ -62,6 +63,7 @@ outputs: col_stop: 14 path: test content: "for x in 0..7 {" + inclusive: false block: statements: - Return: @@ -119,6 +121,7 @@ outputs: col_stop: 17 path: test content: "for x in 0..99u8 {" + inclusive: false block: statements: - Return: @@ -167,6 +170,7 @@ outputs: content: "for x in 0..Self {" stop: Identifier: "{\"name\":\"Self\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":13,\\\"col_stop\\\":17,\\\"path\\\":\\\"test\\\",\\\"content\\\":\\\"for x in 0..Self {\\\"}\"}" + inclusive: false block: statements: - Return: From 8ae89149a9cc7cf4e6ff16aeb0c17cfd32dfdf81 Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Fri, 23 Jul 2021 17:36:27 -0700 Subject: [PATCH 7/7] ABNF grammar update --- grammar/README.md | Bin 111950 -> 111732 bytes grammar/abnf-grammar.txt | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/grammar/README.md b/grammar/README.md index 6491e949ff2279c879705eef6f63c35cd056f658..eef68c73a3dabc6eb17013e957b0affd605a8803 100644 GIT binary patch delta 1328 zcmZuwe@L5G6!paPYnEm%1S?KNV^*X%XI0p6F0)RgbeRpQDwWln4m z`vV)h%v-!7(w5R`5G}&j`jyhrt{XFMBZSeqt?NWONsF+p_+#vkZR{qYEsXy0;NAD` zIrpCP?u#uctM`hAw>`>^o*FsBydWwCaP_(^E zRtd#E4A7Ado9g=L`g7z>WK(>sfJVl4v9}Nk)larl{-}-S$IRrpY9nuYuMR~{m}p_T zgsx3DN>VPxC$nU4rPhmObVu`3cv>Ng7N_Bhf2yuay?SnW1vyl9HDA5|`C_IzH$Dgo zuNl+>Uz+r!t1qG8O)C!rr4*lSq3LKdb4ns0j9cNl)P;D@@WX!+M%>PlGY!reUj_ZNj)#T_k5=2W$f? zS?R!A0Rt}^Q9}ze3XLy0cp(gh^NQeLuU&RFBYeDIhefN~fTd^n#ui-Qzsk{;VjNg9 z(EM`kJs1xh))3ckVZ$Yb-1QshLfbm2b;vsV2) z&M55ND2LG(q-{YIbF2!R)7{+Lib3tZ9lbif^%6qdz7_t5G@8)(p5XZF0$yl9CtF@k zGuXJwfnv$qr0HJ6kKo1zX(82&dnd}$)Xfg`X^T4$(XnZ#fK%#2F4>9tY;AZaS`;cj zpy!<3$mc8%tQ2h5b6b<>@_OLqRW|}GfLxy12TL-ek*|5snlw{fccVEO8rb9(^IG3P zKs(ul^M=%5JThFYl;pQjz*T)>mUl}Mn+$zLBF5!}UJJZ~1|(q(k4>}`p`Dz4X_!|0 z9=i2OLtQN8-0XBdXt3a8Y}QWgL#6)7rVML_E#qZb){H&$){dt+u^-)!UR99Wxa>5P z>4TWg;=CR>*Of|c6Q4eWLY^p>P8~fk@x&om==#xIt-A*&b;&QXmpbQM9C}|Yym1&c zdOp_*J0Izj&+u^C?ET``wd0~xG;i1Hk7EcN8ngJP)5F=OX`xM3NxO9t%O@zho+7TK0%gGzLo{~Q}EM+6VTY2#ms_ER4 zPb)u-YK4Olc^6j%XN8&0_nWzG6b7wk6yspeXBdB=!K^JuP?AYsFPr(y2y(d8o&HOy ZAT%K?GWHf;7?OE7F@bI^IEmQ${{Y5e2CM)8 delta 1437 zcmah|ZAe>Z6uw8ZYs_rCq!;U4bhnw4B2I%08=Pd~I<|^*nS+{TMQ&|$(zz_NQKpEq zLuhr*22aTuLxXd+I;$dN<_aB>^+y|Jh(D&taHTEo%SES7q=?Agn^d=d3JxS@H!9}Zp zske>EmpF-Ya@CxR`;hZ+)wuca*bC>mdiI^?nz&0`4tIppG1(F!0i9gIZ zFtotq(!FyiFx(rK@%r6H+W!Ou`sp|%1xjWuI;>fcX=#wDyo2xt-d(7qsUfhT%p#kA zv<5O4%ad{7rr5Kh#r?k}w9cp^MXrGsbAJue`ZeIOc1FPakF?nROCh=*3OM?gJ`nd? zFOSQcNm#ii(wBW8p|BML89pdQc}k?#W1v&bf#&t9c-l(`0Vg)K)S3syn6qVL0U~Z} z76j(D(g2IL9kF6YB$#Lu*{HxOxKtM?xPgVKK)zKDyip1lbd zdOy=ByX|1rP;)nP)_1}=l6+u^Qf3Vm9A2JLh} zDjB;$M;TpELSZxWo9}{1te83nr{eZP%~R-Kvta0tN~O*RJACXGR`o#-TGj>Z|C3i7 zekkBcy1_2S#vl}uJOp<1jhS%#b0Ml$oHt-3Iy~Fq6CWXV5A;gbFc{-wz4TvU%VOIO XlUK_|5E_X=iTaN}fr@_=78Cvf(0wao diff --git a/grammar/abnf-grammar.txt b/grammar/abnf-grammar.txt index 650a035744..233f0b4910 100644 --- a/grammar/abnf-grammar.txt +++ b/grammar/abnf-grammar.txt @@ -936,7 +936,7 @@ conditional-statement = branch ; that goes from a starting value (inclusive) to an ending value (exclusive). ; The body is a block. -loop-statement = %s"for" identifier %s"in" expression ".." expression block +loop-statement = %s"for" identifier %s"in" expression ".." [ "=" ] expression block ; An assignment statement is straightforward. ; Based on the operator, the assignment may be simple (i.e. `=`)