From 28d6aeb47d0844ae415e9351dbe3dc7795e56a46 Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu Date: Wed, 22 Sep 2021 10:41:47 -0700 Subject: [PATCH] Reorganized parser/tests and included new test for generating ASTs without spans --- .../expected_leo_ast/linear_regression.json | 2368 +++++++++++++++++ .../one_plus_one.json} | 0 .../expected_leo_ast/palindrome.json | 1232 +++++++++ .../expected_leo_ast/pedersen_hash.json | 308 +++ .../expected_leo_ast/silly_sudoku.json | 1323 +++++++++ parser/tests/serialization/json.rs | 55 +- .../{ => leo}/deprecated_error.leo | 0 .../serialization/leo/linear_regression.leo | 65 + .../{main.leo => leo/one_plus_one.leo} | 0 parser/tests/serialization/leo/palindrome.leo | 59 + .../serialization/{ => leo}/parser_error.leo | 0 .../tests/serialization/leo/pedersen_hash.leo | 25 + .../tests/serialization/leo/silly_sudoku.leo | 71 + 13 files changed, 5503 insertions(+), 3 deletions(-) create mode 100644 parser/tests/serialization/expected_leo_ast/linear_regression.json rename parser/tests/serialization/{expected_leo_ast.json => expected_leo_ast/one_plus_one.json} (100%) create mode 100644 parser/tests/serialization/expected_leo_ast/palindrome.json create mode 100644 parser/tests/serialization/expected_leo_ast/pedersen_hash.json create mode 100644 parser/tests/serialization/expected_leo_ast/silly_sudoku.json rename parser/tests/serialization/{ => leo}/deprecated_error.leo (100%) create mode 100644 parser/tests/serialization/leo/linear_regression.leo rename parser/tests/serialization/{main.leo => leo/one_plus_one.leo} (100%) create mode 100644 parser/tests/serialization/leo/palindrome.leo rename parser/tests/serialization/{ => leo}/parser_error.leo (100%) create mode 100644 parser/tests/serialization/leo/pedersen_hash.leo create mode 100644 parser/tests/serialization/leo/silly_sudoku.leo diff --git a/parser/tests/serialization/expected_leo_ast/linear_regression.json b/parser/tests/serialization/expected_leo_ast/linear_regression.json new file mode 100644 index 0000000000..734c084833 --- /dev/null +++ b/parser/tests/serialization/expected_leo_ast/linear_regression.json @@ -0,0 +1,2368 @@ +{ + "name": "", + "expected_input": [], + "imports": [], + "circuits": { + "{\"name\":\"Point\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\"circuit Point {\\\"}\"}": { + "circuit_name": "{\"name\":\"Point\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\"circuit Point {\\\"}\"}", + "members": [ + { + "CircuitVariable": [ + "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":2,\\\"line_stop\\\":2,\\\"col_start\\\":5,\\\"col_stop\\\":6,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x: i32,\\\"}\"}", + { + "IntegerType": "I32" + } + ] + }, + { + "CircuitVariable": [ + "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":5,\\\"col_stop\\\":6,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" y: i32,\\\"}\"}", + { + "IntegerType": "I32" + } + ] + }, + { + "CircuitFunction": { + "annotations": [], + "identifier": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":14,\\\"col_stop\\\":17,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" function new(x: i32, y: i32) -> Self { \\\"}\"}", + "input": [ + { + "Variable": { + "identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":18,\\\"col_stop\\\":19,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" function new(x: i32, y: i32) -> Self { \\\"}\"}", + "const_": false, + "mutable": true, + "type_": { + "IntegerType": "I32" + }, + "span": { + "line_start": 5, + "line_stop": 5, + "col_start": 18, + "col_stop": 19, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function new(x: i32, y: i32) -> Self { " + } + } + }, + { + "Variable": { + "identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":26,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" function new(x: i32, y: i32) -> Self { \\\"}\"}", + "const_": false, + "mutable": true, + "type_": { + "IntegerType": "I32" + }, + "span": { + "line_start": 5, + "line_stop": 5, + "col_start": 26, + "col_stop": 27, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function new(x: i32, y: i32) -> Self { " + } + } + } + ], + "output": "SelfType", + "block": { + "statements": [ + { + "Return": { + "expression": { + "CircuitInit": { + "name": "{\"name\":\"Self\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":16,\\\"col_stop\\\":20,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return Self { x, y };\\\"}\"}", + "members": [ + { + "identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":23,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return Self { x, y };\\\"}\"}", + "expression": null + }, + { + "identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":26,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return Self { x, y };\\\"}\"}", + "expression": null + } + ], + "span": { + "line_start": 6, + "line_stop": 6, + "col_start": 16, + "col_stop": 29, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " return Self { x, y };" + } + } + }, + "span": { + "line_start": 6, + "line_stop": 6, + "col_start": 9, + "col_stop": 29, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " return Self { x, y };" + } + } + } + ], + "span": { + "line_start": 5, + "line_stop": 7, + "col_start": 42, + "col_stop": 6, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function new(x: i32, y: i32) -> Self { \n...\n }" + } + }, + "span": { + "line_start": 5, + "line_stop": 7, + "col_start": 5, + "col_stop": 6, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function new(x: i32, y: i32) -> Self { \n...\n }" + } + } + } + ] + }, + "{\"name\":\"LinearRegression\",\"span\":\"{\\\"line_start\\\":10,\\\"line_stop\\\":10,\\\"col_start\\\":9,\\\"col_stop\\\":25,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\"circuit LinearRegression {\\\"}\"}": { + "circuit_name": "{\"name\":\"LinearRegression\",\"span\":\"{\\\"line_start\\\":10,\\\"line_stop\\\":10,\\\"col_start\\\":9,\\\"col_stop\\\":25,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\"circuit LinearRegression {\\\"}\"}", + "members": [ + { + "CircuitVariable": [ + "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":11,\\\"line_stop\\\":11,\\\"col_start\\\":5,\\\"col_stop\\\":11,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" points: [Point; 5],\\\"}\"}", + { + "Array": [ + { + "Circuit": "{\"name\":\"Point\",\"span\":\"{\\\"line_start\\\":11,\\\"line_stop\\\":11,\\\"col_start\\\":14,\\\"col_stop\\\":19,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" points: [Point; 5],\\\"}\"}" + }, + [ + { + "value": "5" + } + ] + ] + } + ] + }, + { + "CircuitFunction": { + "annotations": [], + "identifier": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":14,\\\"col_stop\\\":17,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" function new(points: [Point; 5]) -> Self { \\\"}\"}", + "input": [ + { + "Variable": { + "identifier": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":18,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" function new(points: [Point; 5]) -> Self { \\\"}\"}", + "const_": false, + "mutable": true, + "type_": { + "Array": [ + { + "Circuit": "{\"name\":\"Point\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":27,\\\"col_stop\\\":32,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" function new(points: [Point; 5]) -> Self { \\\"}\"}" + }, + [ + { + "value": "5" + } + ] + ] + }, + "span": { + "line_start": 14, + "line_stop": 14, + "col_start": 18, + "col_stop": 24, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function new(points: [Point; 5]) -> Self { " + } + } + } + ], + "output": "SelfType", + "block": { + "statements": [ + { + "Return": { + "expression": { + "CircuitInit": { + "name": "{\"name\":\"Self\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":16,\\\"col_stop\\\":20,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return Self { points };\\\"}\"}", + "members": [ + { + "identifier": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":23,\\\"col_stop\\\":29,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return Self { points };\\\"}\"}", + "expression": null + } + ], + "span": { + "line_start": 15, + "line_stop": 15, + "col_start": 16, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " return Self { points };" + } + } + }, + "span": { + "line_start": 15, + "line_stop": 15, + "col_start": 9, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " return Self { points };" + } + } + } + ], + "span": { + "line_start": 14, + "line_stop": 16, + "col_start": 46, + "col_stop": 6, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function new(points: [Point; 5]) -> Self { \n...\n }" + } + }, + "span": { + "line_start": 14, + "line_stop": 16, + "col_start": 5, + "col_stop": 6, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function new(points: [Point; 5]) -> Self { \n...\n }" + } + } + }, + { + "CircuitFunction": { + "annotations": [], + "identifier": "{\"name\":\"slope\",\"span\":\"{\\\"line_start\\\":19,\\\"line_stop\\\":19,\\\"col_start\\\":14,\\\"col_stop\\\":19,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" function slope(self) -> i32 { \\\"}\"}", + "input": [ + { + "SelfKeyword": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":19,\\\"line_stop\\\":19,\\\"col_start\\\":20,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" function slope(self) -> i32 { \\\"}\"}" + } + ], + "output": { + "IntegerType": "I32" + }, + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"num_points\",\"span\":\"{\\\"line_start\\\":21,\\\"line_stop\\\":21,\\\"col_start\\\":13,\\\"col_stop\\\":23,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let num_points = 5i32;\\\"}\"}", + "span": { + "line_start": 21, + "line_stop": 21, + "col_start": 13, + "col_stop": 23, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let num_points = 5i32;" + } + } + ], + "type_": null, + "value": { + "Value": { + "Integer": [ + "I32", + "5", + { + "line_start": 21, + "line_stop": 21, + "col_start": 26, + "col_stop": 30, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let num_points = 5i32;" + } + ] + } + }, + "span": { + "line_start": 21, + "line_stop": 21, + "col_start": 9, + "col_stop": 30, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let num_points = 5i32;" + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"x_sum\",\"span\":\"{\\\"line_start\\\":23,\\\"line_stop\\\":23,\\\"col_start\\\":13,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let x_sum = 0i32; \\\"}\"}", + "span": { + "line_start": 23, + "line_stop": 23, + "col_start": 13, + "col_stop": 18, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let x_sum = 0i32; " + } + } + ], + "type_": null, + "value": { + "Value": { + "Integer": [ + "I32", + "0", + { + "line_start": 23, + "line_stop": 23, + "col_start": 21, + "col_stop": 25, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let x_sum = 0i32; " + } + ] + } + }, + "span": { + "line_start": 23, + "line_stop": 23, + "col_start": 9, + "col_stop": 25, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let x_sum = 0i32; " + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"y_sum\",\"span\":\"{\\\"line_start\\\":24,\\\"line_stop\\\":24,\\\"col_start\\\":13,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let y_sum = 0i32; \\\"}\"}", + "span": { + "line_start": 24, + "line_stop": 24, + "col_start": 13, + "col_stop": 18, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let y_sum = 0i32; " + } + } + ], + "type_": null, + "value": { + "Value": { + "Integer": [ + "I32", + "0", + { + "line_start": 24, + "line_stop": 24, + "col_start": 21, + "col_stop": 25, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let y_sum = 0i32; " + } + ] + } + }, + "span": { + "line_start": 24, + "line_stop": 24, + "col_start": 9, + "col_stop": 25, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let y_sum = 0i32; " + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"xy_sum\",\"span\":\"{\\\"line_start\\\":25,\\\"line_stop\\\":25,\\\"col_start\\\":13,\\\"col_stop\\\":19,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let xy_sum = 0i32; \\\"}\"}", + "span": { + "line_start": 25, + "line_stop": 25, + "col_start": 13, + "col_stop": 19, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let xy_sum = 0i32; " + } + } + ], + "type_": null, + "value": { + "Value": { + "Integer": [ + "I32", + "0", + { + "line_start": 25, + "line_stop": 25, + "col_start": 22, + "col_stop": 26, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let xy_sum = 0i32; " + } + ] + } + }, + "span": { + "line_start": 25, + "line_stop": 25, + "col_start": 9, + "col_stop": 26, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let xy_sum = 0i32; " + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"x2_sum\",\"span\":\"{\\\"line_start\\\":26,\\\"line_stop\\\":26,\\\"col_start\\\":13,\\\"col_stop\\\":19,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let x2_sum = 0i32; \\\"}\"}", + "span": { + "line_start": 26, + "line_stop": 26, + "col_start": 13, + "col_stop": 19, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let x2_sum = 0i32; " + } + } + ], + "type_": null, + "value": { + "Value": { + "Integer": [ + "I32", + "0", + { + "line_start": 26, + "line_stop": 26, + "col_start": 22, + "col_stop": 26, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let x2_sum = 0i32; " + } + ] + } + }, + "span": { + "line_start": 26, + "line_stop": 26, + "col_start": 9, + "col_stop": 26, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let x2_sum = 0i32; " + } + } + }, + { + "Iteration": { + "variable": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":27,\\\"line_stop\\\":27,\\\"col_start\\\":13,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" for i in 0..5 {\\\"}\"}", + "start": { + "Value": { + "Implicit": [ + "0", + { + "line_start": 27, + "line_stop": 27, + "col_start": 18, + "col_stop": 19, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " for i in 0..5 {" + } + ] + } + }, + "stop": { + "Value": { + "Implicit": [ + "5", + { + "line_start": 27, + "line_stop": 27, + "col_start": 21, + "col_stop": 22, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " for i in 0..5 {" + } + ] + } + }, + "inclusive": false, + "block": { + "statements": [ + { + "Assign": { + "operation": "Add", + "assignee": { + "identifier": "{\"name\":\"x_sum\",\"span\":\"{\\\"line_start\\\":28,\\\"line_stop\\\":28,\\\"col_start\\\":13,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x_sum += self.points[i].x;\\\"}\"}", + "accesses": [], + "span": { + "line_start": 28, + "line_stop": 28, + "col_start": 13, + "col_stop": 18, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x_sum += self.points[i].x;" + } + }, + "value": { + "CircuitMemberAccess": { + "circuit": { + "ArrayAccess": { + "array": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":28,\\\"line_stop\\\":28,\\\"col_start\\\":22,\\\"col_stop\\\":26,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x_sum += self.points[i].x;\\\"}\"}" + }, + "name": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":28,\\\"line_stop\\\":28,\\\"col_start\\\":27,\\\"col_stop\\\":33,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x_sum += self.points[i].x;\\\"}\"}", + "span": { + "line_start": 28, + "line_stop": 28, + "col_start": 22, + "col_stop": 33, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x_sum += self.points[i].x;" + } + } + }, + "index": { + "Identifier": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":28,\\\"line_stop\\\":28,\\\"col_start\\\":34,\\\"col_stop\\\":35,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x_sum += self.points[i].x;\\\"}\"}" + }, + "span": { + "line_start": 28, + "line_stop": 28, + "col_start": 22, + "col_stop": 36, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x_sum += self.points[i].x;" + } + } + }, + "name": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":28,\\\"line_stop\\\":28,\\\"col_start\\\":37,\\\"col_stop\\\":38,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x_sum += self.points[i].x;\\\"}\"}", + "span": { + "line_start": 28, + "line_stop": 28, + "col_start": 22, + "col_stop": 38, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x_sum += self.points[i].x;" + } + } + }, + "span": { + "line_start": 28, + "line_stop": 28, + "col_start": 13, + "col_stop": 38, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x_sum += self.points[i].x;" + } + } + }, + { + "Assign": { + "operation": "Add", + "assignee": { + "identifier": "{\"name\":\"y_sum\",\"span\":\"{\\\"line_start\\\":29,\\\"line_stop\\\":29,\\\"col_start\\\":13,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" y_sum += self.points[i].y;\\\"}\"}", + "accesses": [], + "span": { + "line_start": 29, + "line_stop": 29, + "col_start": 13, + "col_stop": 18, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " y_sum += self.points[i].y;" + } + }, + "value": { + "CircuitMemberAccess": { + "circuit": { + "ArrayAccess": { + "array": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":29,\\\"line_stop\\\":29,\\\"col_start\\\":22,\\\"col_stop\\\":26,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" y_sum += self.points[i].y;\\\"}\"}" + }, + "name": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":29,\\\"line_stop\\\":29,\\\"col_start\\\":27,\\\"col_stop\\\":33,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" y_sum += self.points[i].y;\\\"}\"}", + "span": { + "line_start": 29, + "line_stop": 29, + "col_start": 22, + "col_stop": 33, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " y_sum += self.points[i].y;" + } + } + }, + "index": { + "Identifier": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":29,\\\"line_stop\\\":29,\\\"col_start\\\":34,\\\"col_stop\\\":35,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" y_sum += self.points[i].y;\\\"}\"}" + }, + "span": { + "line_start": 29, + "line_stop": 29, + "col_start": 22, + "col_stop": 36, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " y_sum += self.points[i].y;" + } + } + }, + "name": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":29,\\\"line_stop\\\":29,\\\"col_start\\\":37,\\\"col_stop\\\":38,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" y_sum += self.points[i].y;\\\"}\"}", + "span": { + "line_start": 29, + "line_stop": 29, + "col_start": 22, + "col_stop": 38, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " y_sum += self.points[i].y;" + } + } + }, + "span": { + "line_start": 29, + "line_stop": 29, + "col_start": 13, + "col_stop": 38, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " y_sum += self.points[i].y;" + } + } + }, + { + "Assign": { + "operation": "Add", + "assignee": { + "identifier": "{\"name\":\"xy_sum\",\"span\":\"{\\\"line_start\\\":30,\\\"line_stop\\\":30,\\\"col_start\\\":13,\\\"col_stop\\\":19,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" xy_sum += self.points[i].x * self.points[i].y;\\\"}\"}", + "accesses": [], + "span": { + "line_start": 30, + "line_stop": 30, + "col_start": 13, + "col_stop": 19, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " xy_sum += self.points[i].x * self.points[i].y;" + } + }, + "value": { + "Binary": { + "left": { + "CircuitMemberAccess": { + "circuit": { + "ArrayAccess": { + "array": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":30,\\\"line_stop\\\":30,\\\"col_start\\\":23,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" xy_sum += self.points[i].x * self.points[i].y;\\\"}\"}" + }, + "name": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":30,\\\"line_stop\\\":30,\\\"col_start\\\":28,\\\"col_stop\\\":34,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" xy_sum += self.points[i].x * self.points[i].y;\\\"}\"}", + "span": { + "line_start": 30, + "line_stop": 30, + "col_start": 23, + "col_stop": 34, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " xy_sum += self.points[i].x * self.points[i].y;" + } + } + }, + "index": { + "Identifier": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":30,\\\"line_stop\\\":30,\\\"col_start\\\":35,\\\"col_stop\\\":36,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" xy_sum += self.points[i].x * self.points[i].y;\\\"}\"}" + }, + "span": { + "line_start": 30, + "line_stop": 30, + "col_start": 23, + "col_stop": 37, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " xy_sum += self.points[i].x * self.points[i].y;" + } + } + }, + "name": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":30,\\\"line_stop\\\":30,\\\"col_start\\\":38,\\\"col_stop\\\":39,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" xy_sum += self.points[i].x * self.points[i].y;\\\"}\"}", + "span": { + "line_start": 30, + "line_stop": 30, + "col_start": 23, + "col_stop": 39, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " xy_sum += self.points[i].x * self.points[i].y;" + } + } + }, + "right": { + "CircuitMemberAccess": { + "circuit": { + "ArrayAccess": { + "array": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":30,\\\"line_stop\\\":30,\\\"col_start\\\":42,\\\"col_stop\\\":46,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" xy_sum += self.points[i].x * self.points[i].y;\\\"}\"}" + }, + "name": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":30,\\\"line_stop\\\":30,\\\"col_start\\\":47,\\\"col_stop\\\":53,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" xy_sum += self.points[i].x * self.points[i].y;\\\"}\"}", + "span": { + "line_start": 30, + "line_stop": 30, + "col_start": 42, + "col_stop": 53, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " xy_sum += self.points[i].x * self.points[i].y;" + } + } + }, + "index": { + "Identifier": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":30,\\\"line_stop\\\":30,\\\"col_start\\\":54,\\\"col_stop\\\":55,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" xy_sum += self.points[i].x * self.points[i].y;\\\"}\"}" + }, + "span": { + "line_start": 30, + "line_stop": 30, + "col_start": 42, + "col_stop": 56, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " xy_sum += self.points[i].x * self.points[i].y;" + } + } + }, + "name": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":30,\\\"line_stop\\\":30,\\\"col_start\\\":57,\\\"col_stop\\\":58,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" xy_sum += self.points[i].x * self.points[i].y;\\\"}\"}", + "span": { + "line_start": 30, + "line_stop": 30, + "col_start": 42, + "col_stop": 58, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " xy_sum += self.points[i].x * self.points[i].y;" + } + } + }, + "op": "Mul", + "span": { + "line_start": 30, + "line_stop": 30, + "col_start": 23, + "col_stop": 58, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " xy_sum += self.points[i].x * self.points[i].y;" + } + } + }, + "span": { + "line_start": 30, + "line_stop": 30, + "col_start": 13, + "col_stop": 58, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " xy_sum += self.points[i].x * self.points[i].y;" + } + } + }, + { + "Assign": { + "operation": "Add", + "assignee": { + "identifier": "{\"name\":\"x2_sum\",\"span\":\"{\\\"line_start\\\":31,\\\"line_stop\\\":31,\\\"col_start\\\":13,\\\"col_stop\\\":19,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x2_sum += self.points[i].x * self.points[i].x;\\\"}\"}", + "accesses": [], + "span": { + "line_start": 31, + "line_stop": 31, + "col_start": 13, + "col_stop": 19, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x2_sum += self.points[i].x * self.points[i].x;" + } + }, + "value": { + "Binary": { + "left": { + "CircuitMemberAccess": { + "circuit": { + "ArrayAccess": { + "array": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":31,\\\"line_stop\\\":31,\\\"col_start\\\":23,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x2_sum += self.points[i].x * self.points[i].x;\\\"}\"}" + }, + "name": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":31,\\\"line_stop\\\":31,\\\"col_start\\\":28,\\\"col_stop\\\":34,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x2_sum += self.points[i].x * self.points[i].x;\\\"}\"}", + "span": { + "line_start": 31, + "line_stop": 31, + "col_start": 23, + "col_stop": 34, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x2_sum += self.points[i].x * self.points[i].x;" + } + } + }, + "index": { + "Identifier": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":31,\\\"line_stop\\\":31,\\\"col_start\\\":35,\\\"col_stop\\\":36,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x2_sum += self.points[i].x * self.points[i].x;\\\"}\"}" + }, + "span": { + "line_start": 31, + "line_stop": 31, + "col_start": 23, + "col_stop": 37, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x2_sum += self.points[i].x * self.points[i].x;" + } + } + }, + "name": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":31,\\\"line_stop\\\":31,\\\"col_start\\\":38,\\\"col_stop\\\":39,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x2_sum += self.points[i].x * self.points[i].x;\\\"}\"}", + "span": { + "line_start": 31, + "line_stop": 31, + "col_start": 23, + "col_stop": 39, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x2_sum += self.points[i].x * self.points[i].x;" + } + } + }, + "right": { + "CircuitMemberAccess": { + "circuit": { + "ArrayAccess": { + "array": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":31,\\\"line_stop\\\":31,\\\"col_start\\\":42,\\\"col_stop\\\":46,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x2_sum += self.points[i].x * self.points[i].x;\\\"}\"}" + }, + "name": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":31,\\\"line_stop\\\":31,\\\"col_start\\\":47,\\\"col_stop\\\":53,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x2_sum += self.points[i].x * self.points[i].x;\\\"}\"}", + "span": { + "line_start": 31, + "line_stop": 31, + "col_start": 42, + "col_stop": 53, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x2_sum += self.points[i].x * self.points[i].x;" + } + } + }, + "index": { + "Identifier": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":31,\\\"line_stop\\\":31,\\\"col_start\\\":54,\\\"col_stop\\\":55,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x2_sum += self.points[i].x * self.points[i].x;\\\"}\"}" + }, + "span": { + "line_start": 31, + "line_stop": 31, + "col_start": 42, + "col_stop": 56, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x2_sum += self.points[i].x * self.points[i].x;" + } + } + }, + "name": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":31,\\\"line_stop\\\":31,\\\"col_start\\\":57,\\\"col_stop\\\":58,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x2_sum += self.points[i].x * self.points[i].x;\\\"}\"}", + "span": { + "line_start": 31, + "line_stop": 31, + "col_start": 42, + "col_stop": 58, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x2_sum += self.points[i].x * self.points[i].x;" + } + } + }, + "op": "Mul", + "span": { + "line_start": 31, + "line_stop": 31, + "col_start": 23, + "col_stop": 58, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x2_sum += self.points[i].x * self.points[i].x;" + } + } + }, + "span": { + "line_start": 31, + "line_stop": 31, + "col_start": 13, + "col_stop": 58, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x2_sum += self.points[i].x * self.points[i].x;" + } + } + } + ], + "span": { + "line_start": 27, + "line_stop": 32, + "col_start": 23, + "col_stop": 10, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " for i in 0..5 {\n...\n }" + } + }, + "span": { + "line_start": 27, + "line_stop": 32, + "col_start": 9, + "col_stop": 10, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " for i in 0..5 {\n...\n }\n\n\n" + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"numerator\",\"span\":\"{\\\"line_start\\\":33,\\\"line_stop\\\":33,\\\"col_start\\\":13,\\\"col_stop\\\":22,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let numerator = (num_points * xy_sum) - (x_sum * y_sum); \\\"}\"}", + "span": { + "line_start": 33, + "line_stop": 33, + "col_start": 13, + "col_stop": 22, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let numerator = (num_points * xy_sum) - (x_sum * y_sum); " + } + } + ], + "type_": null, + "value": { + "Binary": { + "left": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"num_points\",\"span\":\"{\\\"line_start\\\":33,\\\"line_stop\\\":33,\\\"col_start\\\":26,\\\"col_stop\\\":36,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let numerator = (num_points * xy_sum) - (x_sum * y_sum); \\\"}\"}" + }, + "right": { + "Identifier": "{\"name\":\"xy_sum\",\"span\":\"{\\\"line_start\\\":33,\\\"line_stop\\\":33,\\\"col_start\\\":39,\\\"col_stop\\\":45,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let numerator = (num_points * xy_sum) - (x_sum * y_sum); \\\"}\"}" + }, + "op": "Mul", + "span": { + "line_start": 33, + "line_stop": 33, + "col_start": 26, + "col_stop": 45, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let numerator = (num_points * xy_sum) - (x_sum * y_sum); " + } + } + }, + "right": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"x_sum\",\"span\":\"{\\\"line_start\\\":33,\\\"line_stop\\\":33,\\\"col_start\\\":50,\\\"col_stop\\\":55,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let numerator = (num_points * xy_sum) - (x_sum * y_sum); \\\"}\"}" + }, + "right": { + "Identifier": "{\"name\":\"y_sum\",\"span\":\"{\\\"line_start\\\":33,\\\"line_stop\\\":33,\\\"col_start\\\":58,\\\"col_stop\\\":63,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let numerator = (num_points * xy_sum) - (x_sum * y_sum); \\\"}\"}" + }, + "op": "Mul", + "span": { + "line_start": 33, + "line_stop": 33, + "col_start": 50, + "col_stop": 63, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let numerator = (num_points * xy_sum) - (x_sum * y_sum); " + } + } + }, + "op": "Sub", + "span": { + "line_start": 33, + "line_stop": 33, + "col_start": 26, + "col_stop": 63, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let numerator = (num_points * xy_sum) - (x_sum * y_sum); " + } + } + }, + "span": { + "line_start": 33, + "line_stop": 33, + "col_start": 9, + "col_stop": 63, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let numerator = (num_points * xy_sum) - (x_sum * y_sum); " + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"denominator\",\"span\":\"{\\\"line_start\\\":34,\\\"line_stop\\\":34,\\\"col_start\\\":13,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let denominator = (num_points * x2_sum) - (x_sum * x_sum);\\\"}\"}", + "span": { + "line_start": 34, + "line_stop": 34, + "col_start": 13, + "col_stop": 24, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let denominator = (num_points * x2_sum) - (x_sum * x_sum);" + } + } + ], + "type_": null, + "value": { + "Binary": { + "left": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"num_points\",\"span\":\"{\\\"line_start\\\":34,\\\"line_stop\\\":34,\\\"col_start\\\":28,\\\"col_stop\\\":38,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let denominator = (num_points * x2_sum) - (x_sum * x_sum);\\\"}\"}" + }, + "right": { + "Identifier": "{\"name\":\"x2_sum\",\"span\":\"{\\\"line_start\\\":34,\\\"line_stop\\\":34,\\\"col_start\\\":41,\\\"col_stop\\\":47,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let denominator = (num_points * x2_sum) - (x_sum * x_sum);\\\"}\"}" + }, + "op": "Mul", + "span": { + "line_start": 34, + "line_stop": 34, + "col_start": 28, + "col_stop": 47, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let denominator = (num_points * x2_sum) - (x_sum * x_sum);" + } + } + }, + "right": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"x_sum\",\"span\":\"{\\\"line_start\\\":34,\\\"line_stop\\\":34,\\\"col_start\\\":52,\\\"col_stop\\\":57,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let denominator = (num_points * x2_sum) - (x_sum * x_sum);\\\"}\"}" + }, + "right": { + "Identifier": "{\"name\":\"x_sum\",\"span\":\"{\\\"line_start\\\":34,\\\"line_stop\\\":34,\\\"col_start\\\":60,\\\"col_stop\\\":65,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let denominator = (num_points * x2_sum) - (x_sum * x_sum);\\\"}\"}" + }, + "op": "Mul", + "span": { + "line_start": 34, + "line_stop": 34, + "col_start": 52, + "col_stop": 65, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let denominator = (num_points * x2_sum) - (x_sum * x_sum);" + } + } + }, + "op": "Sub", + "span": { + "line_start": 34, + "line_stop": 34, + "col_start": 28, + "col_stop": 65, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let denominator = (num_points * x2_sum) - (x_sum * x_sum);" + } + } + }, + "span": { + "line_start": 34, + "line_stop": 34, + "col_start": 9, + "col_stop": 65, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let denominator = (num_points * x2_sum) - (x_sum * x_sum);" + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"slope\",\"span\":\"{\\\"line_start\\\":35,\\\"line_stop\\\":35,\\\"col_start\\\":13,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let slope = numerator / denominator;\\\"}\"}", + "span": { + "line_start": 35, + "line_stop": 35, + "col_start": 13, + "col_stop": 18, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let slope = numerator / denominator;" + } + } + ], + "type_": null, + "value": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"numerator\",\"span\":\"{\\\"line_start\\\":35,\\\"line_stop\\\":35,\\\"col_start\\\":21,\\\"col_stop\\\":30,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let slope = numerator / denominator;\\\"}\"}" + }, + "right": { + "Identifier": "{\"name\":\"denominator\",\"span\":\"{\\\"line_start\\\":35,\\\"line_stop\\\":35,\\\"col_start\\\":33,\\\"col_stop\\\":44,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let slope = numerator / denominator;\\\"}\"}" + }, + "op": "Div", + "span": { + "line_start": 35, + "line_stop": 35, + "col_start": 21, + "col_stop": 44, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let slope = numerator / denominator;" + } + } + }, + "span": { + "line_start": 35, + "line_stop": 35, + "col_start": 9, + "col_stop": 44, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let slope = numerator / denominator;" + } + } + }, + { + "Return": { + "expression": { + "Identifier": "{\"name\":\"slope\",\"span\":\"{\\\"line_start\\\":36,\\\"line_stop\\\":36,\\\"col_start\\\":16,\\\"col_stop\\\":21,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return slope;\\\"}\"}" + }, + "span": { + "line_start": 36, + "line_stop": 36, + "col_start": 9, + "col_stop": 21, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " return slope;" + } + } + } + ], + "span": { + "line_start": 19, + "line_stop": 37, + "col_start": 33, + "col_stop": 6, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function slope(self) -> i32 { \n...\n }" + } + }, + "span": { + "line_start": 19, + "line_stop": 37, + "col_start": 5, + "col_stop": 6, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function slope(self) -> i32 { \n...\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + } + } + }, + { + "CircuitFunction": { + "annotations": [], + "identifier": "{\"name\":\"offset\",\"span\":\"{\\\"line_start\\\":39,\\\"line_stop\\\":39,\\\"col_start\\\":14,\\\"col_stop\\\":20,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" function offset(self, slope: i32) -> i32 {\\\"}\"}", + "input": [ + { + "SelfKeyword": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":39,\\\"line_stop\\\":39,\\\"col_start\\\":21,\\\"col_stop\\\":25,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" function offset(self, slope: i32) -> i32 {\\\"}\"}" + }, + { + "Variable": { + "identifier": "{\"name\":\"slope\",\"span\":\"{\\\"line_start\\\":39,\\\"line_stop\\\":39,\\\"col_start\\\":27,\\\"col_stop\\\":32,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" function offset(self, slope: i32) -> i32 {\\\"}\"}", + "const_": false, + "mutable": true, + "type_": { + "IntegerType": "I32" + }, + "span": { + "line_start": 39, + "line_stop": 39, + "col_start": 27, + "col_stop": 32, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function offset(self, slope: i32) -> i32 {" + } + } + } + ], + "output": { + "IntegerType": "I32" + }, + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"num_points\",\"span\":\"{\\\"line_start\\\":40,\\\"line_stop\\\":40,\\\"col_start\\\":13,\\\"col_stop\\\":23,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let num_points = 5i32; \\\"}\"}", + "span": { + "line_start": 40, + "line_stop": 40, + "col_start": 13, + "col_stop": 23, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let num_points = 5i32; " + } + } + ], + "type_": null, + "value": { + "Value": { + "Integer": [ + "I32", + "5", + { + "line_start": 40, + "line_stop": 40, + "col_start": 26, + "col_stop": 30, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let num_points = 5i32; " + } + ] + } + }, + "span": { + "line_start": 40, + "line_stop": 40, + "col_start": 9, + "col_stop": 30, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let num_points = 5i32; " + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"x_sum\",\"span\":\"{\\\"line_start\\\":42,\\\"line_stop\\\":42,\\\"col_start\\\":13,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let x_sum = 0i32;\\\"}\"}", + "span": { + "line_start": 42, + "line_stop": 42, + "col_start": 13, + "col_stop": 18, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let x_sum = 0i32;" + } + } + ], + "type_": null, + "value": { + "Value": { + "Integer": [ + "I32", + "0", + { + "line_start": 42, + "line_stop": 42, + "col_start": 21, + "col_stop": 25, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let x_sum = 0i32;" + } + ] + } + }, + "span": { + "line_start": 42, + "line_stop": 42, + "col_start": 9, + "col_stop": 25, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let x_sum = 0i32;" + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"y_sum\",\"span\":\"{\\\"line_start\\\":43,\\\"line_stop\\\":43,\\\"col_start\\\":13,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let y_sum = 0i32;\\\"}\"}", + "span": { + "line_start": 43, + "line_stop": 43, + "col_start": 13, + "col_stop": 18, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let y_sum = 0i32;" + } + } + ], + "type_": null, + "value": { + "Value": { + "Integer": [ + "I32", + "0", + { + "line_start": 43, + "line_stop": 43, + "col_start": 21, + "col_stop": 25, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let y_sum = 0i32;" + } + ] + } + }, + "span": { + "line_start": 43, + "line_stop": 43, + "col_start": 9, + "col_stop": 25, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let y_sum = 0i32;" + } + } + }, + { + "Iteration": { + "variable": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":44,\\\"line_stop\\\":44,\\\"col_start\\\":13,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" for i in 0..5 {\\\"}\"}", + "start": { + "Value": { + "Implicit": [ + "0", + { + "line_start": 44, + "line_stop": 44, + "col_start": 18, + "col_stop": 19, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " for i in 0..5 {" + } + ] + } + }, + "stop": { + "Value": { + "Implicit": [ + "5", + { + "line_start": 44, + "line_stop": 44, + "col_start": 21, + "col_stop": 22, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " for i in 0..5 {" + } + ] + } + }, + "inclusive": false, + "block": { + "statements": [ + { + "Assign": { + "operation": "Add", + "assignee": { + "identifier": "{\"name\":\"x_sum\",\"span\":\"{\\\"line_start\\\":45,\\\"line_stop\\\":45,\\\"col_start\\\":13,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x_sum += self.points[i].x;\\\"}\"}", + "accesses": [], + "span": { + "line_start": 45, + "line_stop": 45, + "col_start": 13, + "col_stop": 18, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x_sum += self.points[i].x;" + } + }, + "value": { + "CircuitMemberAccess": { + "circuit": { + "ArrayAccess": { + "array": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":45,\\\"line_stop\\\":45,\\\"col_start\\\":22,\\\"col_stop\\\":26,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x_sum += self.points[i].x;\\\"}\"}" + }, + "name": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":45,\\\"line_stop\\\":45,\\\"col_start\\\":27,\\\"col_stop\\\":33,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x_sum += self.points[i].x;\\\"}\"}", + "span": { + "line_start": 45, + "line_stop": 45, + "col_start": 22, + "col_stop": 33, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x_sum += self.points[i].x;" + } + } + }, + "index": { + "Identifier": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":45,\\\"line_stop\\\":45,\\\"col_start\\\":34,\\\"col_stop\\\":35,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x_sum += self.points[i].x;\\\"}\"}" + }, + "span": { + "line_start": 45, + "line_stop": 45, + "col_start": 22, + "col_stop": 36, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x_sum += self.points[i].x;" + } + } + }, + "name": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":45,\\\"line_stop\\\":45,\\\"col_start\\\":37,\\\"col_stop\\\":38,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" x_sum += self.points[i].x;\\\"}\"}", + "span": { + "line_start": 45, + "line_stop": 45, + "col_start": 22, + "col_stop": 38, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x_sum += self.points[i].x;" + } + } + }, + "span": { + "line_start": 45, + "line_stop": 45, + "col_start": 13, + "col_stop": 38, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " x_sum += self.points[i].x;" + } + } + }, + { + "Assign": { + "operation": "Add", + "assignee": { + "identifier": "{\"name\":\"y_sum\",\"span\":\"{\\\"line_start\\\":46,\\\"line_stop\\\":46,\\\"col_start\\\":13,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" y_sum += self.points[i].y; \\\"}\"}", + "accesses": [], + "span": { + "line_start": 46, + "line_stop": 46, + "col_start": 13, + "col_stop": 18, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " y_sum += self.points[i].y; " + } + }, + "value": { + "CircuitMemberAccess": { + "circuit": { + "ArrayAccess": { + "array": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":46,\\\"line_stop\\\":46,\\\"col_start\\\":22,\\\"col_stop\\\":26,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" y_sum += self.points[i].y; \\\"}\"}" + }, + "name": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":46,\\\"line_stop\\\":46,\\\"col_start\\\":27,\\\"col_stop\\\":33,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" y_sum += self.points[i].y; \\\"}\"}", + "span": { + "line_start": 46, + "line_stop": 46, + "col_start": 22, + "col_stop": 33, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " y_sum += self.points[i].y; " + } + } + }, + "index": { + "Identifier": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":46,\\\"line_stop\\\":46,\\\"col_start\\\":34,\\\"col_stop\\\":35,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" y_sum += self.points[i].y; \\\"}\"}" + }, + "span": { + "line_start": 46, + "line_stop": 46, + "col_start": 22, + "col_stop": 36, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " y_sum += self.points[i].y; " + } + } + }, + "name": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":46,\\\"line_stop\\\":46,\\\"col_start\\\":37,\\\"col_stop\\\":38,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" y_sum += self.points[i].y; \\\"}\"}", + "span": { + "line_start": 46, + "line_stop": 46, + "col_start": 22, + "col_stop": 38, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " y_sum += self.points[i].y; " + } + } + }, + "span": { + "line_start": 46, + "line_stop": 46, + "col_start": 13, + "col_stop": 38, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " y_sum += self.points[i].y; " + } + } + } + ], + "span": { + "line_start": 44, + "line_stop": 47, + "col_start": 23, + "col_stop": 10, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " for i in 0..5 {\n...\n }" + } + }, + "span": { + "line_start": 44, + "line_stop": 47, + "col_start": 9, + "col_stop": 10, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " for i in 0..5 {\n...\n }\n" + } + } + }, + { + "Return": { + "expression": { + "Binary": { + "left": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"y_sum\",\"span\":\"{\\\"line_start\\\":48,\\\"line_stop\\\":48,\\\"col_start\\\":17,\\\"col_stop\\\":22,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return (y_sum - slope * x_sum) / num_points;\\\"}\"}" + }, + "right": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"slope\",\"span\":\"{\\\"line_start\\\":48,\\\"line_stop\\\":48,\\\"col_start\\\":25,\\\"col_stop\\\":30,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return (y_sum - slope * x_sum) / num_points;\\\"}\"}" + }, + "right": { + "Identifier": "{\"name\":\"x_sum\",\"span\":\"{\\\"line_start\\\":48,\\\"line_stop\\\":48,\\\"col_start\\\":33,\\\"col_stop\\\":38,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return (y_sum - slope * x_sum) / num_points;\\\"}\"}" + }, + "op": "Mul", + "span": { + "line_start": 48, + "line_stop": 48, + "col_start": 25, + "col_stop": 38, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " return (y_sum - slope * x_sum) / num_points;" + } + } + }, + "op": "Sub", + "span": { + "line_start": 48, + "line_stop": 48, + "col_start": 17, + "col_stop": 38, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " return (y_sum - slope * x_sum) / num_points;" + } + } + }, + "right": { + "Identifier": "{\"name\":\"num_points\",\"span\":\"{\\\"line_start\\\":48,\\\"line_stop\\\":48,\\\"col_start\\\":42,\\\"col_stop\\\":52,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return (y_sum - slope * x_sum) / num_points;\\\"}\"}" + }, + "op": "Div", + "span": { + "line_start": 48, + "line_stop": 48, + "col_start": 17, + "col_stop": 52, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " return (y_sum - slope * x_sum) / num_points;" + } + } + }, + "span": { + "line_start": 48, + "line_stop": 48, + "col_start": 9, + "col_stop": 52, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " return (y_sum - slope * x_sum) / num_points;" + } + } + } + ], + "span": { + "line_start": 39, + "line_stop": 49, + "col_start": 46, + "col_stop": 6, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function offset(self, slope: i32) -> i32 {\n...\n }" + } + }, + "span": { + "line_start": 39, + "line_stop": 49, + "col_start": 5, + "col_stop": 6, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " function offset(self, slope: i32) -> i32 {\n...\n }\n\n\n\n\n\n\n\n" + } + } + } + ] + } + }, + "global_consts": {}, + "functions": { + "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":53,\\\"line_stop\\\":53,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\"function main (x: i32, y: i32) -> [i32; 2] {\\\"}\"}": { + "annotations": [], + "identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":53,\\\"line_stop\\\":53,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\"function main (x: i32, y: i32) -> [i32; 2] {\\\"}\"}", + "input": [ + { + "Variable": { + "identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":53,\\\"line_stop\\\":53,\\\"col_start\\\":16,\\\"col_stop\\\":17,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\"function main (x: i32, y: i32) -> [i32; 2] {\\\"}\"}", + "const_": false, + "mutable": true, + "type_": { + "IntegerType": "I32" + }, + "span": { + "line_start": 53, + "line_stop": 53, + "col_start": 16, + "col_stop": 17, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": "function main (x: i32, y: i32) -> [i32; 2] {" + } + } + }, + { + "Variable": { + "identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":53,\\\"line_stop\\\":53,\\\"col_start\\\":24,\\\"col_stop\\\":25,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\"function main (x: i32, y: i32) -> [i32; 2] {\\\"}\"}", + "const_": false, + "mutable": true, + "type_": { + "IntegerType": "I32" + }, + "span": { + "line_start": 53, + "line_stop": 53, + "col_start": 24, + "col_stop": 25, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": "function main (x: i32, y: i32) -> [i32; 2] {" + } + } + } + ], + "output": { + "Array": [ + { + "IntegerType": "I32" + }, + [ + { + "value": "2" + } + ] + ] + }, + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":54,\\\"line_stop\\\":54,\\\"col_start\\\":7,\\\"col_stop\\\":13,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let points: [Point; 5] = [\\\"}\"}", + "span": { + "line_start": 54, + "line_stop": 54, + "col_start": 7, + "col_stop": 13, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let points: [Point; 5] = [" + } + } + ], + "type_": { + "Array": [ + { + "Circuit": "{\"name\":\"Point\",\"span\":\"{\\\"line_start\\\":54,\\\"line_stop\\\":54,\\\"col_start\\\":16,\\\"col_stop\\\":21,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let points: [Point; 5] = [\\\"}\"}" + }, + [ + { + "value": "5" + } + ] + ] + }, + "value": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "CircuitInit": { + "name": "{\"name\":\"Point\",\"span\":\"{\\\"line_start\\\":55,\\\"line_stop\\\":55,\\\"col_start\\\":7,\\\"col_stop\\\":12,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 1, y: y + 1},\\\"}\"}", + "members": [ + { + "identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":55,\\\"line_stop\\\":55,\\\"col_start\\\":13,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 1, y: y + 1},\\\"}\"}", + "expression": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":55,\\\"line_stop\\\":55,\\\"col_start\\\":16,\\\"col_stop\\\":17,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 1, y: y + 1},\\\"}\"}" + }, + "right": { + "Value": { + "Implicit": [ + "1", + { + "line_start": 55, + "line_stop": 55, + "col_start": 20, + "col_stop": 21, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 1, y: y + 1}," + } + ] + } + }, + "op": "Add", + "span": { + "line_start": 55, + "line_stop": 55, + "col_start": 16, + "col_stop": 21, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 1, y: y + 1}," + } + } + } + }, + { + "identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":55,\\\"line_stop\\\":55,\\\"col_start\\\":23,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 1, y: y + 1},\\\"}\"}", + "expression": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":55,\\\"line_stop\\\":55,\\\"col_start\\\":26,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 1, y: y + 1},\\\"}\"}" + }, + "right": { + "Value": { + "Implicit": [ + "1", + { + "line_start": 55, + "line_stop": 55, + "col_start": 30, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 1, y: y + 1}," + } + ] + } + }, + "op": "Add", + "span": { + "line_start": 55, + "line_stop": 55, + "col_start": 26, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 1, y: y + 1}," + } + } + } + } + ], + "span": { + "line_start": 55, + "line_stop": 55, + "col_start": 7, + "col_stop": 32, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 1, y: y + 1}," + } + } + } + }, + { + "Expression": { + "CircuitInit": { + "name": "{\"name\":\"Point\",\"span\":\"{\\\"line_start\\\":56,\\\"line_stop\\\":56,\\\"col_start\\\":7,\\\"col_stop\\\":12,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 2, y: y + 2},\\\"}\"}", + "members": [ + { + "identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":56,\\\"line_stop\\\":56,\\\"col_start\\\":13,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 2, y: y + 2},\\\"}\"}", + "expression": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":56,\\\"line_stop\\\":56,\\\"col_start\\\":16,\\\"col_stop\\\":17,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 2, y: y + 2},\\\"}\"}" + }, + "right": { + "Value": { + "Implicit": [ + "2", + { + "line_start": 56, + "line_stop": 56, + "col_start": 20, + "col_stop": 21, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 2, y: y + 2}," + } + ] + } + }, + "op": "Add", + "span": { + "line_start": 56, + "line_stop": 56, + "col_start": 16, + "col_stop": 21, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 2, y: y + 2}," + } + } + } + }, + { + "identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":56,\\\"line_stop\\\":56,\\\"col_start\\\":23,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 2, y: y + 2},\\\"}\"}", + "expression": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":56,\\\"line_stop\\\":56,\\\"col_start\\\":26,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 2, y: y + 2},\\\"}\"}" + }, + "right": { + "Value": { + "Implicit": [ + "2", + { + "line_start": 56, + "line_stop": 56, + "col_start": 30, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 2, y: y + 2}," + } + ] + } + }, + "op": "Add", + "span": { + "line_start": 56, + "line_stop": 56, + "col_start": 26, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 2, y: y + 2}," + } + } + } + } + ], + "span": { + "line_start": 56, + "line_stop": 56, + "col_start": 7, + "col_stop": 32, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 2, y: y + 2}," + } + } + } + }, + { + "Expression": { + "CircuitInit": { + "name": "{\"name\":\"Point\",\"span\":\"{\\\"line_start\\\":57,\\\"line_stop\\\":57,\\\"col_start\\\":7,\\\"col_stop\\\":12,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 3, y: y + 3},\\\"}\"}", + "members": [ + { + "identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":57,\\\"line_stop\\\":57,\\\"col_start\\\":13,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 3, y: y + 3},\\\"}\"}", + "expression": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":57,\\\"line_stop\\\":57,\\\"col_start\\\":16,\\\"col_stop\\\":17,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 3, y: y + 3},\\\"}\"}" + }, + "right": { + "Value": { + "Implicit": [ + "3", + { + "line_start": 57, + "line_stop": 57, + "col_start": 20, + "col_stop": 21, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 3, y: y + 3}," + } + ] + } + }, + "op": "Add", + "span": { + "line_start": 57, + "line_stop": 57, + "col_start": 16, + "col_stop": 21, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 3, y: y + 3}," + } + } + } + }, + { + "identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":57,\\\"line_stop\\\":57,\\\"col_start\\\":23,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 3, y: y + 3},\\\"}\"}", + "expression": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":57,\\\"line_stop\\\":57,\\\"col_start\\\":26,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 3, y: y + 3},\\\"}\"}" + }, + "right": { + "Value": { + "Implicit": [ + "3", + { + "line_start": 57, + "line_stop": 57, + "col_start": 30, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 3, y: y + 3}," + } + ] + } + }, + "op": "Add", + "span": { + "line_start": 57, + "line_stop": 57, + "col_start": 26, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 3, y: y + 3}," + } + } + } + } + ], + "span": { + "line_start": 57, + "line_stop": 57, + "col_start": 7, + "col_stop": 32, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 3, y: y + 3}," + } + } + } + }, + { + "Expression": { + "CircuitInit": { + "name": "{\"name\":\"Point\",\"span\":\"{\\\"line_start\\\":58,\\\"line_stop\\\":58,\\\"col_start\\\":7,\\\"col_stop\\\":12,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 4, y: y + 4},\\\"}\"}", + "members": [ + { + "identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":58,\\\"line_stop\\\":58,\\\"col_start\\\":13,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 4, y: y + 4},\\\"}\"}", + "expression": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":58,\\\"line_stop\\\":58,\\\"col_start\\\":16,\\\"col_stop\\\":17,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 4, y: y + 4},\\\"}\"}" + }, + "right": { + "Value": { + "Implicit": [ + "4", + { + "line_start": 58, + "line_stop": 58, + "col_start": 20, + "col_stop": 21, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 4, y: y + 4}," + } + ] + } + }, + "op": "Add", + "span": { + "line_start": 58, + "line_stop": 58, + "col_start": 16, + "col_stop": 21, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 4, y: y + 4}," + } + } + } + }, + { + "identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":58,\\\"line_stop\\\":58,\\\"col_start\\\":23,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 4, y: y + 4},\\\"}\"}", + "expression": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":58,\\\"line_stop\\\":58,\\\"col_start\\\":26,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 4, y: y + 4},\\\"}\"}" + }, + "right": { + "Value": { + "Implicit": [ + "4", + { + "line_start": 58, + "line_stop": 58, + "col_start": 30, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 4, y: y + 4}," + } + ] + } + }, + "op": "Add", + "span": { + "line_start": 58, + "line_stop": 58, + "col_start": 26, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 4, y: y + 4}," + } + } + } + } + ], + "span": { + "line_start": 58, + "line_stop": 58, + "col_start": 7, + "col_stop": 32, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 4, y: y + 4}," + } + } + } + }, + { + "Expression": { + "CircuitInit": { + "name": "{\"name\":\"Point\",\"span\":\"{\\\"line_start\\\":59,\\\"line_stop\\\":59,\\\"col_start\\\":7,\\\"col_stop\\\":12,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 5, y: y + 5}\\\"}\"}", + "members": [ + { + "identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":59,\\\"line_stop\\\":59,\\\"col_start\\\":13,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 5, y: y + 5}\\\"}\"}", + "expression": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":59,\\\"line_stop\\\":59,\\\"col_start\\\":16,\\\"col_stop\\\":17,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 5, y: y + 5}\\\"}\"}" + }, + "right": { + "Value": { + "Implicit": [ + "5", + { + "line_start": 59, + "line_stop": 59, + "col_start": 20, + "col_stop": 21, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 5, y: y + 5}" + } + ] + } + }, + "op": "Add", + "span": { + "line_start": 59, + "line_stop": 59, + "col_start": 16, + "col_stop": 21, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 5, y: y + 5}" + } + } + } + }, + { + "identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":59,\\\"line_stop\\\":59,\\\"col_start\\\":23,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 5, y: y + 5}\\\"}\"}", + "expression": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":59,\\\"line_stop\\\":59,\\\"col_start\\\":26,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" Point{x: x + 5, y: y + 5}\\\"}\"}" + }, + "right": { + "Value": { + "Implicit": [ + "5", + { + "line_start": 59, + "line_stop": 59, + "col_start": 30, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 5, y: y + 5}" + } + ] + } + }, + "op": "Add", + "span": { + "line_start": 59, + "line_stop": 59, + "col_start": 26, + "col_stop": 31, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 5, y: y + 5}" + } + } + } + } + ], + "span": { + "line_start": 59, + "line_stop": 59, + "col_start": 7, + "col_stop": 32, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " Point{x: x + 5, y: y + 5}" + } + } + } + } + ], + "span": { + "line_start": 54, + "line_stop": 60, + "col_start": 28, + "col_stop": 4, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let points: [Point; 5] = [\n...\n ];" + } + } + }, + "span": { + "line_start": 54, + "line_stop": 60, + "col_start": 3, + "col_stop": 4, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let points: [Point; 5] = [\n...\n ];\n\n\n\n" + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"reg\",\"span\":\"{\\\"line_start\\\":61,\\\"line_stop\\\":61,\\\"col_start\\\":7,\\\"col_stop\\\":10,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let reg = LinearRegression::new(points);\\\"}\"}", + "span": { + "line_start": 61, + "line_stop": 61, + "col_start": 7, + "col_stop": 10, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let reg = LinearRegression::new(points);" + } + } + ], + "type_": null, + "value": { + "Call": { + "function": { + "CircuitStaticFunctionAccess": { + "circuit": { + "Identifier": "{\"name\":\"LinearRegression\",\"span\":\"{\\\"line_start\\\":61,\\\"line_stop\\\":61,\\\"col_start\\\":13,\\\"col_stop\\\":29,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let reg = LinearRegression::new(points);\\\"}\"}" + }, + "name": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":61,\\\"line_stop\\\":61,\\\"col_start\\\":31,\\\"col_stop\\\":34,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let reg = LinearRegression::new(points);\\\"}\"}", + "span": { + "line_start": 61, + "line_stop": 61, + "col_start": 13, + "col_stop": 34, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let reg = LinearRegression::new(points);" + } + } + }, + "arguments": [ + { + "Identifier": "{\"name\":\"points\",\"span\":\"{\\\"line_start\\\":61,\\\"line_stop\\\":61,\\\"col_start\\\":35,\\\"col_stop\\\":41,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let reg = LinearRegression::new(points);\\\"}\"}" + } + ], + "span": { + "line_start": 61, + "line_stop": 61, + "col_start": 13, + "col_stop": 42, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let reg = LinearRegression::new(points);" + } + } + }, + "span": { + "line_start": 61, + "line_stop": 61, + "col_start": 3, + "col_stop": 42, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let reg = LinearRegression::new(points);" + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"slope\",\"span\":\"{\\\"line_start\\\":62,\\\"line_stop\\\":62,\\\"col_start\\\":7,\\\"col_stop\\\":12,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let slope = reg.slope();\\\"}\"}", + "span": { + "line_start": 62, + "line_stop": 62, + "col_start": 7, + "col_stop": 12, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let slope = reg.slope();" + } + } + ], + "type_": null, + "value": { + "Call": { + "function": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"reg\",\"span\":\"{\\\"line_start\\\":62,\\\"line_stop\\\":62,\\\"col_start\\\":15,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let slope = reg.slope();\\\"}\"}" + }, + "name": "{\"name\":\"slope\",\"span\":\"{\\\"line_start\\\":62,\\\"line_stop\\\":62,\\\"col_start\\\":19,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let slope = reg.slope();\\\"}\"}", + "span": { + "line_start": 62, + "line_stop": 62, + "col_start": 15, + "col_stop": 24, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let slope = reg.slope();" + } + } + }, + "arguments": [], + "span": { + "line_start": 62, + "line_stop": 62, + "col_start": 15, + "col_stop": 26, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let slope = reg.slope();" + } + } + }, + "span": { + "line_start": 62, + "line_stop": 62, + "col_start": 3, + "col_stop": 26, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let slope = reg.slope();" + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"offset\",\"span\":\"{\\\"line_start\\\":63,\\\"line_stop\\\":63,\\\"col_start\\\":7,\\\"col_stop\\\":13,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let offset = reg.offset(slope);\\\"}\"}", + "span": { + "line_start": 63, + "line_stop": 63, + "col_start": 7, + "col_stop": 13, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let offset = reg.offset(slope);" + } + } + ], + "type_": null, + "value": { + "Call": { + "function": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"reg\",\"span\":\"{\\\"line_start\\\":63,\\\"line_stop\\\":63,\\\"col_start\\\":16,\\\"col_stop\\\":19,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let offset = reg.offset(slope);\\\"}\"}" + }, + "name": "{\"name\":\"offset\",\"span\":\"{\\\"line_start\\\":63,\\\"line_stop\\\":63,\\\"col_start\\\":20,\\\"col_stop\\\":26,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let offset = reg.offset(slope);\\\"}\"}", + "span": { + "line_start": 63, + "line_stop": 63, + "col_start": 16, + "col_stop": 26, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let offset = reg.offset(slope);" + } + } + }, + "arguments": [ + { + "Identifier": "{\"name\":\"slope\",\"span\":\"{\\\"line_start\\\":63,\\\"line_stop\\\":63,\\\"col_start\\\":27,\\\"col_stop\\\":32,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" let offset = reg.offset(slope);\\\"}\"}" + } + ], + "span": { + "line_start": 63, + "line_stop": 63, + "col_start": 16, + "col_stop": 33, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let offset = reg.offset(slope);" + } + } + }, + "span": { + "line_start": 63, + "line_stop": 63, + "col_start": 3, + "col_stop": 33, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " let offset = reg.offset(slope);" + } + } + }, + { + "Return": { + "expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Identifier": "{\"name\":\"slope\",\"span\":\"{\\\"line_start\\\":64,\\\"line_stop\\\":64,\\\"col_start\\\":11,\\\"col_stop\\\":16,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return [slope, offset];\\\"}\"}" + } + }, + { + "Expression": { + "Identifier": "{\"name\":\"offset\",\"span\":\"{\\\"line_start\\\":64,\\\"line_stop\\\":64,\\\"col_start\\\":18,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo\\\",\\\"content\\\":\\\" return [slope, offset];\\\"}\"}" + } + } + ], + "span": { + "line_start": 64, + "line_stop": 64, + "col_start": 10, + "col_stop": 25, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " return [slope, offset];" + } + } + }, + "span": { + "line_start": 64, + "line_stop": 64, + "col_start": 3, + "col_stop": 25, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": " return [slope, offset];" + } + } + } + ], + "span": { + "line_start": 53, + "line_stop": 65, + "col_start": 44, + "col_stop": 2, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": "function main (x: i32, y: i32) -> [i32; 2] {\n...\n}" + } + }, + "span": { + "line_start": 53, + "line_stop": 65, + "col_start": 1, + "col_stop": 2, + "path": "/Users/pranav/work/Aleo/leo/examples/linear-regression/src/main.leo", + "content": "function main (x: i32, y: i32) -> [i32; 2] {\n...\n}\n\n\n\n\n\n\n\n\n\n" + } + } + } +} \ No newline at end of file diff --git a/parser/tests/serialization/expected_leo_ast.json b/parser/tests/serialization/expected_leo_ast/one_plus_one.json similarity index 100% rename from parser/tests/serialization/expected_leo_ast.json rename to parser/tests/serialization/expected_leo_ast/one_plus_one.json diff --git a/parser/tests/serialization/expected_leo_ast/palindrome.json b/parser/tests/serialization/expected_leo_ast/palindrome.json new file mode 100644 index 0000000000..5e512e9c57 --- /dev/null +++ b/parser/tests/serialization/expected_leo_ast/palindrome.json @@ -0,0 +1,1232 @@ +{ + "aliases": {}, + "circuits": {}, + "expected_input": [], + "functions": { + "{\"name\":\"is_palindrome\",\"span\":\"{\\\"line_start\\\":8,\\\"line_stop\\\":8,\\\"col_start\\\":10,\\\"col_stop\\\":23,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\"function is_palindrome(str: [char; 20]) -> bool {\\\"}\"}": { + "annotations": [], + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Const", + "type_": null, + "value": { + "Value": { + "Integer": [ + "U32", + "20", + {} + ] + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"str_len\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":11,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" const str_len = 20u32; // saving const for convenience\\\"}\"}", + "mutable": false + } + ] + } + }, + { + "Definition": { + "declaration_type": "Let", + "type_": null, + "value": { + "Value": { + "Boolean": [ + "true", + {} + ] + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":12,\\\"line_stop\\\":12,\\\"col_start\\\":9,\\\"col_stop\\\":15,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" let result = true;\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Definition": { + "declaration_type": "Let", + "type_": null, + "value": { + "Value": { + "Integer": [ + "U8", + "0", + {} + ] + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"processed\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":9,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" let processed = 0u8;\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Iteration": { + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "type_": null, + "value": { + "ArrayAccess": { + "array": { + "Identifier": "{\"name\":\"str\",\"span\":\"{\\\"line_start\\\":16,\\\"line_stop\\\":16,\\\"col_start\\\":25,\\\"col_stop\\\":28,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" let start_sym = str[start];\\\"}\"}" + }, + "index": { + "Identifier": "{\"name\":\"start\",\"span\":\"{\\\"line_start\\\":16,\\\"line_stop\\\":16,\\\"col_start\\\":29,\\\"col_stop\\\":34,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" let start_sym = str[start];\\\"}\"}" + } + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"start_sym\",\"span\":\"{\\\"line_start\\\":16,\\\"line_stop\\\":16,\\\"col_start\\\":13,\\\"col_stop\\\":22,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" let start_sym = str[start];\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Conditional": { + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "type_": null, + "value": { + "Value": { + "Integer": [ + "U8", + "0", + {} + ] + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"skipped\",\"span\":\"{\\\"line_start\\\":18,\\\"line_stop\\\":18,\\\"col_start\\\":17,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" let skipped = 0u8;\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Definition": { + "declaration_type": "Let", + "type_": null, + "value": { + "Value": { + "Integer": [ + "U8", + "0", + {} + ] + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"end_empty\",\"span\":\"{\\\"line_start\\\":19,\\\"line_stop\\\":19,\\\"col_start\\\":17,\\\"col_stop\\\":26,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" let end_empty = 0u8;\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Definition": { + "declaration_type": "Let", + "type_": null, + "value": { + "Value": { + "Char": { + "character": { + "Scalar": 32 + } + } + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"end_sym\",\"span\":\"{\\\"line_start\\\":20,\\\"line_stop\\\":20,\\\"col_start\\\":17,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" let end_sym = ' ';\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Iteration": { + "block": { + "statements": [ + { + "Conditional": { + "block": { + "statements": [ + { + "Assign": { + "assignee": { + "accesses": [], + "identifier": "{\"name\":\"end_sym\",\"span\":\"{\\\"line_start\\\":24,\\\"line_stop\\\":24,\\\"col_start\\\":21,\\\"col_stop\\\":28,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" end_sym = str[end];\\\"}\"}" + }, + "operation": "Assign", + "value": { + "ArrayAccess": { + "array": { + "Identifier": "{\"name\":\"str\",\"span\":\"{\\\"line_start\\\":24,\\\"line_stop\\\":24,\\\"col_start\\\":31,\\\"col_stop\\\":34,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" end_sym = str[end];\\\"}\"}" + }, + "index": { + "Identifier": "{\"name\":\"end\",\"span\":\"{\\\"line_start\\\":24,\\\"line_stop\\\":24,\\\"col_start\\\":35,\\\"col_stop\\\":38,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" end_sym = str[end];\\\"}\"}" + } + } + } + } + } + ] + }, + "condition": { + "Binary": { + "left": { + "Binary": { + "left": { + "Binary": { + "left": { + "ArrayAccess": { + "array": { + "Identifier": "{\"name\":\"str\",\"span\":\"{\\\"line_start\\\":23,\\\"line_stop\\\":23,\\\"col_start\\\":20,\\\"col_stop\\\":23,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" if str[end] != ' ' && skipped == processed && end_sym == ' ' {\\\"}\"}" + }, + "index": { + "Identifier": "{\"name\":\"end\",\"span\":\"{\\\"line_start\\\":23,\\\"line_stop\\\":23,\\\"col_start\\\":24,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" if str[end] != ' ' && skipped == processed && end_sym == ' ' {\\\"}\"}" + } + } + }, + "op": "Ne", + "right": { + "Value": { + "Char": { + "character": { + "Scalar": 32 + } + } + } + } + } + }, + "op": "And", + "right": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"skipped\",\"span\":\"{\\\"line_start\\\":23,\\\"line_stop\\\":23,\\\"col_start\\\":39,\\\"col_stop\\\":46,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" if str[end] != ' ' && skipped == processed && end_sym == ' ' {\\\"}\"}" + }, + "op": "Eq", + "right": { + "Identifier": "{\"name\":\"processed\",\"span\":\"{\\\"line_start\\\":23,\\\"line_stop\\\":23,\\\"col_start\\\":50,\\\"col_stop\\\":59,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" if str[end] != ' ' && skipped == processed && end_sym == ' ' {\\\"}\"}" + } + } + } + } + }, + "op": "And", + "right": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"end_sym\",\"span\":\"{\\\"line_start\\\":23,\\\"line_stop\\\":23,\\\"col_start\\\":63,\\\"col_stop\\\":70,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" if str[end] != ' ' && skipped == processed && end_sym == ' ' {\\\"}\"}" + }, + "op": "Eq", + "right": { + "Value": { + "Char": { + "character": { + "Scalar": 32 + } + } + } + } + } + } + } + }, + "next": { + "Block": { + "statements": [ + { + "Assign": { + "assignee": { + "accesses": [], + "identifier": "{\"name\":\"end_empty\",\"span\":\"{\\\"line_start\\\":26,\\\"line_stop\\\":26,\\\"col_start\\\":21,\\\"col_stop\\\":30,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" end_empty = end_empty + 1;\\\"}\"}" + }, + "operation": "Assign", + "value": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"end_empty\",\"span\":\"{\\\"line_start\\\":26,\\\"line_stop\\\":26,\\\"col_start\\\":33,\\\"col_stop\\\":42,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" end_empty = end_empty + 1;\\\"}\"}" + }, + "op": "Add", + "right": { + "Value": { + "Implicit": [ + "1", + {} + ] + } + } + } + } + } + }, + { + "Conditional": { + "block": { + "statements": [ + { + "Assign": { + "assignee": { + "accesses": [], + "identifier": "{\"name\":\"skipped\",\"span\":\"{\\\"line_start\\\":28,\\\"line_stop\\\":28,\\\"col_start\\\":25,\\\"col_stop\\\":32,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" skipped = skipped + 1;\\\"}\"}" + }, + "operation": "Assign", + "value": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"skipped\",\"span\":\"{\\\"line_start\\\":28,\\\"line_stop\\\":28,\\\"col_start\\\":35,\\\"col_stop\\\":42,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" skipped = skipped + 1;\\\"}\"}" + }, + "op": "Add", + "right": { + "Value": { + "Implicit": [ + "1", + {} + ] + } + } + } + } + } + } + ] + }, + "condition": { + "Binary": { + "left": { + "ArrayAccess": { + "array": { + "Identifier": "{\"name\":\"str\",\"span\":\"{\\\"line_start\\\":27,\\\"line_stop\\\":27,\\\"col_start\\\":24,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" if str[end] != ' ' {\\\"}\"}" + }, + "index": { + "Identifier": "{\"name\":\"end\",\"span\":\"{\\\"line_start\\\":27,\\\"line_stop\\\":27,\\\"col_start\\\":28,\\\"col_stop\\\":31,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" if str[end] != ' ' {\\\"}\"}" + } + } + }, + "op": "Ne", + "right": { + "Value": { + "Char": { + "character": { + "Scalar": 32 + } + } + } + } + } + }, + "next": null + } + } + ] + } + } + } + } + ] + }, + "inclusive": false, + "start": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"str_len\",\"span\":\"{\\\"line_start\\\":22,\\\"line_stop\\\":22,\\\"col_start\\\":25,\\\"col_stop\\\":32,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" for end in (str_len - 1)..start {\\\"}\"}" + }, + "op": "Sub", + "right": { + "Value": { + "Implicit": [ + "1", + {} + ] + } + } + } + }, + "stop": { + "Identifier": "{\"name\":\"start\",\"span\":\"{\\\"line_start\\\":22,\\\"line_stop\\\":22,\\\"col_start\\\":39,\\\"col_stop\\\":44,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" for end in (str_len - 1)..start {\\\"}\"}" + }, + "variable": "{\"name\":\"end\",\"span\":\"{\\\"line_start\\\":22,\\\"line_stop\\\":22,\\\"col_start\\\":17,\\\"col_stop\\\":20,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" for end in (str_len - 1)..start {\\\"}\"}" + } + }, + { + "Conditional": { + "block": { + "statements": [ + { + "Console": { + "function": { + "Log": { + "parameters": [ + { + "Identifier": "{\"name\":\"start_sym\",\"span\":\"{\\\"line_start\\\":35,\\\"line_stop\\\":35,\\\"col_start\\\":51,\\\"col_stop\\\":60,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" console.log(\\\\\\\"Comparing: {} ? {}\\\\\\\", start_sym, end_sym);\\\"}\"}" + }, + { + "Identifier": "{\"name\":\"end_sym\",\"span\":\"{\\\"line_start\\\":35,\\\"line_stop\\\":35,\\\"col_start\\\":62,\\\"col_stop\\\":69,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" console.log(\\\\\\\"Comparing: {} ? {}\\\\\\\", start_sym, end_sym);\\\"}\"}" + } + ], + "string": [ + { + "Scalar": 67 + }, + { + "Scalar": 111 + }, + { + "Scalar": 109 + }, + { + "Scalar": 112 + }, + { + "Scalar": 97 + }, + { + "Scalar": 114 + }, + { + "Scalar": 105 + }, + { + "Scalar": 110 + }, + { + "Scalar": 103 + }, + { + "Scalar": 58 + }, + { + "Scalar": 32 + }, + { + "Scalar": 123 + }, + { + "Scalar": 125 + }, + { + "Scalar": 32 + }, + { + "Scalar": 63 + }, + { + "Scalar": 32 + }, + { + "Scalar": 123 + }, + { + "Scalar": 125 + } + ] + } + } + } + }, + { + "Conditional": { + "block": { + "statements": [ + { + "Assign": { + "assignee": { + "accesses": [], + "identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":38,\\\"line_stop\\\":38,\\\"col_start\\\":21,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" result = (start_sym == end_sym);\\\"}\"}" + }, + "operation": "Assign", + "value": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"start_sym\",\"span\":\"{\\\"line_start\\\":38,\\\"line_stop\\\":38,\\\"col_start\\\":31,\\\"col_stop\\\":40,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" result = (start_sym == end_sym);\\\"}\"}" + }, + "op": "Eq", + "right": { + "Identifier": "{\"name\":\"end_sym\",\"span\":\"{\\\"line_start\\\":38,\\\"line_stop\\\":38,\\\"col_start\\\":44,\\\"col_stop\\\":51,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" result = (start_sym == end_sym);\\\"}\"}" + } + } + } + } + } + ] + }, + "condition": { + "Identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":37,\\\"line_stop\\\":37,\\\"col_start\\\":20,\\\"col_stop\\\":26,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" if result {\\\"}\"}" + }, + "next": null + } + }, + { + "Assign": { + "assignee": { + "accesses": [], + "identifier": "{\"name\":\"processed\",\"span\":\"{\\\"line_start\\\":41,\\\"line_stop\\\":41,\\\"col_start\\\":17,\\\"col_stop\\\":26,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" processed = processed + 1;\\\"}\"}" + }, + "operation": "Assign", + "value": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"processed\",\"span\":\"{\\\"line_start\\\":41,\\\"line_stop\\\":41,\\\"col_start\\\":29,\\\"col_stop\\\":38,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" processed = processed + 1;\\\"}\"}" + }, + "op": "Add", + "right": { + "Value": { + "Implicit": [ + "1", + {} + ] + } + } + } + } + } + } + ] + }, + "condition": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"end_sym\",\"span\":\"{\\\"line_start\\\":34,\\\"line_stop\\\":34,\\\"col_start\\\":16,\\\"col_stop\\\":23,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" if end_sym != ' ' {\\\"}\"}" + }, + "op": "Ne", + "right": { + "Value": { + "Char": { + "character": { + "Scalar": 32 + } + } + } + } + } + }, + "next": null + } + } + ] + }, + "condition": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"start_sym\",\"span\":\"{\\\"line_start\\\":17,\\\"line_stop\\\":17,\\\"col_start\\\":12,\\\"col_stop\\\":21,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" if start_sym != ' ' {\\\"}\"}" + }, + "op": "Ne", + "right": { + "Value": { + "Char": { + "character": { + "Scalar": 32 + } + } + } + } + } + }, + "next": null + } + } + ] + }, + "inclusive": false, + "start": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + }, + "stop": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"str_len\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":22,\\\"col_stop\\\":29,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" for start in 0..(str_len / 2) {\\\"}\"}" + }, + "op": "Div", + "right": { + "Value": { + "Implicit": [ + "2", + {} + ] + } + } + } + }, + "variable": "{\"name\":\"start\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":9,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" for start in 0..(str_len / 2) {\\\"}\"}" + } + }, + { + "Console": { + "function": { + "Log": { + "parameters": [ + { + "Identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":46,\\\"line_stop\\\":46,\\\"col_start\\\":34,\\\"col_stop\\\":40,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" console.log(\\\\\\\"Result is: {}\\\\\\\", result);\\\"}\"}" + } + ], + "string": [ + { + "Scalar": 82 + }, + { + "Scalar": 101 + }, + { + "Scalar": 115 + }, + { + "Scalar": 117 + }, + { + "Scalar": 108 + }, + { + "Scalar": 116 + }, + { + "Scalar": 32 + }, + { + "Scalar": 105 + }, + { + "Scalar": 115 + }, + { + "Scalar": 58 + }, + { + "Scalar": 32 + }, + { + "Scalar": 123 + }, + { + "Scalar": 125 + } + ] + } + } + } + }, + { + "Return": { + "expression": { + "Identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":48,\\\"line_stop\\\":48,\\\"col_start\\\":12,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" return result;\\\"}\"}" + } + } + } + ] + }, + "identifier": "{\"name\":\"is_palindrome\",\"span\":\"{\\\"line_start\\\":8,\\\"line_stop\\\":8,\\\"col_start\\\":10,\\\"col_stop\\\":23,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\"function is_palindrome(str: [char; 20]) -> bool {\\\"}\"}", + "input": [ + { + "Variable": { + "const_": false, + "identifier": "{\"name\":\"str\",\"span\":\"{\\\"line_start\\\":8,\\\"line_stop\\\":8,\\\"col_start\\\":24,\\\"col_stop\\\":27,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\"function is_palindrome(str: [char; 20]) -> bool {\\\"}\"}", + "mutable": true, + "type_": { + "Array": [ + "Char", + [ + { + "value": "20" + } + ] + ] + } + } + } + ], + "output": "Boolean" + }, + "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\"function main(str: [char; 20]) -> bool {\\\"}\"}": { + "annotations": [], + "block": { + "statements": [ + { + "Return": { + "expression": { + "Call": { + "arguments": [ + { + "Identifier": "{\"name\":\"str\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":26,\\\"col_stop\\\":29,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" return is_palindrome(str);\\\"}\"}" + } + ], + "function": { + "Identifier": "{\"name\":\"is_palindrome\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":12,\\\"col_stop\\\":25,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" return is_palindrome(str);\\\"}\"}" + } + } + } + } + } + ] + }, + "identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\"function main(str: [char; 20]) -> bool {\\\"}\"}", + "input": [ + { + "Variable": { + "const_": false, + "identifier": "{\"name\":\"str\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":15,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\"function main(str: [char; 20]) -> bool {\\\"}\"}", + "mutable": true, + "type_": { + "Array": [ + "Char", + [ + { + "value": "20" + } + ] + ] + } + } + } + ], + "output": "Boolean" + }, + "{\"name\":\"test_is_palindrome\",\"span\":\"{\\\"line_start\\\":52,\\\"line_stop\\\":52,\\\"col_start\\\":10,\\\"col_stop\\\":28,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\"function test_is_palindrome() {\\\"}\"}": { + "annotations": [ + { + "arguments": [], + "name": "{\"name\":\"test\",\"span\":\"{\\\"line_start\\\":51,\\\"line_stop\\\":51,\\\"col_start\\\":2,\\\"col_stop\\\":6,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\"@test\\\"}\"}" + } + ], + "block": { + "statements": [ + { + "Console": { + "function": { + "Assert": { + "Call": { + "arguments": [ + { + "Value": { + "String": [ + [ + { + "Scalar": 97 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 98 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 97 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + } + ], + {} + ] + } + } + ], + "function": { + "Identifier": "{\"name\":\"is_palindrome\",\"span\":\"{\\\"line_start\\\":53,\\\"line_stop\\\":53,\\\"col_start\\\":20,\\\"col_stop\\\":33,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" console.assert(is_palindrome(\\\\\\\"a b a \\\\\\\"));\\\"}\"}" + } + } + } + } + } + }, + { + "Console": { + "function": { + "Assert": { + "Call": { + "arguments": [ + { + "Value": { + "String": [ + [ + { + "Scalar": 128512 + }, + { + "Scalar": 128512 + }, + { + "Scalar": 128512 + }, + { + "Scalar": 128512 + }, + { + "Scalar": 128512 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 128512 + }, + { + "Scalar": 128512 + }, + { + "Scalar": 128512 + }, + { + "Scalar": 128512 + }, + { + "Scalar": 128512 + } + ], + {} + ] + } + } + ], + "function": { + "Identifier": "{\"name\":\"is_palindrome\",\"span\":\"{\\\"line_start\\\":54,\\\"line_stop\\\":54,\\\"col_start\\\":20,\\\"col_stop\\\":33,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" console.assert(is_palindrome(\\\\\\\"😀😀😀😀😀 😀😀😀😀😀\\\\\\\"));\\\"}\"}" + } + } + } + } + } + }, + { + "Console": { + "function": { + "Assert": { + "Call": { + "arguments": [ + { + "Value": { + "String": [ + [ + { + "Scalar": 98 + }, + { + "Scalar": 111 + }, + { + "Scalar": 114 + }, + { + "Scalar": 114 + }, + { + "Scalar": 111 + }, + { + "Scalar": 119 + }, + { + "Scalar": 32 + }, + { + "Scalar": 111 + }, + { + "Scalar": 114 + }, + { + "Scalar": 32 + }, + { + "Scalar": 114 + }, + { + "Scalar": 111 + }, + { + "Scalar": 98 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + } + ], + {} + ] + } + } + ], + "function": { + "Identifier": "{\"name\":\"is_palindrome\",\"span\":\"{\\\"line_start\\\":55,\\\"line_stop\\\":55,\\\"col_start\\\":20,\\\"col_stop\\\":33,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" console.assert(is_palindrome(\\\\\\\"borrow or rob \\\\\\\"));\\\"}\"}" + } + } + } + } + } + }, + { + "Console": { + "function": { + "Assert": { + "Call": { + "arguments": [ + { + "Value": { + "String": [ + [ + { + "Scalar": 98 + }, + { + "Scalar": 98 + }, + { + "Scalar": 98 + }, + { + "Scalar": 98 + }, + { + "Scalar": 32 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 32 + }, + { + "Scalar": 98 + }, + { + "Scalar": 98 + }, + { + "Scalar": 98 + }, + { + "Scalar": 98 + } + ], + {} + ] + } + } + ], + "function": { + "Identifier": "{\"name\":\"is_palindrome\",\"span\":\"{\\\"line_start\\\":56,\\\"line_stop\\\":56,\\\"col_start\\\":20,\\\"col_stop\\\":33,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" console.assert(is_palindrome(\\\\\\\"bbbb aaaa aaaa bbbb\\\\\\\"));\\\"}\"}" + } + } + } + } + } + }, + { + "Console": { + "function": { + "Assert": { + "Call": { + "arguments": [ + { + "Value": { + "String": [ + [ + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + }, + { + "Scalar": 97 + } + ], + {} + ] + } + } + ], + "function": { + "Identifier": "{\"name\":\"is_palindrome\",\"span\":\"{\\\"line_start\\\":57,\\\"line_stop\\\":57,\\\"col_start\\\":20,\\\"col_stop\\\":33,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" console.assert(is_palindrome(\\\\\\\"aaaaaaaaaaaaaaaaaaaa\\\\\\\"));\\\"}\"}" + } + } + } + } + } + }, + { + "Console": { + "function": { + "Assert": { + "Call": { + "arguments": [ + { + "Value": { + "String": [ + [ + { + "Scalar": 116 + }, + { + "Scalar": 97 + }, + { + "Scalar": 99 + }, + { + "Scalar": 111 + }, + { + "Scalar": 32 + }, + { + "Scalar": 99 + }, + { + "Scalar": 97 + }, + { + "Scalar": 116 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + }, + { + "Scalar": 32 + } + ], + {} + ] + } + } + ], + "function": { + "Identifier": "{\"name\":\"is_palindrome\",\"span\":\"{\\\"line_start\\\":58,\\\"line_stop\\\":58,\\\"col_start\\\":20,\\\"col_stop\\\":33,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\" console.assert(is_palindrome(\\\\\\\"taco cat \\\\\\\"));\\\"}\"}" + } + } + } + } + } + } + ] + }, + "identifier": "{\"name\":\"test_is_palindrome\",\"span\":\"{\\\"line_start\\\":52,\\\"line_stop\\\":52,\\\"col_start\\\":10,\\\"col_stop\\\":28,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/palindrome/src/main.leo\\\",\\\"content\\\":\\\"function test_is_palindrome() {\\\"}\"}", + "input": [], + "output": null + } + }, + "global_consts": {}, + "import_statements": [], + "imports": {}, + "name": "" +} \ No newline at end of file diff --git a/parser/tests/serialization/expected_leo_ast/pedersen_hash.json b/parser/tests/serialization/expected_leo_ast/pedersen_hash.json new file mode 100644 index 0000000000..8545f93981 --- /dev/null +++ b/parser/tests/serialization/expected_leo_ast/pedersen_hash.json @@ -0,0 +1,308 @@ +{ + "aliases": {}, + "circuits": { + "{\"name\":\"PedersenHash\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":21,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\"circuit PedersenHash {\\\"}\"}": { + "circuit_name": "{\"name\":\"PedersenHash\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":21,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\"circuit PedersenHash {\\\"}\"}", + "core_mapping": null, + "members": [ + { + "CircuitVariable": [ + "{\"name\":\"parameters\",\"span\":\"{\\\"line_start\\\":2,\\\"line_stop\\\":2,\\\"col_start\\\":5,\\\"col_stop\\\":15,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" parameters: [group; 256];\\\"}\"}", + { + "Array": [ + "Group", + [ + { + "value": "256" + } + ] + ] + } + ] + }, + { + "CircuitFunction": { + "annotations": [], + "block": { + "statements": [ + { + "Return": { + "expression": { + "CircuitInit": { + "members": [ + { + "expression": { + "Identifier": "{\"name\":\"parameters\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":35,\\\"col_stop\\\":45,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" return Self { parameters: parameters };\\\"}\"}" + }, + "identifier": "{\"name\":\"parameters\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":23,\\\"col_stop\\\":33,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" return Self { parameters: parameters };\\\"}\"}" + } + ], + "name": "{\"name\":\"Self\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":16,\\\"col_stop\\\":20,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" return Self { parameters: parameters };\\\"}\"}" + } + } + } + } + ] + }, + "identifier": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":14,\\\"col_stop\\\":17,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" function new(parameters: [group; 256]) -> Self {\\\"}\"}", + "input": [ + { + "Variable": { + "const_": false, + "identifier": "{\"name\":\"parameters\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":18,\\\"col_stop\\\":28,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" function new(parameters: [group; 256]) -> Self {\\\"}\"}", + "mutable": true, + "type_": { + "Array": [ + "Group", + [ + { + "value": "256" + } + ] + ] + } + } + } + ], + "output": "SelfType" + } + }, + { + "CircuitFunction": { + "annotations": [], + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "type_": "Group", + "value": { + "Value": { + "Group": { + "Single": [ + "0", + {} + ] + } + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"digest\",\"span\":\"{\\\"line_start\\\":10,\\\"line_stop\\\":10,\\\"col_start\\\":13,\\\"col_stop\\\":19,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" let digest: group = 0group;\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Iteration": { + "block": { + "statements": [ + { + "Conditional": { + "block": { + "statements": [ + { + "Assign": { + "assignee": { + "accesses": [], + "identifier": "{\"name\":\"digest\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":17,\\\"col_stop\\\":23,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" digest += self.parameters[i];\\\"}\"}" + }, + "operation": "Add", + "value": { + "ArrayAccess": { + "array": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":27,\\\"col_stop\\\":31,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" digest += self.parameters[i];\\\"}\"}" + }, + "name": "{\"name\":\"parameters\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":32,\\\"col_stop\\\":42,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" digest += self.parameters[i];\\\"}\"}", + "type_": null + } + }, + "index": { + "Identifier": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":43,\\\"col_stop\\\":44,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" digest += self.parameters[i];\\\"}\"}" + } + } + } + } + } + ] + }, + "condition": { + "ArrayAccess": { + "array": { + "Identifier": "{\"name\":\"bits\",\"span\":\"{\\\"line_start\\\":12,\\\"line_stop\\\":12,\\\"col_start\\\":16,\\\"col_stop\\\":20,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" if bits[i] {\\\"}\"}" + }, + "index": { + "Identifier": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":12,\\\"line_stop\\\":12,\\\"col_start\\\":21,\\\"col_stop\\\":22,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" if bits[i] {\\\"}\"}" + } + } + }, + "next": null + } + } + ] + }, + "inclusive": false, + "start": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + }, + "stop": { + "Value": { + "Implicit": [ + "256", + {} + ] + } + }, + "variable": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":11,\\\"line_stop\\\":11,\\\"col_start\\\":13,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" for i in 0..256 {\\\"}\"}" + } + }, + { + "Return": { + "expression": { + "Identifier": "{\"name\":\"digest\",\"span\":\"{\\\"line_start\\\":16,\\\"line_stop\\\":16,\\\"col_start\\\":16,\\\"col_stop\\\":22,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" return digest;\\\"}\"}" + } + } + } + ] + }, + "identifier": "{\"name\":\"hash\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":14,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" function hash(self, bits: [bool; 256]) -> group {\\\"}\"}", + "input": [ + { + "SelfKeyword": "{\"name\":\"self\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":19,\\\"col_stop\\\":23,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" function hash(self, bits: [bool; 256]) -> group {\\\"}\"}" + }, + { + "Variable": { + "const_": false, + "identifier": "{\"name\":\"bits\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":25,\\\"col_stop\\\":29,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" function hash(self, bits: [bool; 256]) -> group {\\\"}\"}", + "mutable": true, + "type_": { + "Array": [ + "Boolean", + [ + { + "value": "256" + } + ] + ] + } + } + } + ], + "output": "Group" + } + } + ] + } + }, + "expected_input": [], + "functions": { + "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":21,\\\"line_stop\\\":21,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\"function main(hash_input: [bool; 256], const parameters: [group; 256]) -> group {\\\"}\"}": { + "annotations": [], + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Const", + "type_": null, + "value": { + "Call": { + "arguments": [ + { + "Identifier": "{\"name\":\"parameters\",\"span\":\"{\\\"line_start\\\":22,\\\"line_stop\\\":22,\\\"col_start\\\":40,\\\"col_stop\\\":50,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" const pedersen = PedersenHash::new(parameters);\\\"}\"}" + } + ], + "function": { + "CircuitStaticFunctionAccess": { + "circuit": { + "Identifier": "{\"name\":\"PedersenHash\",\"span\":\"{\\\"line_start\\\":22,\\\"line_stop\\\":22,\\\"col_start\\\":22,\\\"col_stop\\\":34,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" const pedersen = PedersenHash::new(parameters);\\\"}\"}" + }, + "name": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":22,\\\"line_stop\\\":22,\\\"col_start\\\":36,\\\"col_stop\\\":39,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" const pedersen = PedersenHash::new(parameters);\\\"}\"}" + } + } + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"pedersen\",\"span\":\"{\\\"line_start\\\":22,\\\"line_stop\\\":22,\\\"col_start\\\":11,\\\"col_stop\\\":19,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" const pedersen = PedersenHash::new(parameters);\\\"}\"}", + "mutable": false + } + ] + } + }, + { + "Return": { + "expression": { + "Call": { + "arguments": [ + { + "Identifier": "{\"name\":\"hash_input\",\"span\":\"{\\\"line_start\\\":23,\\\"line_stop\\\":23,\\\"col_start\\\":26,\\\"col_stop\\\":36,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" return pedersen.hash(hash_input);\\\"}\"}" + } + ], + "function": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"pedersen\",\"span\":\"{\\\"line_start\\\":23,\\\"line_stop\\\":23,\\\"col_start\\\":12,\\\"col_stop\\\":20,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" return pedersen.hash(hash_input);\\\"}\"}" + }, + "name": "{\"name\":\"hash\",\"span\":\"{\\\"line_start\\\":23,\\\"line_stop\\\":23,\\\"col_start\\\":21,\\\"col_stop\\\":25,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\" return pedersen.hash(hash_input);\\\"}\"}", + "type_": null + } + } + } + } + } + } + ] + }, + "identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":21,\\\"line_stop\\\":21,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\"function main(hash_input: [bool; 256], const parameters: [group; 256]) -> group {\\\"}\"}", + "input": [ + { + "Variable": { + "const_": false, + "identifier": "{\"name\":\"hash_input\",\"span\":\"{\\\"line_start\\\":21,\\\"line_stop\\\":21,\\\"col_start\\\":15,\\\"col_stop\\\":25,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\"function main(hash_input: [bool; 256], const parameters: [group; 256]) -> group {\\\"}\"}", + "mutable": true, + "type_": { + "Array": [ + "Boolean", + [ + { + "value": "256" + } + ] + ] + } + } + }, + { + "Variable": { + "const_": true, + "identifier": "{\"name\":\"parameters\",\"span\":\"{\\\"line_start\\\":21,\\\"line_stop\\\":21,\\\"col_start\\\":46,\\\"col_stop\\\":56,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/pedersen-hash/src/main.leo\\\",\\\"content\\\":\\\"function main(hash_input: [bool; 256], const parameters: [group; 256]) -> group {\\\"}\"}", + "mutable": false, + "type_": { + "Array": [ + "Group", + [ + { + "value": "256" + } + ] + ] + } + } + } + ], + "output": "Group" + } + }, + "global_consts": {}, + "import_statements": [], + "imports": {}, + "name": "" +} \ No newline at end of file diff --git a/parser/tests/serialization/expected_leo_ast/silly_sudoku.json b/parser/tests/serialization/expected_leo_ast/silly_sudoku.json new file mode 100644 index 0000000000..b3addc0ba6 --- /dev/null +++ b/parser/tests/serialization/expected_leo_ast/silly_sudoku.json @@ -0,0 +1,1323 @@ +{ + "aliases": {}, + "circuits": {}, + "expected_input": [], + "functions": { + "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"function main(puzzle: [u8; (3, 3)], answer: [u8; (3, 3)]) -> bool {\\\"}\"}": { + "annotations": [], + "block": { + "statements": [ + { + "Console": { + "function": { + "Log": { + "parameters": [], + "string": [ + { + "Scalar": 83 + }, + { + "Scalar": 116 + }, + { + "Scalar": 97 + }, + { + "Scalar": 114 + }, + { + "Scalar": 116 + }, + { + "Scalar": 105 + }, + { + "Scalar": 110 + }, + { + "Scalar": 103 + }, + { + "Scalar": 32 + }, + { + "Scalar": 83 + }, + { + "Scalar": 117 + }, + { + "Scalar": 100 + }, + { + "Scalar": 111 + }, + { + "Scalar": 107 + }, + { + "Scalar": 117 + }, + { + "Scalar": 32 + }, + { + "Scalar": 115 + }, + { + "Scalar": 111 + }, + { + "Scalar": 108 + }, + { + "Scalar": 118 + }, + { + "Scalar": 101 + }, + { + "Scalar": 114 + }, + { + "Scalar": 46 + }, + { + "Scalar": 46 + }, + { + "Scalar": 46 + } + ] + } + } + } + }, + { + "Console": { + "function": { + "Log": { + "parameters": [ + { + "Identifier": "{\"name\":\"puzzle\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":23,\\\"col_stop\\\":29,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" console.log(\\\\\\\"{}\\\\\\\", puzzle);\\\"}\"}" + } + ], + "string": [ + { + "Scalar": 123 + }, + { + "Scalar": 125 + } + ] + } + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "type_": null, + "value": { + "CircuitInit": { + "members": [ + { + "expression": { + "Identifier": "{\"name\":\"puzzle\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":45,\\\"col_stop\\\":51,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let sudoku = SillySudoku { puzzle_grid: puzzle };\\\"}\"}" + }, + "identifier": "{\"name\":\"puzzle_grid\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":32,\\\"col_stop\\\":43,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let sudoku = SillySudoku { puzzle_grid: puzzle };\\\"}\"}" + } + ], + "name": "{\"name\":\"SillySudoku\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":18,\\\"col_stop\\\":29,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let sudoku = SillySudoku { puzzle_grid: puzzle };\\\"}\"}" + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"sudoku\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":9,\\\"col_stop\\\":15,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let sudoku = SillySudoku { puzzle_grid: puzzle };\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Console": { + "function": { + "Log": { + "parameters": [], + "string": [ + { + "Scalar": 67 + }, + { + "Scalar": 104 + }, + { + "Scalar": 101 + }, + { + "Scalar": 99 + }, + { + "Scalar": 107 + }, + { + "Scalar": 105 + }, + { + "Scalar": 110 + }, + { + "Scalar": 103 + }, + { + "Scalar": 32 + }, + { + "Scalar": 83 + }, + { + "Scalar": 117 + }, + { + "Scalar": 100 + }, + { + "Scalar": 111 + }, + { + "Scalar": 107 + }, + { + "Scalar": 117 + }, + { + "Scalar": 32 + }, + { + "Scalar": 97 + }, + { + "Scalar": 110 + }, + { + "Scalar": 115 + }, + { + "Scalar": 119 + }, + { + "Scalar": 101 + }, + { + "Scalar": 114 + }, + { + "Scalar": 46 + }, + { + "Scalar": 46 + }, + { + "Scalar": 46 + } + ] + } + } + } + }, + { + "Console": { + "function": { + "Log": { + "parameters": [ + { + "Identifier": "{\"name\":\"answer\",\"span\":\"{\\\"line_start\\\":12,\\\"line_stop\\\":12,\\\"col_start\\\":23,\\\"col_stop\\\":29,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" console.log(\\\\\\\"{}\\\\\\\", answer);\\\"}\"}" + } + ], + "string": [ + { + "Scalar": 123 + }, + { + "Scalar": 125 + } + ] + } + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "type_": null, + "value": { + "Call": { + "arguments": [ + { + "Identifier": "{\"name\":\"answer\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":31,\\\"col_stop\\\":37,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = sudoku.solve(answer);\\\"}\"}" + } + ], + "function": { + "CircuitMemberAccess": { + "circuit": { + "Identifier": "{\"name\":\"sudoku\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":18,\\\"col_stop\\\":24,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = sudoku.solve(answer);\\\"}\"}" + }, + "name": "{\"name\":\"solve\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":25,\\\"col_stop\\\":30,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = sudoku.solve(answer);\\\"}\"}", + "type_": null + } + } + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":9,\\\"col_stop\\\":15,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = sudoku.solve(answer);\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Console": { + "function": { + "Log": { + "parameters": [ + { + "Identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":17,\\\"line_stop\\\":17,\\\"col_start\\\":38,\\\"col_stop\\\":44,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" console.log(\\\\\\\"The answer is {}.\\\\\\\", result);\\\"}\"}" + } + ], + "string": [ + { + "Scalar": 84 + }, + { + "Scalar": 104 + }, + { + "Scalar": 101 + }, + { + "Scalar": 32 + }, + { + "Scalar": 97 + }, + { + "Scalar": 110 + }, + { + "Scalar": 115 + }, + { + "Scalar": 119 + }, + { + "Scalar": 101 + }, + { + "Scalar": 114 + }, + { + "Scalar": 32 + }, + { + "Scalar": 105 + }, + { + "Scalar": 115 + }, + { + "Scalar": 32 + }, + { + "Scalar": 123 + }, + { + "Scalar": 125 + }, + { + "Scalar": 46 + } + ] + } + } + } + }, + { + "Return": { + "expression": { + "Identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":19,\\\"line_stop\\\":19,\\\"col_start\\\":12,\\\"col_stop\\\":18,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" return result;\\\"}\"}" + } + } + } + ] + }, + "identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"function main(puzzle: [u8; (3, 3)], answer: [u8; (3, 3)]) -> bool {\\\"}\"}", + "input": [ + { + "Variable": { + "const_": false, + "identifier": "{\"name\":\"puzzle\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":15,\\\"col_stop\\\":21,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"function main(puzzle: [u8; (3, 3)], answer: [u8; (3, 3)]) -> bool {\\\"}\"}", + "mutable": true, + "type_": { + "Array": [ + { + "IntegerType": "U8" + }, + [ + { + "value": "3" + }, + { + "value": "3" + } + ] + ] + } + } + }, + { + "Variable": { + "const_": false, + "identifier": "{\"name\":\"answer\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":37,\\\"col_stop\\\":43,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"function main(puzzle: [u8; (3, 3)], answer: [u8; (3, 3)]) -> bool {\\\"}\"}", + "mutable": true, + "type_": { + "Array": [ + { + "IntegerType": "U8" + }, + [ + { + "value": "3" + }, + { + "value": "3" + } + ] + ] + } + } + } + ], + "output": "Boolean" + }, + "{\"name\":\"test_solve_fail\",\"span\":\"{\\\"line_start\\\":42,\\\"line_stop\\\":42,\\\"col_start\\\":10,\\\"col_stop\\\":25,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"function test_solve_fail() {\\\"}\"}": { + "annotations": [ + { + "arguments": [], + "name": "{\"name\":\"test\",\"span\":\"{\\\"line_start\\\":41,\\\"line_stop\\\":41,\\\"col_start\\\":2,\\\"col_stop\\\":6,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"@test\\\"}\"}" + } + ], + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "type_": { + "Array": [ + { + "IntegerType": "U8" + }, + [ + { + "value": "3" + }, + { + "value": "3" + } + ] + ] + }, + "value": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "2", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + } + } + ] + } + } + }, + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "6", + {} + ] + } + } + } + ] + } + } + }, + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "8", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + } + } + ] + } + } + } + ] + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"puzzle\",\"span\":\"{\\\"line_start\\\":43,\\\"line_stop\\\":43,\\\"col_start\\\":9,\\\"col_stop\\\":15,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let puzzle: [u8; (3, 3)] = [[0, 2, 0],\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Definition": { + "declaration_type": "Let", + "type_": { + "Array": [ + { + "IntegerType": "U8" + }, + [ + { + "value": "3" + }, + { + "value": "3" + } + ] + ] + }, + "value": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "1", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "2", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "3", + {} + ] + } + } + } + ] + } + } + }, + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "4", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "5", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "6", + {} + ] + } + } + } + ] + } + } + }, + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "7", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "8", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "8", + {} + ] + } + } + } + ] + } + } + } + ] + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"answer\",\"span\":\"{\\\"line_start\\\":47,\\\"line_stop\\\":47,\\\"col_start\\\":9,\\\"col_stop\\\":15,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let answer: [u8; (3, 3)] = [[1, 2, 3],\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Definition": { + "declaration_type": "Let", + "type_": null, + "value": { + "Call": { + "arguments": [ + { + "Identifier": "{\"name\":\"puzzle\",\"span\":\"{\\\"line_start\\\":52,\\\"line_stop\\\":52,\\\"col_start\\\":23,\\\"col_stop\\\":29,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}" + }, + { + "Identifier": "{\"name\":\"answer\",\"span\":\"{\\\"line_start\\\":52,\\\"line_stop\\\":52,\\\"col_start\\\":31,\\\"col_stop\\\":37,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}" + } + ], + "function": { + "Identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":52,\\\"line_stop\\\":52,\\\"col_start\\\":18,\\\"col_stop\\\":22,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}" + } + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":52,\\\"line_stop\\\":52,\\\"col_start\\\":9,\\\"col_stop\\\":15,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Console": { + "function": { + "Assert": { + "Binary": { + "left": { + "Value": { + "Boolean": [ + "false", + {} + ] + } + }, + "op": "Eq", + "right": { + "Identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":55,\\\"line_stop\\\":55,\\\"col_start\\\":29,\\\"col_stop\\\":35,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" console.assert(false == result);\\\"}\"}" + } + } + } + } + } + } + ] + }, + "identifier": "{\"name\":\"test_solve_fail\",\"span\":\"{\\\"line_start\\\":42,\\\"line_stop\\\":42,\\\"col_start\\\":10,\\\"col_stop\\\":25,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"function test_solve_fail() {\\\"}\"}", + "input": [], + "output": null + }, + "{\"name\":\"test_solve_pass\",\"span\":\"{\\\"line_start\\\":24,\\\"line_stop\\\":24,\\\"col_start\\\":10,\\\"col_stop\\\":25,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"function test_solve_pass() {\\\"}\"}": { + "annotations": [ + { + "arguments": [], + "name": "{\"name\":\"test\",\"span\":\"{\\\"line_start\\\":23,\\\"line_stop\\\":23,\\\"col_start\\\":2,\\\"col_stop\\\":6,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"@test\\\"}\"}" + } + ], + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "type_": { + "Array": [ + { + "IntegerType": "U8" + }, + [ + { + "value": "3" + }, + { + "value": "3" + } + ] + ] + }, + "value": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "2", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + } + } + ] + } + } + }, + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "6", + {} + ] + } + } + } + ] + } + } + }, + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "0", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "8", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "9", + {} + ] + } + } + } + ] + } + } + } + ] + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"puzzle\",\"span\":\"{\\\"line_start\\\":25,\\\"line_stop\\\":25,\\\"col_start\\\":9,\\\"col_stop\\\":15,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let puzzle: [u8; (3, 3)] = [[0, 2, 0],\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Definition": { + "declaration_type": "Let", + "type_": { + "Array": [ + { + "IntegerType": "U8" + }, + [ + { + "value": "3" + }, + { + "value": "3" + } + ] + ] + }, + "value": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "1", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "2", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "3", + {} + ] + } + } + } + ] + } + } + }, + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "4", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "5", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "6", + {} + ] + } + } + } + ] + } + } + }, + { + "Expression": { + "ArrayInline": { + "elements": [ + { + "Expression": { + "Value": { + "Implicit": [ + "7", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "8", + {} + ] + } + } + }, + { + "Expression": { + "Value": { + "Implicit": [ + "9", + {} + ] + } + } + } + ] + } + } + } + ] + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"answer\",\"span\":\"{\\\"line_start\\\":29,\\\"line_stop\\\":29,\\\"col_start\\\":9,\\\"col_stop\\\":15,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let answer: [u8; (3, 3)] = [[1, 2, 3],\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Definition": { + "declaration_type": "Let", + "type_": null, + "value": { + "Call": { + "arguments": [ + { + "Identifier": "{\"name\":\"puzzle\",\"span\":\"{\\\"line_start\\\":34,\\\"line_stop\\\":34,\\\"col_start\\\":23,\\\"col_stop\\\":29,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}" + }, + { + "Identifier": "{\"name\":\"answer\",\"span\":\"{\\\"line_start\\\":34,\\\"line_stop\\\":34,\\\"col_start\\\":31,\\\"col_stop\\\":37,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}" + } + ], + "function": { + "Identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":34,\\\"line_stop\\\":34,\\\"col_start\\\":18,\\\"col_stop\\\":22,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}" + } + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":34,\\\"line_stop\\\":34,\\\"col_start\\\":9,\\\"col_stop\\\":15,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Console": { + "function": { + "Assert": { + "Binary": { + "left": { + "Value": { + "Boolean": [ + "true", + {} + ] + } + }, + "op": "Eq", + "right": { + "Identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":37,\\\"line_stop\\\":37,\\\"col_start\\\":28,\\\"col_stop\\\":34,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" console.assert(true == result);\\\"}\"}" + } + } + } + } + } + } + ] + }, + "identifier": "{\"name\":\"test_solve_pass\",\"span\":\"{\\\"line_start\\\":24,\\\"line_stop\\\":24,\\\"col_start\\\":10,\\\"col_stop\\\":25,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"function test_solve_pass() {\\\"}\"}", + "input": [], + "output": null + }, + "{\"name\":\"test_solve_with_input\",\"span\":\"{\\\"line_start\\\":60,\\\"line_stop\\\":60,\\\"col_start\\\":10,\\\"col_stop\\\":31,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"function test_solve_with_input(\\\"}\"}": { + "annotations": [ + { + "arguments": [ + "test_input" + ], + "name": "{\"name\":\"test\",\"span\":\"{\\\"line_start\\\":59,\\\"line_stop\\\":59,\\\"col_start\\\":2,\\\"col_stop\\\":6,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"@test(test_input)\\\"}\"}" + } + ], + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "type_": null, + "value": { + "Call": { + "arguments": [ + { + "Identifier": "{\"name\":\"puzzle\",\"span\":\"{\\\"line_start\\\":66,\\\"line_stop\\\":66,\\\"col_start\\\":23,\\\"col_stop\\\":29,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}" + }, + { + "Identifier": "{\"name\":\"answer\",\"span\":\"{\\\"line_start\\\":66,\\\"line_stop\\\":66,\\\"col_start\\\":31,\\\"col_stop\\\":37,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}" + } + ], + "function": { + "Identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":66,\\\"line_stop\\\":66,\\\"col_start\\\":18,\\\"col_stop\\\":22,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}" + } + } + }, + "variable_names": [ + { + "identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":66,\\\"line_stop\\\":66,\\\"col_start\\\":9,\\\"col_stop\\\":15,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" let result = main(puzzle, answer);\\\"}\"}", + "mutable": true + } + ] + } + }, + { + "Console": { + "function": { + "Log": { + "parameters": [ + { + "Identifier": "{\"name\":\"expected\",\"span\":\"{\\\"line_start\\\":68,\\\"line_stop\\\":68,\\\"col_start\\\":40,\\\"col_stop\\\":48,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" console.log(\\\\\\\"expected {}, got {}\\\\\\\", expected, result);\\\"}\"}" + }, + { + "Identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":68,\\\"line_stop\\\":68,\\\"col_start\\\":50,\\\"col_stop\\\":56,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" console.log(\\\\\\\"expected {}, got {}\\\\\\\", expected, result);\\\"}\"}" + } + ], + "string": [ + { + "Scalar": 101 + }, + { + "Scalar": 120 + }, + { + "Scalar": 112 + }, + { + "Scalar": 101 + }, + { + "Scalar": 99 + }, + { + "Scalar": 116 + }, + { + "Scalar": 101 + }, + { + "Scalar": 100 + }, + { + "Scalar": 32 + }, + { + "Scalar": 123 + }, + { + "Scalar": 125 + }, + { + "Scalar": 44 + }, + { + "Scalar": 32 + }, + { + "Scalar": 103 + }, + { + "Scalar": 111 + }, + { + "Scalar": 116 + }, + { + "Scalar": 32 + }, + { + "Scalar": 123 + }, + { + "Scalar": 125 + } + ] + } + } + } + }, + { + "Console": { + "function": { + "Assert": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"expected\",\"span\":\"{\\\"line_start\\\":70,\\\"line_stop\\\":70,\\\"col_start\\\":20,\\\"col_stop\\\":28,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" console.assert(expected == result);\\\"}\"}" + }, + "op": "Eq", + "right": { + "Identifier": "{\"name\":\"result\",\"span\":\"{\\\"line_start\\\":70,\\\"line_stop\\\":70,\\\"col_start\\\":32,\\\"col_stop\\\":38,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" console.assert(expected == result);\\\"}\"}" + } + } + } + } + } + } + ] + }, + "identifier": "{\"name\":\"test_solve_with_input\",\"span\":\"{\\\"line_start\\\":60,\\\"line_stop\\\":60,\\\"col_start\\\":10,\\\"col_stop\\\":31,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"function test_solve_with_input(\\\"}\"}", + "input": [ + { + "Variable": { + "const_": false, + "identifier": "{\"name\":\"puzzle\",\"span\":\"{\\\"line_start\\\":61,\\\"line_stop\\\":61,\\\"col_start\\\":5,\\\"col_stop\\\":11,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" puzzle: [u8; (3, 3)],\\\"}\"}", + "mutable": true, + "type_": { + "Array": [ + { + "IntegerType": "U8" + }, + [ + { + "value": "3" + }, + { + "value": "3" + } + ] + ] + } + } + }, + { + "Variable": { + "const_": false, + "identifier": "{\"name\":\"answer\",\"span\":\"{\\\"line_start\\\":62,\\\"line_stop\\\":62,\\\"col_start\\\":5,\\\"col_stop\\\":11,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" answer: [u8; (3, 3)],\\\"}\"}", + "mutable": true, + "type_": { + "Array": [ + { + "IntegerType": "U8" + }, + [ + { + "value": "3" + }, + { + "value": "3" + } + ] + ] + } + } + }, + { + "Variable": { + "const_": false, + "identifier": "{\"name\":\"expected\",\"span\":\"{\\\"line_start\\\":63,\\\"line_stop\\\":63,\\\"col_start\\\":5,\\\"col_stop\\\":13,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\" expected: bool\\\"}\"}", + "mutable": true, + "type_": "Boolean" + } + } + ], + "output": null + } + }, + "global_consts": {}, + "import_statements": [ + { + "package_or_packages": { + "Package": { + "access": { + "Symbol": { + "alias": null, + "symbol": "{\"name\":\"SillySudoku\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":12,\\\"col_stop\\\":23,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"import lib.SillySudoku;\\\"}\"}" + } + }, + "name": "{\"name\":\"lib\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":8,\\\"col_stop\\\":11,\\\"path\\\":\\\"/Users/pranav/work/Aleo/leo/examples/silly-sudoku/src/main.leo\\\",\\\"content\\\":\\\"import lib.SillySudoku;\\\"}\"}" + } + } + } + ], + "imports": {}, + "name": "" +} \ No newline at end of file diff --git a/parser/tests/serialization/json.rs b/parser/tests/serialization/json.rs index c640f881ce..eff7e90bc1 100644 --- a/parser/tests/serialization/json.rs +++ b/parser/tests/serialization/json.rs @@ -19,6 +19,9 @@ use leo_ast::Ast; use leo_ast::Program; use leo_errors::{LeoError, Result}; +use std::fs::File; +use std::io::BufReader; +use std::iter::Iterator; use std::path::{Path, PathBuf}; fn to_ast(program_filepath: &Path) -> Result { @@ -44,7 +47,7 @@ fn test_serialize() { // Construct an ast from the given test file. let ast = { let mut program_filepath = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - program_filepath.push("tests/serialization/main.leo"); + program_filepath.push("tests/serialization/leo/one_plus_one.leo"); to_ast(&program_filepath).unwrap() }; @@ -53,12 +56,58 @@ fn test_serialize() { let serialized_ast: Program = serde_json::from_value(serde_json::to_value(ast.as_repr()).unwrap()).unwrap(); // Load the expected ast. - let expected: Program = serde_json::from_str(include_str!("expected_leo_ast.json")).unwrap(); + let expected: Program = serde_json::from_str(include_str!("./expected_leo_ast/one_plus_one.json")).unwrap(); clean(); assert_eq!(expected, serialized_ast); } +#[test] +#[cfg(not(feature = "ci_skip"))] +fn serialize_no_span() { + setup(); + + let program_paths = vec![ + "tests/serialization/leo/linear_regression.leo", + "tests/serialization/leo/palindrome.leo", + "tests/serialization/leo/pedersen_hash.leo", + "tests/serialization/leo/silly_sudoku.leo", + ]; + + let json_paths = vec![ + "./expected_leo_ast/linear_regression.json", + "./expected_leo_ast/palindrome.json", + "./expected_leo_ast/pedersen_hash.json", + "./expected_leo_ast/silly_sudoku.json", + ]; + + for (program_path, json_path) in program_paths.into_iter().zip(json_paths) { + // Construct an ast from the given test file. + let ast = { + let mut program_filepath = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + program_filepath.push(program_path); + to_ast(&program_filepath).unwrap() + }; + + let json_reader = { + let mut json_filepath = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + json_filepath.push(json_path); + let file = File::open(json_filepath).expect("Failed to read expected ast file"); + BufReader::new(file) + }; + + // Serializes the ast into JSON format. + let serialized_ast: serde_json::Value = + serde_json::from_value(serde_json::to_value(ast.as_repr()).unwrap()).unwrap(); + + // Load the expected ast. + let expected: serde_json::Value = serde_json::from_reader(json_reader).unwrap(); + + assert_eq!(expected, serialized_ast); + } + clean(); +} + // TODO Renable when we don't write spans to snapshots. /* #[test] #[cfg(not(feature = "ci_skip"))] @@ -112,7 +161,7 @@ fn test_generic_parser_error() { let error_result = { let mut program_filepath = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - program_filepath.push("tests/serialization/parser_error.leo"); + program_filepath.push("tests/serialization/leo/parser_error.leo"); to_ast(&program_filepath) } diff --git a/parser/tests/serialization/deprecated_error.leo b/parser/tests/serialization/leo/deprecated_error.leo similarity index 100% rename from parser/tests/serialization/deprecated_error.leo rename to parser/tests/serialization/leo/deprecated_error.leo diff --git a/parser/tests/serialization/leo/linear_regression.leo b/parser/tests/serialization/leo/linear_regression.leo new file mode 100644 index 0000000000..51dc4dd908 --- /dev/null +++ b/parser/tests/serialization/leo/linear_regression.leo @@ -0,0 +1,65 @@ +circuit Point { + x: i32, + y: i32, + + function new(x: i32, y: i32) -> Self { + return Self { x, y }; + } +} + +circuit LinearRegression { + points: [Point; 5], + + // Instantiates a linear regression circuit. + function new(points: [Point; 5]) -> Self { + return Self { points }; + } + + // Return the slope of the linear regression. + function slope(self) -> i32 { + + let num_points = 5i32; + // Calculate the sums. + let x_sum = 0i32; + let y_sum = 0i32; + let xy_sum = 0i32; + let x2_sum = 0i32; + for i in 0..5 { + x_sum += self.points[i].x; + y_sum += self.points[i].y; + xy_sum += self.points[i].x * self.points[i].y; + x2_sum += self.points[i].x * self.points[i].x; + } + let numerator = (num_points * xy_sum) - (x_sum * y_sum); + let denominator = (num_points * x2_sum) - (x_sum * x_sum); + let slope = numerator / denominator; + return slope; + } + // Return the offset of the linear regression. + function offset(self, slope: i32) -> i32 { + let num_points = 5i32; + // Calculate the sum. + let x_sum = 0i32; + let y_sum = 0i32; + for i in 0..5 { + x_sum += self.points[i].x; + y_sum += self.points[i].y; + } + return (y_sum - slope * x_sum) / num_points; + } +} + + +function main (x: i32, y: i32) -> [i32; 2] { + let points: [Point; 5] = [ + Point{x: x + 1, y: y + 1}, + Point{x: x + 2, y: y + 2}, + Point{x: x + 3, y: y + 3}, + Point{x: x + 4, y: y + 4}, + Point{x: x + 5, y: y + 5} + ]; + let reg = LinearRegression::new(points); + let slope = reg.slope(); + let offset = reg.offset(slope); + return [slope, offset]; +} diff --git a/parser/tests/serialization/main.leo b/parser/tests/serialization/leo/one_plus_one.leo similarity index 100% rename from parser/tests/serialization/main.leo rename to parser/tests/serialization/leo/one_plus_one.leo diff --git a/parser/tests/serialization/leo/palindrome.leo b/parser/tests/serialization/leo/palindrome.leo new file mode 100644 index 0000000000..f2b1872733 --- /dev/null +++ b/parser/tests/serialization/leo/palindrome.leo @@ -0,0 +1,59 @@ +// This Program takes in any 20-byte low register string and tells +// whether a string is a palindrome ignoring any spaces. + +function main(str: [char; 20]) -> bool { + return is_palindrome(str); +} + +function is_palindrome(str: [char; 20]) -> bool { + const str_len = 20u32; // saving const for convenience + + // By default we assume that input is a palindrome. + let result = true; + let processed = 0u8; + + for start in 0..(str_len / 2) { + let start_sym = str[start]; + if start_sym != ' ' { + let skipped = 0u8; + let end_empty = 0u8; + let end_sym = ' '; + + for end in (str_len - 1)..start { + if str[end] != ' ' && skipped == processed && end_sym == ' ' { + end_sym = str[end]; + } else { + end_empty = end_empty + 1; + if str[end] != ' ' { + skipped = skipped + 1; + } + } + } + + // If there are symbols left to the right from the start. + if end_sym != ' ' { + console.log("Comparing: {} ? {}", start_sym, end_sym); + + if result { + result = (start_sym == end_sym); + } + + processed = processed + 1; + } + } + } + + console.log("Result is: {}", result); + + return result; +} + +@test +function test_is_palindrome() { + console.assert(is_palindrome("a b a ")); + console.assert(is_palindrome("😀😀😀😀😀 😀😀😀😀😀")); + console.assert(is_palindrome("borrow or rob ")); + console.assert(is_palindrome("bbbb aaaa aaaa bbbb")); + console.assert(is_palindrome("aaaaaaaaaaaaaaaaaaaa")); + console.assert(is_palindrome("taco cat ")); +} diff --git a/parser/tests/serialization/parser_error.leo b/parser/tests/serialization/leo/parser_error.leo similarity index 100% rename from parser/tests/serialization/parser_error.leo rename to parser/tests/serialization/leo/parser_error.leo diff --git a/parser/tests/serialization/leo/pedersen_hash.leo b/parser/tests/serialization/leo/pedersen_hash.leo new file mode 100644 index 0000000000..ab6474c4e4 --- /dev/null +++ b/parser/tests/serialization/leo/pedersen_hash.leo @@ -0,0 +1,25 @@ +circuit PedersenHash { + parameters: [group; 256]; + + // Instantiates a Pedersen hash circuit + function new(parameters: [group; 256]) -> Self { + return Self { parameters: parameters }; + } + + function hash(self, bits: [bool; 256]) -> group { + let digest: group = 0group; + for i in 0..256 { + if bits[i] { + digest += self.parameters[i]; + } + } + return digest; + } +} + +// The 'pedersen-hash' main function. +function main(hash_input: [bool; 256], const parameters: [group; 256]) -> group { + const pedersen = PedersenHash::new(parameters); + return pedersen.hash(hash_input); +} + diff --git a/parser/tests/serialization/leo/silly_sudoku.leo b/parser/tests/serialization/leo/silly_sudoku.leo new file mode 100644 index 0000000000..856bd8892a --- /dev/null +++ b/parser/tests/serialization/leo/silly_sudoku.leo @@ -0,0 +1,71 @@ +import lib.SillySudoku; + +// The `silly-sudoku` main function +function main(puzzle: [u8; (3, 3)], answer: [u8; (3, 3)]) -> bool { + console.log("Starting Sudoku solver..."); + console.log("{}", puzzle); + + // Instantiate the Sudoku puzzle. + let sudoku = SillySudoku { puzzle_grid: puzzle }; + + console.log("Checking Sudoku answer..."); + console.log("{}", answer); + + // Evaluate the Sudoku puzzle with the given answer. + let result = sudoku.solve(answer); + + console.log("The answer is {}.", result); + + return result; +} + +// Tests that the `silly-sudoku` circuit outputs true on a correct answer. +@test +function test_solve_pass() { + let puzzle: [u8; (3, 3)] = [[0, 2, 0], + [0, 0, 6], + [0, 8, 9]]; + + let answer: [u8; (3, 3)] = [[1, 2, 3], + [4, 5, 6], + [7, 8, 9]]; + + // Runs the Sudoku checker. + let result = main(puzzle, answer); + + // Expects the result to be true. + console.assert(true == result); +} + +// Tests that the `silly-sudoku` circuit outputs false on an incorrect answer. +@test +function test_solve_fail() { + let puzzle: [u8; (3, 3)] = [[0, 2, 0], + [0, 0, 6], + [0, 8, 0]]; + + let answer: [u8; (3, 3)] = [[1, 2, 3], + [4, 5, 6], + [7, 8, 8]]; // We have an extra `8` in this column! + + // Runs the Sudoku checker. + let result = main(puzzle, answer); + + // Expects the result to be false. + console.assert(false == result); +} + +// Test that the `silly-sudoku` circuit outputs the expected value on a custom test input. +@test(test_input) +function test_solve_with_input( + puzzle: [u8; (3, 3)], + answer: [u8; (3, 3)], + expected: bool +) { + // Runs the Sudoku checker. + let result = main(puzzle, answer); + + console.log("expected {}, got {}", expected, result); + + console.assert(expected == result); +}