diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 138932beaf..5c597886c7 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -5,7 +5,7 @@ updates:
schedule:
interval: daily
time: "10:00"
- target-branch: "staging"
+ target-branch: "testnet3"
open-pull-requests-limit: 20
ignore:
- dependency-name: snarkvm-curves
diff --git a/Cargo.lock b/Cargo.lock
index 98bbc22fde..eafa305075 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -56,9 +56,9 @@ dependencies = [
[[package]]
name = "anyhow"
-version = "1.0.53"
+version = "1.0.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
+checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd"
[[package]]
name = "assert_cmd"
@@ -127,34 +127,13 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
-[[package]]
-name = "block-buffer"
-version = "0.7.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
-dependencies = [
- "block-padding",
- "byte-tools",
- "byteorder",
- "generic-array 0.12.4",
-]
-
[[package]]
name = "block-buffer"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95"
dependencies = [
- "generic-array 0.14.5",
-]
-
-[[package]]
-name = "block-padding"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
-dependencies = [
- "byte-tools",
+ "generic-array",
]
[[package]]
@@ -175,12 +154,6 @@ version = "3.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"
-[[package]]
-name = "byte-tools"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
-
[[package]]
name = "byteorder"
version = "1.4.3"
@@ -267,9 +240,9 @@ dependencies = [
[[package]]
name = "clap"
-version = "3.0.14"
+version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b63edc3f163b3c71ec8aa23f9bd6070f77edbf3d1d198b164afa90ff00e4ec62"
+checksum = "6d76c22c9b9b215eeb8d016ad3a90417bd13cb24cf8142756e6472445876cab7"
dependencies = [
"atty",
"bitflags",
@@ -362,7 +335,7 @@ dependencies = [
"clap 2.34.0",
"criterion-plot",
"csv",
- "itertools 0.10.3",
+ "itertools",
"lazy_static",
"num-traits",
"oorandom",
@@ -384,7 +357,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57"
dependencies = [
"cast",
- "itertools 0.10.3",
+ "itertools",
]
[[package]]
@@ -433,11 +406,12 @@ dependencies = [
[[package]]
name = "crypto-common"
-version = "0.1.1"
+version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0"
+checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8"
dependencies = [
- "generic-array 0.14.5",
+ "generic-array",
+ "typenum",
]
[[package]]
@@ -468,9 +442,9 @@ version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
@@ -481,22 +455,12 @@ checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
[[package]]
name = "digest"
-version = "0.8.1"
+version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
+checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506"
dependencies = [
- "generic-array 0.12.4",
-]
-
-[[package]]
-name = "digest"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b"
-dependencies = [
- "block-buffer 0.10.0",
+ "block-buffer",
"crypto-common",
- "generic-array 0.14.5",
]
[[package]]
@@ -566,34 +530,6 @@ dependencies = [
"once_cell",
]
-[[package]]
-name = "failure"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
-dependencies = [
- "backtrace",
- "failure_derive",
-]
-
-[[package]]
-name = "failure_derive"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
-dependencies = [
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
- "synstructure",
-]
-
-[[package]]
-name = "fake-simd"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
-
[[package]]
name = "fastrand"
version = "1.7.0"
@@ -658,16 +594,6 @@ dependencies = [
"percent-encoding",
]
-[[package]]
-name = "from-pest"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aba9389cedcba1fb3a2aa2ed00f584f2606bce8e0106614a17327a24513bc60f"
-dependencies = [
- "pest",
- "void",
-]
-
[[package]]
name = "fsevent"
version = "0.4.0"
@@ -776,15 +702,6 @@ dependencies = [
"byteorder",
]
-[[package]]
-name = "generic-array"
-version = "0.12.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
-dependencies = [
- "typenum",
-]
-
[[package]]
name = "generic-array"
version = "0.14.5"
@@ -1036,15 +953,6 @@ version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9"
-[[package]]
-name = "itertools"
-version = "0.7.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d47946d458e94a1b7bcabbf6521ea7c037062c81f534615abcad76e84d4970d"
-dependencies = [
- "either",
-]
-
[[package]]
name = "itertools"
version = "0.10.3"
@@ -1112,22 +1020,33 @@ dependencies = [
"criterion",
"indexmap",
"leo-errors",
- "leo-input",
"leo-span",
- "pest",
"serde",
"serde_json",
"smallvec",
"tendril",
]
+[[package]]
+name = "leo-ast-passes"
+version = "1.5.3"
+dependencies = [
+ "indexmap",
+ "leo-ast",
+ "leo-errors",
+ "leo-parser",
+ "leo-span",
+]
+
[[package]]
name = "leo-compiler"
version = "1.5.3"
dependencies = [
"leo-ast",
+ "leo-ast-passes",
"leo-errors",
"leo-parser",
+ "leo-span",
"sha2",
]
@@ -1140,38 +1059,23 @@ dependencies = [
"colored",
"derivative",
"eyre",
- "leo-input",
"leo-span",
- "pest",
"serde",
"tendril",
"thiserror",
]
-[[package]]
-name = "leo-input"
-version = "1.5.3"
-dependencies = [
- "from-pest",
- "pest",
- "pest-ast",
- "pest_derive",
- "thiserror",
- "tracing",
-]
-
[[package]]
name = "leo-lang"
version = "1.5.3"
dependencies = [
"ansi_term",
"assert_cmd",
- "clap 3.0.14",
+ "clap 3.1.1",
"color-backtrace",
"colored",
"console",
"dirs",
- "from-pest",
"indexmap",
"lazy_static",
"leo-ast",
@@ -1219,13 +1123,13 @@ dependencies = [
"lazy_static",
"leo-ast",
"leo-errors",
- "leo-input",
"leo-span",
"leo-test-framework",
"serde",
"serde_json",
"serde_yaml",
"smallvec",
+ "structopt",
"tendril",
"tracing",
]
@@ -1236,7 +1140,6 @@ version = "1.5.3"
dependencies = [
"fxhash",
"indexmap",
- "pest",
"scoped-tls",
"serde",
"tendril",
@@ -1281,12 +1184,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
-[[package]]
-name = "maplit"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
-
[[package]]
name = "matches"
version = "0.1.9"
@@ -1551,12 +1448,6 @@ version = "11.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
-[[package]]
-name = "opaque-debug"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
-
[[package]]
name = "openssl"
version = "0.10.38"
@@ -1614,53 +1505,6 @@ dependencies = [
"ucd-trie",
]
-[[package]]
-name = "pest-ast"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3fbf404899169771dd6a32c84248b83cd67a26cc7cc957aac87661490e1227e4"
-dependencies = [
- "itertools 0.7.11",
- "proc-macro2 0.4.30",
- "quote 0.6.13",
- "single",
- "syn 0.15.44",
-]
-
-[[package]]
-name = "pest_derive"
-version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
-dependencies = [
- "pest",
- "pest_generator",
-]
-
-[[package]]
-name = "pest_generator"
-version = "2.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
-dependencies = [
- "pest",
- "pest_meta",
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
-]
-
-[[package]]
-name = "pest_meta"
-version = "2.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
-dependencies = [
- "maplit",
- "pest",
- "sha-1",
-]
-
[[package]]
name = "pin-project-lite"
version = "0.2.8"
@@ -1720,7 +1564,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5aab5be6e4732b473071984b3164dbbfb7a3674d30ea5ff44410b6bcd960c3c"
dependencies = [
"difflib",
- "itertools 0.10.3",
+ "itertools",
"predicates-core",
]
@@ -1756,9 +1600,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
+ "proc-macro2",
+ "quote",
+ "syn",
"version_check",
]
@@ -1768,27 +1612,18 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
- "proc-macro2 1.0.36",
- "quote 1.0.15",
+ "proc-macro2",
+ "quote",
"version_check",
]
-[[package]]
-name = "proc-macro2"
-version = "0.4.30"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
-dependencies = [
- "unicode-xid 0.1.0",
-]
-
[[package]]
name = "proc-macro2"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
dependencies = [
- "unicode-xid 0.2.2",
+ "unicode-xid",
]
[[package]]
@@ -1800,22 +1635,13 @@ dependencies = [
"memchr",
]
-[[package]]
-name = "quote"
-version = "0.6.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
-dependencies = [
- "proc-macro2 0.4.30",
-]
-
[[package]]
name = "quote"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
dependencies = [
- "proc-macro2 1.0.36",
+ "proc-macro2",
]
[[package]]
@@ -2166,9 +1992,9 @@ version = "1.0.136"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
dependencies = [
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
@@ -2207,27 +2033,15 @@ dependencies = [
"yaml-rust",
]
-[[package]]
-name = "sha-1"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
-dependencies = [
- "block-buffer 0.7.3",
- "digest 0.8.1",
- "fake-simd",
- "opaque-debug",
-]
-
[[package]]
name = "sha2"
-version = "0.10.1"
+version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "99c3bd8169c58782adad9290a9af5939994036b76187f7b4f0e6de91dbbfc0ec"
+checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676"
dependencies = [
"cfg-if 1.0.0",
"cpufeatures",
- "digest 0.10.1",
+ "digest",
]
[[package]]
@@ -2239,15 +2053,6 @@ dependencies = [
"lazy_static",
]
-[[package]]
-name = "single"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd5add732a1ab689845591a1b50339cf5310b563e08dc5813c65991f30369ea2"
-dependencies = [
- "failure",
-]
-
[[package]]
name = "slab"
version = "0.4.5"
@@ -2270,9 +2075,9 @@ source = "git+https://github.com/AleoHQ/snarkVM.git?rev=51633e2#51633e2fac247bc8
dependencies = [
"proc-macro-crate",
"proc-macro-error",
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
@@ -2282,7 +2087,7 @@ source = "git+https://github.com/AleoHQ/snarkVM.git?rev=51633e2#51633e2fac247bc8
dependencies = [
"anyhow",
"bincode",
- "itertools 0.10.3",
+ "itertools",
"num-bigint",
"rand 0.8.4",
"serde",
@@ -2331,20 +2136,9 @@ checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
dependencies = [
"heck",
"proc-macro-error",
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
-]
-
-[[package]]
-name = "syn"
-version = "0.15.44"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
-dependencies = [
- "proc-macro2 0.4.30",
- "quote 0.6.13",
- "unicode-xid 0.1.0",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
@@ -2353,21 +2147,9 @@ version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b"
dependencies = [
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "unicode-xid 0.2.2",
-]
-
-[[package]]
-name = "synstructure"
-version = "0.12.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
-dependencies = [
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
- "unicode-xid 0.2.2",
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
]
[[package]]
@@ -2459,9 +2241,9 @@ version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
dependencies = [
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
@@ -2580,9 +2362,9 @@ version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
dependencies = [
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
@@ -2673,12 +2455,6 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
-[[package]]
-name = "unicode-xid"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
-
[[package]]
name = "unicode-xid"
version = "0.2.2"
@@ -2721,12 +2497,6 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
-[[package]]
-name = "void"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
-
[[package]]
name = "wait-timeout"
version = "0.2.0"
@@ -2788,9 +2558,9 @@ dependencies = [
"bumpalo",
"lazy_static",
"log",
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
+ "proc-macro2",
+ "quote",
+ "syn",
"wasm-bindgen-shared",
]
@@ -2812,7 +2582,7 @@ version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01"
dependencies = [
- "quote 1.0.15",
+ "quote",
"wasm-bindgen-macro-support",
]
@@ -2822,9 +2592,9 @@ version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc"
dependencies = [
- "proc-macro2 1.0.36",
- "quote 1.0.15",
- "syn 1.0.86",
+ "proc-macro2",
+ "quote",
+ "syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
diff --git a/Cargo.toml b/Cargo.toml
index 37b9bc78b5..17ca9838e9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,7 +30,7 @@ members = [
# "asg",
# "asg-passes",
"ast",
-# "ast-passes",
+ "ast-passes",
"compiler",
"errors",
"grammar",
@@ -63,9 +63,6 @@ version = "1.5.3"
#path = "./imports"
#version = "1.5.3"
#
-#[dependencies.leo-input]
-#path = "./input"
-#version = "1.5.3"
[dependencies.leo-package]
path = "./package"
@@ -107,7 +104,7 @@ git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
[dependencies.clap]
-version = "3.0.10"
+version = "3.1"
[dependencies.color-backtrace]
version = "0.5.1"
@@ -121,9 +118,6 @@ version = "4.0.0"
[dependencies.console]
version = "0.15.0"
-[dependencies.from-pest]
-version = "0.3.1"
-
[dependencies.indexmap]
version = "1.8"
features = ["serde"]
diff --git a/ast-passes/Cargo.toml b/ast-passes/Cargo.toml
index 0a63c84dbb..57f6d387dd 100644
--- a/ast-passes/Cargo.toml
+++ b/ast-passes/Cargo.toml
@@ -36,6 +36,10 @@ version = "1.5.3"
path = "../parser"
version = "1.5.3"
+[dependencies.leo-span]
+path = "../span"
+version = "1.5.3"
+
#[dependencies.leo-stdlib]
#path = "../stdlib"
#version = "1.5.3"
\ No newline at end of file
diff --git a/ast-passes/src/canonicalization/canonicalizer.rs b/ast-passes/src/canonicalization/canonicalizer.rs
index ac05fa3db2..4c42d32407 100644
--- a/ast-passes/src/canonicalization/canonicalizer.rs
+++ b/ast-passes/src/canonicalization/canonicalizer.rs
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2021 Aleo Systems Inc.
+// Copyright (C) 2019-2022 Aleo Systems Inc.
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
@@ -14,8 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
+//! Creates a struct that implements a ReconstructingReducer
+//! such that it applies changes to the AST nodes for canonicalization.
+//! An example of these changes are transforming Self -> to the circuit name.
+
use leo_ast::*;
-use leo_errors::{AstError, Result, Span};
+use leo_errors::{AstError, Result};
+use leo_span::{sym, Span, Symbol};
+
+use indexmap::IndexMap;
/// Replace Self when it is in a enclosing circuit type.
/// Error when Self is outside an enclosing circuit type.
@@ -30,14 +37,6 @@ pub struct Canonicalizer {
in_circuit: bool,
}
-impl AstPass for Canonicalizer {
- fn do_pass(ast: Program) -> Result {
- Ok(Ast::new(
- ReconstructingDirector::new(Self::default()).reduce_program(&ast)?,
- ))
- }
-}
-
impl Canonicalizer {
pub fn canonicalize_accesses(
&mut self,
@@ -50,34 +49,34 @@ impl Canonicalizer {
for access in accesses.iter() {
match self.canonicalize_assignee_access(access) {
AssigneeAccess::ArrayIndex(index) => {
- left = Box::new(Expression::ArrayAccess(ArrayAccessExpression {
+ left = Box::new(Expression::Access(AccessExpression::Array(ArrayAccess {
array: left,
index: Box::new(index),
span: span.clone(),
- }));
+ })));
}
AssigneeAccess::ArrayRange(start, stop) => {
- left = Box::new(Expression::ArrayRangeAccess(ArrayRangeAccessExpression {
+ left = Box::new(Expression::Access(AccessExpression::ArrayRange(ArrayRangeAccess {
array: left,
left: start.map(Box::new),
right: stop.map(Box::new),
span: span.clone(),
- }));
+ })));
}
AssigneeAccess::Tuple(positive_number, _) => {
- left = Box::new(Expression::TupleAccess(TupleAccessExpression {
+ left = Box::new(Expression::Access(AccessExpression::Tuple(TupleAccess {
tuple: left,
index: positive_number,
span: span.clone(),
- }));
+ })));
}
AssigneeAccess::Member(identifier) => {
- left = Box::new(Expression::CircuitMemberAccess(CircuitMemberAccessExpression {
- circuit: left,
+ left = Box::new(Expression::Access(AccessExpression::Member(MemberAccess {
+ inner: left,
name: identifier,
span: span.clone(),
type_: None,
- }));
+ })));
}
}
}
@@ -85,7 +84,7 @@ impl Canonicalizer {
Ok(left)
}
- pub fn compound_operation_converstion(&mut self, operation: &AssignOperation) -> Result {
+ pub fn compound_operation_conversion(&mut self, operation: &AssignOperation) -> Result {
match operation {
AssignOperation::Assign => unreachable!(),
AssignOperation::Add => Ok(BinaryOperation::Add),
@@ -125,11 +124,11 @@ impl Canonicalizer {
}
}
- fn canonicalize_circuit_implied_variable_definition(
+ fn canonicalize_circuit_variable_initializer(
&mut self,
- member: &CircuitImpliedVariableDefinition,
- ) -> CircuitImpliedVariableDefinition {
- CircuitImpliedVariableDefinition {
+ member: &CircuitVariableInitializer,
+ ) -> CircuitVariableInitializer {
+ CircuitVariableInitializer {
identifier: member.identifier.clone(),
expression: member
.expression
@@ -156,7 +155,7 @@ impl Canonicalizer {
return Expression::Binary(BinaryExpression {
left,
right,
- op: binary.op.clone(),
+ op: binary.op,
span: binary.span.clone(),
});
}
@@ -184,6 +183,62 @@ impl Canonicalizer {
});
}
+ Expression::Access(access) => {
+ let access = match access {
+ AccessExpression::Array(array_access) => {
+ let array = Box::new(self.canonicalize_expression(&array_access.array));
+ let index = Box::new(self.canonicalize_expression(&array_access.index));
+
+ AccessExpression::Array(ArrayAccess {
+ array,
+ index,
+ span: array_access.span.clone(),
+ })
+ }
+ AccessExpression::ArrayRange(array_range_access) => {
+ let array = Box::new(self.canonicalize_expression(&array_range_access.array));
+ let left = array_range_access
+ .left
+ .as_ref()
+ .map(|left| Box::new(self.canonicalize_expression(left)));
+ let right = array_range_access
+ .right
+ .as_ref()
+ .map(|right| Box::new(self.canonicalize_expression(right)));
+
+ AccessExpression::ArrayRange(ArrayRangeAccess {
+ array,
+ left,
+ right,
+ span: array_range_access.span.clone(),
+ })
+ }
+ AccessExpression::Member(member_access) => AccessExpression::Member(MemberAccess {
+ inner: Box::new(self.canonicalize_expression(&member_access.inner)),
+ name: member_access.name.clone(),
+ span: member_access.span.clone(),
+ type_: None,
+ }),
+ AccessExpression::Tuple(tuple_access) => {
+ let tuple = Box::new(self.canonicalize_expression(&tuple_access.tuple));
+
+ AccessExpression::Tuple(TupleAccess {
+ tuple,
+ index: tuple_access.index.clone(),
+ span: tuple_access.span.clone(),
+ })
+ }
+ AccessExpression::Static(static_access) => AccessExpression::Static(StaticAccess {
+ inner: Box::new(self.canonicalize_expression(&static_access.inner)),
+ name: static_access.name.clone(),
+ type_: self.canonicalize_self_type(static_access.type_.as_ref()),
+ span: static_access.span.clone(),
+ }),
+ };
+
+ return Expression::Access(access);
+ }
+
Expression::ArrayInline(array_inline) => {
let elements = array_inline
.elements
@@ -214,36 +269,6 @@ impl Canonicalizer {
});
}
- Expression::ArrayAccess(array_access) => {
- let array = Box::new(self.canonicalize_expression(&array_access.array));
- let index = Box::new(self.canonicalize_expression(&array_access.index));
-
- return Expression::ArrayAccess(ArrayAccessExpression {
- array,
- index,
- span: array_access.span.clone(),
- });
- }
-
- Expression::ArrayRangeAccess(array_range_access) => {
- let array = Box::new(self.canonicalize_expression(&array_range_access.array));
- let left = array_range_access
- .left
- .as_ref()
- .map(|left| Box::new(self.canonicalize_expression(left)));
- let right = array_range_access
- .right
- .as_ref()
- .map(|right| Box::new(self.canonicalize_expression(right)));
-
- return Expression::ArrayRangeAccess(ArrayRangeAccessExpression {
- array,
- left,
- right,
- span: array_range_access.span.clone(),
- });
- }
-
Expression::TupleInit(tuple_init) => {
let elements = tuple_init
.elements
@@ -257,20 +282,10 @@ impl Canonicalizer {
});
}
- Expression::TupleAccess(tuple_access) => {
- let tuple = Box::new(self.canonicalize_expression(&tuple_access.tuple));
-
- return Expression::TupleAccess(TupleAccessExpression {
- tuple,
- index: tuple_access.index.clone(),
- span: tuple_access.span.clone(),
- });
- }
-
Expression::CircuitInit(circuit_init) => {
let mut name = circuit_init.name.clone();
- if name.name.as_ref() == "Self" && self.circuit_name.is_some() {
- name = self.circuit_name.as_ref().unwrap().clone();
+ if name.name == sym::SelfUpper && self.circuit_name.is_some() {
+ name = self.circuit_name.clone().unwrap();
}
return Expression::CircuitInit(CircuitInitExpression {
@@ -278,26 +293,11 @@ impl Canonicalizer {
members: circuit_init
.members
.iter()
- .map(|member| self.canonicalize_circuit_implied_variable_definition(member))
+ .map(|member| self.canonicalize_circuit_variable_initializer(member))
.collect(),
span: circuit_init.span.clone(),
});
}
- Expression::CircuitMemberAccess(circuit_member_access) => {
- return Expression::CircuitMemberAccess(CircuitMemberAccessExpression {
- circuit: Box::new(self.canonicalize_expression(&circuit_member_access.circuit)),
- name: circuit_member_access.name.clone(),
- span: circuit_member_access.span.clone(),
- type_: None,
- });
- }
- Expression::CircuitStaticFunctionAccess(circuit_static_func_access) => {
- return Expression::CircuitStaticFunctionAccess(CircuitStaticFunctionAccessExpression {
- circuit: Box::new(self.canonicalize_expression(&circuit_static_func_access.circuit)),
- name: circuit_static_func_access.name.clone(),
- span: circuit_static_func_access.span.clone(),
- });
- }
Expression::Call(call) => {
return Expression::Call(CallExpression {
function: Box::new(self.canonicalize_expression(&call.function)),
@@ -310,7 +310,7 @@ impl Canonicalizer {
});
}
Expression::Identifier(identifier) => {
- if identifier.name.as_ref() == "Self" && self.circuit_name.is_some() {
+ if identifier.name == sym::SelfUpper && self.circuit_name.is_some() {
return Expression::Identifier(self.circuit_name.as_ref().unwrap().clone());
}
}
@@ -376,6 +376,7 @@ impl Canonicalizer {
Statement::Definition(DefinitionStatement {
declaration_type: definition.declaration_type.clone(),
variable_names: definition.variable_names.clone(),
+ parened: definition.parened,
type_,
value,
span: definition.span.clone(),
@@ -478,6 +479,13 @@ impl Canonicalizer {
fn canonicalize_circuit_member(&mut self, circuit_member: &CircuitMember) -> CircuitMember {
match circuit_member {
+ CircuitMember::CircuitConst(identifier, type_, value) => {
+ return CircuitMember::CircuitConst(
+ identifier.clone(),
+ type_.clone(),
+ self.canonicalize_expression(value),
+ );
+ }
CircuitMember::CircuitVariable(_, _) => {}
CircuitMember::CircuitFunction(function) => {
let input = function
@@ -488,14 +496,16 @@ impl Canonicalizer {
let output = self.canonicalize_self_type(function.output.as_ref());
let block = self.canonicalize_block(&function.block);
- return CircuitMember::CircuitFunction(Function {
+ return CircuitMember::CircuitFunction(Box::new(Function {
annotations: function.annotations.clone(),
identifier: function.identifier.clone(),
+ const_: function.const_,
input,
output,
block,
+ core_mapping: function.core_mapping.clone(),
span: function.span.clone(),
- });
+ }));
}
}
@@ -513,35 +523,20 @@ impl ReconstructingReducer for Canonicalizer {
}
fn reduce_type(&mut self, _type_: &Type, new: Type, span: &Span) -> Result {
- match new {
- Type::Array(type_, dimensions) => {
- if let Some(mut dimensions) = dimensions {
- if dimensions.is_zero() {
- return Err(AstError::invalid_array_dimension_size(span).into());
- }
-
- let mut next = Type::Array(type_, Some(ArrayDimensions(vec![dimensions.remove_last().unwrap()])));
- let mut array = next.clone();
-
- loop {
- if dimensions.is_empty() {
- break;
- }
-
- array = Type::Array(
- Box::new(next),
- Some(ArrayDimensions(vec![dimensions.remove_last().unwrap()])),
- );
- next = array.clone();
- }
-
- Ok(array)
- } else {
- Ok(Type::Array(type_, None))
- }
+ match new.clone() {
+ Type::Array(base, dims) if dims.is_empty() => Ok(Type::Array(base, dims)),
+ Type::Array(_, dims) if dims.is_zero() => Err(AstError::invalid_array_dimension_size(span).into()),
+ // Reduce `ArrayDimensions` into nested `Array` types.
+ Type::Array(base, dims) => {
+ let mut iter = dims.0.into_iter().rev();
+ let ctor = |ty, dim| Type::Array(ty, ArrayDimensions::single(dim));
+ let dim = iter.next().unwrap();
+ let base = ctor(base, dim);
+ Ok(iter.fold(base, |ty, dim| ctor(Box::new(ty), dim)))
}
Type::SelfType if !self.in_circuit => Err(AstError::big_self_outside_of_circuit(span).into()),
- _ => Ok(new.clone()),
+ Type::Tuple(types) if types.len() == 1 => Err(AstError::invalid_tuple_dimension_size(span).into()),
+ _ => Ok(new),
}
}
@@ -594,6 +589,10 @@ impl ReconstructingReducer for Canonicalizer {
)));
}
+ if elements.is_empty() {
+ return Err(AstError::invalid_array_dimension_size(span).into());
+ }
+
Ok(Expression::ArrayInline(ArrayInlineExpression {
elements,
span: span.clone(),
@@ -605,46 +604,40 @@ impl ReconstructingReducer for Canonicalizer {
array_init: &ArrayInitExpression,
element: Expression,
) -> Result {
- if array_init.dimensions.is_zero() {
- return Err(AstError::invalid_array_dimension_size(&array_init.span).into());
- }
-
- let element = Box::new(element);
-
- if array_init.dimensions.0.len() == 1 {
- return Ok(ArrayInitExpression {
- element,
- dimensions: array_init.dimensions.clone(),
- span: array_init.span.clone(),
- });
- }
-
- let mut dimensions = array_init.dimensions.clone();
-
- let mut next = Expression::ArrayInit(ArrayInitExpression {
+ let mk_expr = |element, dim| ArrayInitExpression {
element,
- dimensions: ArrayDimensions(vec![dimensions.remove_last().unwrap()]),
+ dimensions: ArrayDimensions::single(dim),
span: array_init.span.clone(),
- });
+ };
- let mut outer_element = Box::new(next.clone());
- for (index, dimension) in dimensions.0.iter().rev().enumerate() {
- if index == dimensions.0.len() - 1 {
- break;
+ let mut iter = array_init.dimensions.iter().rev().cloned();
+ // We know the array has non-zero dimensions.
+ let init = mk_expr(Box::new(element), iter.next().unwrap());
+ Ok(iter.fold(init, |elem, dim| mk_expr(Box::new(Expression::ArrayInit(elem)), dim)))
+ }
+
+ fn reduce_definition(
+ &mut self,
+ definition: &DefinitionStatement,
+ variable_names: Vec,
+ type_: Option,
+ value: Expression,
+ ) -> Result {
+ match &type_ {
+ Some(Type::Tuple(elements)) if elements.len() != 1 => {}
+ _ if definition.parened => {
+ return Err(AstError::invalid_parens_around_single_variable(&definition.span).into());
}
-
- next = Expression::ArrayInit(ArrayInitExpression {
- element: outer_element,
- dimensions: ArrayDimensions(vec![dimension.clone()]),
- span: array_init.span.clone(),
- });
- outer_element = Box::new(next.clone());
+ _ => {}
}
- Ok(ArrayInitExpression {
- element: outer_element,
- dimensions: ArrayDimensions(vec![dimensions.remove_first().unwrap()]),
- span: array_init.span.clone(),
+ Ok(DefinitionStatement {
+ declaration_type: definition.declaration_type.clone(),
+ variable_names,
+ parened: definition.parened,
+ type_,
+ value,
+ span: definition.span.clone(),
})
}
@@ -662,7 +655,7 @@ impl ReconstructingReducer for Canonicalizer {
&assign.span,
)?;
let right = Box::new(value);
- let op = self.compound_operation_converstion(&assign.operation)?;
+ let op = self.compound_operation_conversion(&assign.operation)?;
let new_value = Expression::Binary(BinaryExpression {
left,
@@ -691,8 +684,9 @@ impl ReconstructingReducer for Canonicalizer {
&mut self,
function: &Function,
identifier: Identifier,
- annotations: Vec,
+ annotations: IndexMap,
input: Vec,
+ const_: bool,
output: Option,
block: Block,
) -> Result {
@@ -705,22 +699,23 @@ impl ReconstructingReducer for Canonicalizer {
identifier,
annotations,
input,
+ const_,
output: new_output,
block,
+ core_mapping: function.core_mapping.clone(),
span: function.span.clone(),
})
}
fn reduce_circuit(
&mut self,
- circuit: &Circuit,
+ _circuit: &Circuit,
circuit_name: Identifier,
members: Vec,
) -> Result {
self.circuit_name = Some(circuit_name.clone());
let circ = Circuit {
circuit_name,
- core_mapping: circuit.core_mapping.clone(),
members: members
.iter()
.map(|member| self.canonicalize_circuit_member(member))
diff --git a/ast-passes/src/canonicalization/mod.rs b/ast-passes/src/canonicalization/mod.rs
index 155ccd8043..26f172ff16 100644
--- a/ast-passes/src/canonicalization/mod.rs
+++ b/ast-passes/src/canonicalization/mod.rs
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2021 Aleo Systems Inc.
+// Copyright (C) 2019-2022 Aleo Systems Inc.
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
@@ -14,5 +14,18 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
+//! Implements the AstPass trait for the Canonicalizer
+//! which is a ReconstructingReducer trait to canonicalize AST nodes.
+//! This allows for easy calling of the Canonicalization pass.
+
pub mod canonicalizer;
pub use canonicalizer::*;
+
+use leo_ast::{Ast, AstPass, Program, ReconstructingDirector};
+use leo_errors::Result;
+
+impl AstPass for Canonicalizer {
+ fn do_pass(self, ast: Program) -> Result {
+ Ok(Ast::new(ReconstructingDirector::new(self).reduce_program(&ast)?))
+ }
+}
diff --git a/ast-passes/src/lib.rs b/ast-passes/src/lib.rs
index b8add261cf..0f9455d9de 100644
--- a/ast-passes/src/lib.rs
+++ b/ast-passes/src/lib.rs
@@ -19,5 +19,7 @@
pub mod canonicalization;
pub use canonicalization::*;
-pub mod import_resolution;
-pub use import_resolution::*;
+// Temporarily disable import resolution
+// until we migrate stdlib and then import resolution.
+/* pub mod import_resolution;
+pub use import_resolution::*; */
diff --git a/ast/Cargo.toml b/ast/Cargo.toml
index 368ffc1d51..85f5e3bc6b 100644
--- a/ast/Cargo.toml
+++ b/ast/Cargo.toml
@@ -21,10 +21,6 @@ rust-version = "1.56"
[dependencies]
smallvec = { version = "1.8.0", features = ["serde"] }
-[dependencies.leo-input]
-path = "../input"
-version = "1.5.3"
-
[dependencies.leo-errors]
path = "../errors"
version = "1.5.3"
@@ -37,9 +33,6 @@ version = "1.5.3"
version = "1.8.0"
features = [ "serde-1" ]
-[dependencies.pest]
-version = "2.0"
-
[dependencies.serde]
version = "1.0"
features = [ "derive", "rc" ]
diff --git a/ast/src/chars/char_value.rs b/ast/src/chars/char_value.rs
index 06391a50fc..37857a3c5d 100644
--- a/ast/src/chars/char_value.rs
+++ b/ast/src/chars/char_value.rs
@@ -17,7 +17,6 @@
use leo_span::Span;
use serde::{Deserialize, Serialize};
-// use serde::de::{Deserialize as SerDeserialize, Deserializer};
use std::fmt;
fn char_to_u32(character: &char, serializer: S) -> Result
diff --git a/ast/src/common/array_dimensions.rs b/ast/src/common/array_dimensions.rs
index 261b78df3a..4b661f703f 100644
--- a/ast/src/common/array_dimensions.rs
+++ b/ast/src/common/array_dimensions.rs
@@ -15,7 +15,6 @@
// along with the Leo library. If not, see .
use crate::PositiveNumber;
-use leo_input::types::ArrayDimensions as InputArrayDimensions;
use serde::{ser::SerializeSeq, Deserialize, Serialize, Serializer};
use smallvec::{smallvec, SmallVec};
@@ -114,24 +113,6 @@ impl Serialize for ArrayDimensions {
}
}
-/// Create a new [`ArrayDimensions`] from a [`InputArrayDimensions`] in a Leo program file.
-impl<'ast> From> for ArrayDimensions {
- fn from(dimensions: InputArrayDimensions<'ast>) -> Self {
- match dimensions {
- InputArrayDimensions::Single(single) => {
- Self(smallvec![Dimension::Number(PositiveNumber::from(single.number))])
- }
- InputArrayDimensions::Multiple(multiple) => Self(
- multiple
- .numbers
- .into_iter()
- .map(|num| Dimension::Number(PositiveNumber::from(num)))
- .collect(),
- ),
- }
- }
-}
-
impl fmt::Display for ArrayDimensions {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &*self.0 {
diff --git a/ast/src/common/identifier.rs b/ast/src/common/identifier.rs
index 7273012d44..b2f2ba5c61 100644
--- a/ast/src/common/identifier.rs
+++ b/ast/src/common/identifier.rs
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use leo_input::common::Identifier as InputIdentifier;
use leo_span::{Span, Symbol};
use crate::Node;
@@ -68,15 +67,6 @@ impl Identifier {
}
}
-impl<'ast> From> for Identifier {
- fn from(identifier: InputIdentifier<'ast>) -> Self {
- Self {
- name: Symbol::intern(&identifier.value),
- span: Span::from(identifier.span),
- }
- }
-}
-
impl fmt::Display for Identifier {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.name)
diff --git a/ast/src/common/positive_number.rs b/ast/src/common/positive_number.rs
index 1ecc719398..a083e45b26 100644
--- a/ast/src/common/positive_number.rs
+++ b/ast/src/common/positive_number.rs
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use leo_input::values::PositiveNumber as InputPositiveNumber;
-
use serde::{Deserialize, Serialize};
use std::fmt;
use tendril::StrTendril;
@@ -36,15 +34,6 @@ impl PositiveNumber {
}
}
-/// Create a new [`PositiveNumber`] from an [`InputPositiveNumber`] in a Leo input file.
-impl<'ast> From> for PositiveNumber {
- fn from(array: InputPositiveNumber<'ast>) -> Self {
- Self {
- value: array.value.into(),
- }
- }
-}
-
impl fmt::Display for PositiveNumber {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.value)
diff --git a/ast/src/groups/group_coordinate.rs b/ast/src/groups/group_coordinate.rs
index a19c88c269..8fb39aee29 100644
--- a/ast/src/groups/group_coordinate.rs
+++ b/ast/src/groups/group_coordinate.rs
@@ -14,10 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use leo_input::values::{
- GroupCoordinate as InputGroupCoordinate, Inferred as InputInferred, NumberValue as InputNumberValue,
- SignHigh as InputSignHigh, SignLow as InputSignLow,
-};
use leo_span::Span;
use serde::{Deserialize, Serialize};
@@ -40,17 +36,6 @@ pub enum GroupCoordinate {
Inferred,
}
-impl<'ast> From> for GroupCoordinate {
- fn from(coordinate: InputGroupCoordinate<'ast>) -> Self {
- match coordinate {
- InputGroupCoordinate::Number(number) => GroupCoordinate::from(number),
- InputGroupCoordinate::SignHigh(sign_high) => GroupCoordinate::from(sign_high),
- InputGroupCoordinate::SignLow(sign_low) => GroupCoordinate::from(sign_low),
- InputGroupCoordinate::Inferred(inferred) => GroupCoordinate::from(inferred),
- }
- }
-}
-
impl fmt::Display for GroupCoordinate {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
@@ -61,30 +46,3 @@ impl fmt::Display for GroupCoordinate {
}
}
}
-
-impl<'ast> From> for GroupCoordinate {
- fn from(number: InputNumberValue<'ast>) -> Self {
- let value = number.to_string();
- let span = Span::from(number.span().clone());
-
- GroupCoordinate::Number(value.into(), span)
- }
-}
-
-impl<'ast> From> for GroupCoordinate {
- fn from(_sign: InputSignHigh<'ast>) -> Self {
- GroupCoordinate::SignHigh
- }
-}
-
-impl<'ast> From> for GroupCoordinate {
- fn from(_sign: InputSignLow<'ast>) -> Self {
- GroupCoordinate::SignLow
- }
-}
-
-impl<'ast> From> for GroupCoordinate {
- fn from(_sign: InputInferred<'ast>) -> Self {
- GroupCoordinate::Inferred
- }
-}
diff --git a/ast/src/groups/group_value.rs b/ast/src/groups/group_value.rs
index 74e9a34779..567527fd90 100644
--- a/ast/src/groups/group_value.rs
+++ b/ast/src/groups/group_value.rs
@@ -15,9 +15,6 @@
// along with the Leo library. If not, see .
use crate::groups::GroupCoordinate;
-use leo_input::values::{
- GroupRepresentation as InputGroupRepresentation, GroupTuple as InputGroupTuple, GroupValue as InputGroupValue,
-};
use leo_span::Span;
use serde::{Deserialize, Serialize};
@@ -52,17 +49,6 @@ impl GroupValue {
}
}
-impl<'ast> From> for GroupValue {
- fn from(ast_group: InputGroupValue) -> Self {
- let span = Span::from(ast_group.span);
-
- match ast_group.value {
- InputGroupRepresentation::Single(number) => GroupValue::Single(number.to_string().into(), span),
- InputGroupRepresentation::Tuple(tuple) => GroupValue::Tuple(GroupTuple::from(tuple)),
- }
- }
-}
-
impl fmt::Display for GroupValue {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
@@ -83,19 +69,6 @@ pub struct GroupTuple {
pub span: Span,
}
-impl<'ast> From> for GroupTuple {
- fn from(ast_group: InputGroupTuple<'ast>) -> Self {
- let ast_x = ast_group.x;
- let ast_y = ast_group.y;
-
- Self {
- x: GroupCoordinate::from(ast_x),
- y: GroupCoordinate::from(ast_y),
- span: Span::from(ast_group.span),
- }
- }
-}
-
impl fmt::Display for GroupTuple {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({}, {})", self.x, self.y)
diff --git a/ast/src/input/program_input/registers.rs b/ast/src/input/definition.rs
similarity index 66%
rename from ast/src/input/program_input/registers.rs
rename to ast/src/input/definition.rs
index 7fdd7fc276..b98eab8279 100644
--- a/ast/src/input/program_input/registers.rs
+++ b/ast/src/input/definition.rs
@@ -14,9 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use crate::{InputValue, Parameter};
-use leo_input::{definitions::Definition, InputParserError};
+use super::*;
+use crate::{Expression, Identifier, Type};
-use indexmap::IndexMap;
-
-record_input_section!(Registers);
+/// A single definition inside a section in a state or an input file.
+/// Definitions should be structured as: `: = ;`
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct Definition {
+ pub type_: Type,
+ pub name: Identifier,
+ pub value: Expression,
+ pub span: Span,
+}
diff --git a/ast/src/input/input.rs b/ast/src/input/input.rs
index e4465300a9..f5c6d9658f 100644
--- a/ast/src/input/input.rs
+++ b/ast/src/input/input.rs
@@ -14,126 +14,26 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use crate::{ConstantInput, InputValue, MainInput, ProgramInput, ProgramState, Record, Registers, State, StateLeaf};
-use leo_input::{
- files::{File, TableOrSection},
- InputParserError,
-};
-use leo_span::Symbol;
+use super::*;
+use leo_errors::AstError;
-#[derive(Clone, PartialEq, Eq)]
+/// Input data which includes [`ProgramInput`] and [`ProgramState`].
+#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Input {
- name: String,
- program_input: ProgramInput,
- program_state: ProgramState,
+ pub program_input: ProgramInput,
+ pub program_state: ProgramState,
}
-impl Default for Input {
- fn default() -> Self {
- Self {
- name: "default".to_owned(),
- program_input: ProgramInput::new(),
- program_state: ProgramState::new(),
- }
- }
+/// A raw unprocessed input or state file data. Used for future conversion
+/// into [`ProgramInput`] or [`ProgramState`].
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct ParsedInputFile {
+ pub sections: Vec,
}
-#[allow(clippy::len_without_is_empty)]
impl Input {
- pub fn new() -> Self {
- Self::default()
- }
-
- /// Returns an empty version of this struct with `None` values.
- /// Called during constraint synthesis to provide private input variables.
- pub fn empty(&self) -> Self {
- let input = self.program_input.empty();
- let state = self.program_state.empty();
-
- Self {
- name: self.name.clone(),
- program_input: input,
- program_state: state,
- }
- }
-
- /// Returns the number of input variables to pass into the `main` program function
- pub fn len(&self) -> usize {
- self.program_input.len() + self.program_state.len()
- }
-
- /// Manually set the input variables to the `main` program function
- pub fn set_main_input(&mut self, input: MainInput) {
- self.program_input.main = input;
- }
-
- /// Parse all input variables included in a file and store them in `self`.
- pub fn parse_input(&mut self, file: File) -> Result<(), InputParserError> {
- for entry in file.entries.into_iter() {
- match entry {
- TableOrSection::Section(section) => {
- self.program_input.parse(section)?;
- }
- TableOrSection::Table(table) => return Err(InputParserError::table(table)),
- }
- }
-
- Ok(())
- }
-
- /// Parse all state variables included in a file and store them in `self`.
- pub fn parse_state(&mut self, file: File) -> Result<(), InputParserError> {
- for entry in file.entries.into_iter() {
- match entry {
- TableOrSection::Section(section) => return Err(InputParserError::section(section.header)),
- TableOrSection::Table(table) => {
- self.program_state.parse(table)?;
- }
- }
- }
-
- Ok(())
- }
-
- /// Returns the main function input value with the given `name`.
- #[allow(clippy::ptr_arg)]
- pub fn get(&self, name: Symbol) -> Option