mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-25 18:42:26 +03:00
Merge branch 'master' of github.com:AleoHQ/leo into fix/synthesis-error-stack-overflow
This commit is contained in:
commit
c686115305
29
.licenserc.json
Normal file
29
.licenserc.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"**/*.rs": [
|
||||
"// Copyright (C) 2019-2020 Aleo Systems Inc.",
|
||||
"// This file is part of the Leo library.",
|
||||
"",
|
||||
"// The Leo library is free software: you can redistribute it and/or modify",
|
||||
"// it under the terms of the GNU General Public License as published by",
|
||||
"// the Free Software Foundation, either version 3 of the License, or",
|
||||
"// (at your option) any later version.",
|
||||
"",
|
||||
"// The Leo library is distributed in the hope that it will be useful,",
|
||||
"// but WITHOUT ANY WARRANTY; without even the implied warranty of",
|
||||
"// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
|
||||
"// GNU General Public License for more details.",
|
||||
"",
|
||||
"// You should have received a copy of the GNU General Public License",
|
||||
"// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.",
|
||||
""
|
||||
],
|
||||
"ignore": [
|
||||
".cargo",
|
||||
".github",
|
||||
".resources",
|
||||
".travis",
|
||||
"examples",
|
||||
"target/"
|
||||
]
|
||||
}
|
||||
|
82
Cargo.lock
generated
82
Cargo.lock
generated
@ -33,6 +33,18 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
@ -70,6 +82,12 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.12.3"
|
||||
@ -134,6 +152,17 @@ dependencies = [
|
||||
"opaque-debug 0.2.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "blake2b_simd"
|
||||
version = "0.5.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"arrayvec",
|
||||
"constant_time_eq",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.7.3"
|
||||
@ -321,6 +350,12 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.7.0"
|
||||
@ -527,6 +562,26 @@ dependencies = [
|
||||
"generic-array 0.14.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "3.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "142995ed02755914747cc6ca76fc7e4583cd18578746716d0508ea6ed558b9ff"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.4.6"
|
||||
@ -1070,6 +1125,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"colored",
|
||||
"dirs",
|
||||
"env_logger",
|
||||
"from-pest",
|
||||
"lazy_static",
|
||||
@ -1095,6 +1151,7 @@ dependencies = [
|
||||
"snarkos-utilities",
|
||||
"thiserror",
|
||||
"toml",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1824,6 +1881,17 @@ version = "0.1.57"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"redox_syscall",
|
||||
"rust-argon2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.3.9"
|
||||
@ -1866,7 +1934,7 @@ version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12427a5577082c24419c9c417db35cfeb65962efc7675bb6b0d5f1f9d315bfe6"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.12.3",
|
||||
"bytes",
|
||||
"encoding_rs",
|
||||
"futures-core",
|
||||
@ -1906,6 +1974,18 @@ dependencies = [
|
||||
"librocksdb-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-argon2"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017"
|
||||
dependencies = [
|
||||
"base64 0.11.0",
|
||||
"blake2b_simd",
|
||||
"constant_time_eq",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.16"
|
||||
|
@ -31,6 +31,7 @@ snarkos-utilities = { git = "ssh://git@github.com/AleoHQ/snarkOS.git", package =
|
||||
|
||||
clap = { version = "2.33.3" }
|
||||
colored = { version = "2.0" }
|
||||
dirs = { version = "3.0.1" }
|
||||
env_logger = { version = "0.7" }
|
||||
from-pest = { version = "0.3.1" }
|
||||
lazy_static = { version = "1.4.0" }
|
||||
@ -44,6 +45,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = { version = "1.0" }
|
||||
toml = { version = "0.5" }
|
||||
thiserror = { version = "1.0" }
|
||||
zip = { version = "0.5" }
|
||||
|
||||
[dev-dependencies]
|
||||
rusty-hook = { version = "0.11.2" }
|
||||
|
826
README.md
826
README.md
@ -3,782 +3,116 @@
|
||||
![CI](https://github.com/AleoHQ/leo/workflows/CI/badge.svg)
|
||||
[![codecov](https://codecov.io/gh/AleoHQ/leo/branch/master/graph/badge.svg?token=S6MWO60SYL)](https://codecov.io/gh/AleoHQ/leo)
|
||||
|
||||
# Overview
|
||||
Leo is a functional, statically-typed programming language built for writing private applications.
|
||||
|
||||
## Compiler Architecture
|
||||
## <a name='TableofContents'></a>Table of Contents
|
||||
|
||||
<!-- generated by mermaid compile action - START -->
|
||||
![~mermaid diagram 1~](/.resources/README-md-1.png)
|
||||
<details>
|
||||
<summary>Mermaid markup</summary>
|
||||
* [1. Overview](#1-overview)
|
||||
* [2. Build Guide](#2-build-guide)
|
||||
* [2.1 Install Rust](#21-install-rust)
|
||||
* [2.2a Build from Crates.io](#22a-build-from-cratesio)
|
||||
* [2.2b Build from Source Code](#22b-build-from-source-code)
|
||||
* [3. Quick Start](#3-quick-start)
|
||||
* [4. Documentation](#4-documentation)
|
||||
* [5. Contributing](#5-contributing)
|
||||
* [6. License](#6-license)
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
Pass1(Syntax Parser) -- ast --> Pass2(Type Resolver)
|
||||
|
||||
Pass2 -- imports --> Pass3(Import Resolver)
|
||||
Pass3 -- statements --> Pass4
|
||||
|
||||
Pass2 -- statements --> Pass4(Synthesizer)
|
||||
|
||||
Pass4 -- constraints --> Pass5(Program)
|
||||
```
|
||||
|
||||
</details>
|
||||
<!-- generated by mermaid compile action - END -->
|
||||
## 1. Overview
|
||||
Welcome to the Leo programming language.
|
||||
|
||||
## Language Specification
|
||||
Leo exists to provide a simple high-level language that abstracts low-level cryptographic concepts and makes it easy to
|
||||
integrate private applications into your stack. Leo compiles to R1CS circuits making zero-knowledge proofs practical.
|
||||
With Leo, you can support zero-knowledge tokens, private stable coins, and decentralized marketplaces.
|
||||
|
||||
* Programs should be formatted:
|
||||
1. Import definitions
|
||||
2. Circuit definitions
|
||||
3. Function definitions
|
||||
The syntax of Leo is influenced by JavaScript, Python, Scala, and Rust with a strong emphasis on readability and ease-of-use.
|
||||
Leo provides developers with never before seen tools to sanity check circuits including unit tests, integration tests, and console functions.
|
||||
|
||||
## Defining Variables
|
||||
Leo supports `let` and `const` keywords for variable definition.
|
||||
Leo is one part of a greater ecosystem for building private applications on [Aleo](https://aleo.org/). If your goal is to build a user experience
|
||||
on the web that is both truly personal and truly private, then we recommend downloading the [Aleo Studio IDE](https://aleo.studio/)
|
||||
and checking out the [Aleo Package Manager]().
|
||||
|
||||
```let a = true;``` defines an **allocated** program variable `a` with boolean value `true`.
|
||||
## 2. Build Guide
|
||||
|
||||
```const a = true;``` defines a **constant** program variable `a` with boolean value `true`.
|
||||
### 2.1 Install Rust
|
||||
|
||||
**Allocated** variables define private variables in the constraint system. Their value is constrained in the circuit on initialization.
|
||||
We recommend installing Rust using [rustup](https://www.rustup.rs/). You can install `rustup` as follows:
|
||||
|
||||
**Constant** variables do not define a variable in the constraint system. Their value is constrained in the circuit on computation with an **allocated** variable.
|
||||
**Constant** variables cannot be mutable. They have the same functionality as `const` variables in other languages.
|
||||
```js
|
||||
function add_one() -> {
|
||||
let a = 0u8; // allocated, value enforced on this line
|
||||
const b = 1u8; // constant, value not enforced yet
|
||||
- macOS or Linux:
|
||||
```bash
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
```
|
||||
|
||||
return a + b // allocated, computed value is enforced to be the sum of both values
|
||||
}
|
||||
```
|
||||
Computations are expressed in terms of arithmetic circuits, in particular rank-1 quadratic constraint systems. Thus computing on an allocated variable always results in another allocated variable.
|
||||
|
||||
## Mutability
|
||||
* All defined variables in Leo are immutable by default.
|
||||
* Variables can be made mutable with the `mut` keyword.
|
||||
|
||||
```js
|
||||
function main() {
|
||||
let a = 0u32;
|
||||
//a = 1 <- Will fail
|
||||
|
||||
let mut b = 0u32;
|
||||
b = 1; // <- Ok
|
||||
}
|
||||
```
|
||||
|
||||
## Addresses
|
||||
|
||||
Addresses are defined to enable compiler-optimized routines for parsing and operating over addresses. These semantics will be accompanied by a standard library in a future sprint.
|
||||
|
||||
```js
|
||||
function main(owner: address) {
|
||||
let sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
|
||||
let receiver: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||
assert_eq!(owner, sender);
|
||||
assert_eq!(sender, receiver);
|
||||
}
|
||||
```
|
||||
|
||||
## Booleans
|
||||
|
||||
Explicit types are optional.
|
||||
```js
|
||||
function main() -> bool {
|
||||
let a: bool = true || false;
|
||||
let b = false && false;
|
||||
let c = 1u32 == 1u32;
|
||||
return a
|
||||
}
|
||||
```
|
||||
|
||||
## Numbers
|
||||
* The definition of a number must include an explicit type.
|
||||
* After assignment, you can choose to explicitly add the type or let the compiler interpret implicitly.
|
||||
* Type casting is not supported.
|
||||
* Comparators are not supported.
|
||||
|
||||
### Integers
|
||||
Supported integer types: `u8`, `u16`, `u32`, `u64`, `u128`
|
||||
```js
|
||||
function main() -> u32 {
|
||||
let a = 2u32; // explicit type
|
||||
let a: u32 = 1 + 1; // explicit type
|
||||
|
||||
let b = a - 1; // implicit type
|
||||
let c = b * 4;
|
||||
let d = c / 2;
|
||||
let e = d ** 3;
|
||||
return e
|
||||
}
|
||||
```
|
||||
|
||||
### Field Elements
|
||||
```js
|
||||
function main() -> field {
|
||||
let a = 1000field; // explicit type
|
||||
let a: field = 21888242871839275222246405745257275088548364400416034343698204186575808495617; // explicit type
|
||||
let b = a + 1; // implicit type
|
||||
let c = b - 1;
|
||||
let d = c * 4;
|
||||
let e = d / 2;
|
||||
return e
|
||||
}
|
||||
```
|
||||
|
||||
### Group Elements
|
||||
An affine point on the elliptic curve passed into the Leo compiler forms a group.
|
||||
Leo supports this set as a primitive data type.
|
||||
|
||||
```js
|
||||
function main() -> group {
|
||||
let a = 1000group; // explicit type
|
||||
let a = (21888242871839275222246405745257275088548364400416034343698204186575808495617, 21888242871839275222246405745257275088548364400416034343698204186575808495617)group; // explicit type
|
||||
let b = a + 0; // implicit type
|
||||
let c = b - 0;
|
||||
return c
|
||||
}
|
||||
```
|
||||
|
||||
### Operator Assignment Statements
|
||||
```js
|
||||
function main() -> u32 {
|
||||
let mut a = 10;
|
||||
a += 5;
|
||||
a -= 10;
|
||||
a *= 5;
|
||||
a /= 5;
|
||||
a **= 2;
|
||||
|
||||
return a
|
||||
}
|
||||
```
|
||||
|
||||
## Arrays
|
||||
Leo supports static arrays with fixed length.
|
||||
```js
|
||||
function main() -> u32[2] {
|
||||
// initialize an integer array with integer values
|
||||
let mut a: u32[3] = [1, 2, 3];
|
||||
|
||||
// set a mutable member to a value
|
||||
a[2] = 4;
|
||||
|
||||
// initialize an array of 4 values all equal to 42
|
||||
let b = [42u8; 4];
|
||||
|
||||
// initialize an array of 5 values copying all elements of b using a spread
|
||||
let c = [1, ...b];
|
||||
|
||||
// initialize an array copying a slice from `c`
|
||||
let d = c[1..3];
|
||||
|
||||
// initialize a field array
|
||||
let e = [5field; 2];
|
||||
|
||||
// initialize a boolean array
|
||||
let f = [true, false || true, true];
|
||||
|
||||
return d
|
||||
}
|
||||
```
|
||||
|
||||
### Multidimensional Arrays
|
||||
```js
|
||||
function main() -> u32[3][2] {
|
||||
let m = [[0u32, 0u32], [0u32, 0u32]];
|
||||
|
||||
let m: u32[3][2] = [[0; 3]; 2];
|
||||
|
||||
return m
|
||||
}
|
||||
```
|
||||
|
||||
## Conditionals
|
||||
|
||||
Branching in Leo is different than traditional programming languages. Leo developers should keep in mind that every program compiles to a circuit which represents
|
||||
all possible evaluations.
|
||||
|
||||
### If Else Ternary Expression
|
||||
Ternary `if [cond] ? [first] : [second];` expressions are the cheapest form of conditional.
|
||||
Since `first` and `second` are expressions, we can resolve their values before proceeding execution.
|
||||
In the underlying circuit, this is a single bit multiplexer.
|
||||
|
||||
```js
|
||||
function main() -> u32 {
|
||||
let y = if 3==3 ? 1 : 5;
|
||||
return y
|
||||
}
|
||||
```
|
||||
|
||||
### If Else Conditional Statement
|
||||
Leo supports the traditional `if [cond] { [first] } else { [second] }` which can be chained using `else if`.
|
||||
Since `first` and `second` are one or more statements, they resolve to separate circuits which will all be evaluated.
|
||||
In the underlying circuit this can be thought of as a demultiplexer.
|
||||
```js
|
||||
function main(a: bool, b: bool) -> u32 {
|
||||
let mut res = 0u32;
|
||||
|
||||
if a {
|
||||
res = 1;
|
||||
} else if b {
|
||||
res = 2;
|
||||
} else {
|
||||
res = 3;
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
```
|
||||
|
||||
### For loop
|
||||
```js
|
||||
function main() -> fe {
|
||||
let mut a = 1field;
|
||||
for i in 0..4 {
|
||||
a = a + 1;
|
||||
}
|
||||
return a
|
||||
}
|
||||
```
|
||||
|
||||
## Functions
|
||||
```js
|
||||
function test1(a : u32) -> u32 {
|
||||
return a + 1
|
||||
}
|
||||
|
||||
function test2(b: fe) -> field {
|
||||
return b * 2field
|
||||
}
|
||||
|
||||
function test3(c: bool) -> bool {
|
||||
return c && true
|
||||
}
|
||||
|
||||
function main() -> u32 {
|
||||
return test1(5)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Function Scope
|
||||
```js
|
||||
function foo() -> field {
|
||||
// return myGlobal <- not allowed
|
||||
return 42field
|
||||
}
|
||||
|
||||
function main() -> field {
|
||||
let myGlobal = 42field;
|
||||
return foo()
|
||||
}
|
||||
```
|
||||
|
||||
### Multiple returns
|
||||
Functions can return tuples whose types are specified in the function signature.
|
||||
```js
|
||||
function test() -> (u32, u32[2]) {
|
||||
return (1, [2, 3])
|
||||
}
|
||||
|
||||
function main() -> u32[3] {
|
||||
let (a, b) = test();
|
||||
// (a, u32[2] b) = test() <- explicit type also works
|
||||
return [a, ...b]
|
||||
}
|
||||
```
|
||||
|
||||
### Function inputs
|
||||
Main function inputs are allocated private variables in the program's constraint system.
|
||||
`a` is implicitly private.
|
||||
```js
|
||||
function main(a: field) -> field {
|
||||
return a
|
||||
}
|
||||
```
|
||||
Normal function inputs are passed by value.
|
||||
```js
|
||||
function test(mut a: u32) {
|
||||
a = 0;
|
||||
}
|
||||
|
||||
function main() -> u32 {
|
||||
let a = 1;
|
||||
test(a);
|
||||
|
||||
return a // <- returns 1
|
||||
}
|
||||
```
|
||||
|
||||
## Circuits
|
||||
Circuits in Leo are similar to classes in object oriented langauges. Circuits are defined above functions in a Leo program. Circuits can have one or more members.
|
||||
|
||||
#### Circuit member values
|
||||
Members can be defined as fields which hold primitive values.
|
||||
```js
|
||||
circuit Point {
|
||||
x: u32
|
||||
y: u32
|
||||
}
|
||||
function main() -> u32 {
|
||||
let p = Point {x: 1, y: 0};
|
||||
return p.x
|
||||
}
|
||||
```
|
||||
|
||||
#### Circuit member functions
|
||||
Members can also be defined as functions.
|
||||
```js
|
||||
circuit Foo {
|
||||
function echo(x: u32) -> u32 {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
function main() -> u32 {
|
||||
let c = Foo { };
|
||||
return c.echo(1u32)
|
||||
}
|
||||
```
|
||||
|
||||
#### Circuit member static functions
|
||||
Circuit functions can be made static, enabling them to be called without instantiation.
|
||||
```js
|
||||
circuit Foo {
|
||||
static function echo(x: u32) -> u32 {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
function main() -> u32 {
|
||||
return Foo::echo(1u32)
|
||||
}
|
||||
```
|
||||
|
||||
#### `Self` and `self`
|
||||
The `Self` keyword is supported in circuit functions.
|
||||
```js
|
||||
circuit Circ {
|
||||
b: bool
|
||||
|
||||
static function new() -> Self { // Self resolves to Foo
|
||||
return Self { b: true }
|
||||
}
|
||||
}
|
||||
|
||||
function main() -> bool {
|
||||
let c = Foo::new();
|
||||
return c.b
|
||||
}
|
||||
```
|
||||
|
||||
The `self` keyword references the circuit's members.
|
||||
```rust
|
||||
circuit Foo {
|
||||
b: bool
|
||||
- Windows (64-bit):
|
||||
|
||||
function bar() -> bool {
|
||||
return self.b
|
||||
}
|
||||
|
||||
function baz() -> bool {
|
||||
return self.bar()
|
||||
}
|
||||
}
|
||||
Download the [Windows 64-bit executable](https://win.rustup.rs/x86_64) and follow the on-screen instructions.
|
||||
|
||||
function main() -> bool {
|
||||
let c = Foo { b: true };
|
||||
|
||||
return c.baz()
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Imports
|
||||
Leo supports importing functions
|
||||
}
|
||||
} and circuits by name into the current file with the following syntax:
|
||||
|
||||
```js
|
||||
import [package].[name];
|
||||
```
|
||||
|
||||
#### Import Aliases
|
||||
To import a name using an alias:
|
||||
```js
|
||||
import [package].[name] as [alias];
|
||||
```
|
||||
|
||||
#### Import Multiple
|
||||
To import multiple names from the same package:
|
||||
```js
|
||||
import [package].(
|
||||
[name_1],
|
||||
[name_2] as [alias],
|
||||
);
|
||||
```
|
||||
|
||||
#### Import Star
|
||||
To import all symbols from a package:
|
||||
Note that this will only import symbols from the package library `lib.leo` file.
|
||||
```js
|
||||
import [package].*;
|
||||
```
|
||||
|
||||
### Local
|
||||
You can import from a local file in the same package using its direct path.
|
||||
`src/` directory by using its `[file].leo` as the `[package]` name.
|
||||
|
||||
```js
|
||||
import [file].[name];
|
||||
```
|
||||
|
||||
#### Example:
|
||||
`src/bar.leo`
|
||||
```js
|
||||
circuit Bar {
|
||||
b: u32
|
||||
}
|
||||
|
||||
function baz() -> u32 {
|
||||
return 1u32
|
||||
}
|
||||
```
|
||||
|
||||
`src/main.leo`
|
||||
```js
|
||||
import bar.(
|
||||
Bar,
|
||||
baz
|
||||
);
|
||||
|
||||
function main() {
|
||||
const bar = Bar { b: 1u32};
|
||||
const z = baz();
|
||||
}
|
||||
```
|
||||
|
||||
### Foreign
|
||||
You can import from a foreign package in the `imports/` directory using its `[package]` name.
|
||||
```js
|
||||
import [package].[name];
|
||||
```
|
||||
|
||||
#### Example:
|
||||
`imports/bar/src/lib.leo`
|
||||
```js
|
||||
circuit Bar {
|
||||
b: u32
|
||||
}
|
||||
```
|
||||
|
||||
`src/main.leo`
|
||||
```js
|
||||
import bar.Bar;
|
||||
|
||||
function main() {
|
||||
const bar = Bar { b: 1u32 };
|
||||
}
|
||||
```
|
||||
|
||||
### Package Paths
|
||||
Leo treats directories as package names when importing.
|
||||
```js
|
||||
import [package].[directory].[file].[name]
|
||||
```
|
||||
|
||||
#### Example:
|
||||
We wish to import the `Baz` circuit from the `baz.leo` file in the `bar` directory in the `foo` package
|
||||
|
||||
|
||||
`imports/foo/src/bar/baz.leo`
|
||||
```js
|
||||
circuit Baz {
|
||||
b: u32
|
||||
}
|
||||
```
|
||||
|
||||
`src/main.leo`
|
||||
```js
|
||||
import foo.bar.baz.Baz;
|
||||
|
||||
function main() {
|
||||
const baz = Baz { b: 1u32 };
|
||||
}
|
||||
```
|
||||
|
||||
## Constraints
|
||||
|
||||
### Assert Equals
|
||||
This will enforce that the two values are equal in the constraint system.
|
||||
|
||||
```js
|
||||
function main() {
|
||||
assert_eq!(45, 45);
|
||||
- Windows (32-bit):
|
||||
|
||||
assert_eq!(2fe, 2fe);
|
||||
|
||||
assert_eq!(true, true);
|
||||
}
|
||||
Download the [Windows 32-bit executable](https://win.rustup.rs/i686) and follow the on-screen instructions.
|
||||
|
||||
### 2.2a Build from Crates.io
|
||||
|
||||
We recommend installing Leo this way. In your terminal, run:
|
||||
|
||||
```bash
|
||||
cargo install leo
|
||||
```
|
||||
|
||||
## Testing
|
||||
Now to use Leo, in your terminal, run:
|
||||
```bash
|
||||
leo
|
||||
```
|
||||
|
||||
### 2.2b Build from Source Code
|
||||
|
||||
Use the `test` keyword to add tests to a leo program. Tests must have 0 function inputs and 0 function returns.
|
||||
Alternatively, you can install Leo by building from the source code as follows:
|
||||
|
||||
```js
|
||||
function main(a: u32) -> u32 {
|
||||
return a
|
||||
}
|
||||
```bash
|
||||
# Download the source code
|
||||
git clone https://github.com/AleoHQ/leo
|
||||
cd leo
|
||||
|
||||
test function expect_pass() {
|
||||
let a = 1u32;
|
||||
|
||||
let res = main(a);
|
||||
|
||||
assert_eq!(res, 1u32);
|
||||
}
|
||||
|
||||
test function expect_fail() {
|
||||
assert_eq!(1u8, 0u8);
|
||||
}
|
||||
# Build in release mode
|
||||
$ cargo build --release
|
||||
```
|
||||
|
||||
## Logging
|
||||
|
||||
Leo supports `print!`, `debug!`, and `error!` logging macros.
|
||||
|
||||
The first argument a macro receives is a format string. This must be a string literal. The power of the formatting string is in the `{}`s contained.
|
||||
|
||||
Additional parameters passed to a macro replace the `{}`s within the formatting string in the order given.
|
||||
|
||||
#### `print!`
|
||||
Directly calls the `println!` macro in rust.
|
||||
```js
|
||||
function main(a: u32) {
|
||||
print!("a is {}", a);
|
||||
}
|
||||
This will generate an executable under the `./target/release` directory. To run snarkOS, run the following command:
|
||||
```bash
|
||||
./target/release/leo
|
||||
```
|
||||
|
||||
#### `debug!`
|
||||
Enabled by specifying the `-d` flag after a Leo command.
|
||||
```js
|
||||
function main(a: u32) {
|
||||
debug!("a is {}", a);
|
||||
}
|
||||
## 3. Quick Start
|
||||
|
||||
Use the Leo CLI to create a new project
|
||||
|
||||
```bash
|
||||
# create a new `hello_world` Leo project
|
||||
leo new hello_world
|
||||
cd hello_world
|
||||
|
||||
# build & setup & prove & verify
|
||||
leo run
|
||||
```
|
||||
|
||||
The `leo new` command creates a new Leo project with a given name.
|
||||
|
||||
#### `error!`
|
||||
Prints the error to console.
|
||||
```js
|
||||
function main(a: u32) {
|
||||
error!("a is {}", a);
|
||||
}
|
||||
```
|
||||
The `leo run` command will compile the main program, generate keys for a trusted setup, fetch inputs, generate a proof and verify it.
|
||||
|
||||
# Leo Inputs
|
||||
Congratulations! You've just run your first Leo program.
|
||||
|
||||
Private inputs for a Leo program are specified in the `inputs/` directory. The syntax for an input file is a limited subset of the Leo program syntax. The default inputs file is `inputs/inputs.leo`.
|
||||
## 4. Documentation
|
||||
|
||||
## Sections
|
||||
A Leo input file is made up of sections. Sections are defined by a section header in brackets followed by one or more input definitions.
|
||||
* [Hello World - Next Steps](https://developer.aleo.org/developer/getting_started/hello_world)
|
||||
* [Leo Language Documentation](https://developer.aleo.org/developer/language/layout)
|
||||
* [Leo CLI Documentation](https://developer.aleo.org/developer/cli/new)
|
||||
* [Homepage](https://developer.aleo.org/developer/getting_started/overview)
|
||||
|
||||
Section headers specify the target file which must have a main function with matching input names and types.
|
||||
## 5. Contributing
|
||||
|
||||
Please see our guidelines in the [developer documentation](https://developer.aleo.org/developer/additional_material/contributing)
|
||||
|
||||
`inputs/inputs.leo`
|
||||
Thank you for helping make Leo better!
|
||||
|
||||
```rust
|
||||
[main] // <- section header
|
||||
a: u32 = 1;
|
||||
b: u32 = 2;
|
||||
```
|
||||
|
||||
`src/main.leo`
|
||||
|
||||
```rust
|
||||
function main(a: u32, b: u32) -> u32 {
|
||||
let c: u32 = a + b;
|
||||
return c
|
||||
}
|
||||
```
|
||||
|
||||
## Input Definitions
|
||||
|
||||
### Supported types
|
||||
```rust
|
||||
[main]
|
||||
a: bool = true; // <- booleans
|
||||
b: u8 = 2; // <- integers
|
||||
c: field = 0; // <- fields
|
||||
d: group = (0, 1)group // <- group tuples
|
||||
```
|
||||
|
||||
### Arrays
|
||||
```rust
|
||||
[main]
|
||||
a: u8[4] = [0u8; 4]; // <- single
|
||||
b: u8[2][3] = [[0u8; 2]; 3]; // <- multi-dimensional
|
||||
```
|
||||
|
||||
# Leo CLI
|
||||
|
||||
## Develop
|
||||
|
||||
### `leo new`
|
||||
|
||||
To setup a new package, run:
|
||||
```
|
||||
leo new {$NAME}
|
||||
```
|
||||
This will create a new directory with a given package name. The new package will have a directory structure as follows:
|
||||
```
|
||||
- inputs # Your program inputs
|
||||
- inputs.leo # Your program inputs for main.leo
|
||||
- outputs # Your program outputs
|
||||
- src
|
||||
- main.leo # Your program
|
||||
- tests
|
||||
- test.leo # Your program tests
|
||||
- Leo.toml # Your program manifest
|
||||
```
|
||||
|
||||
#### Flags
|
||||
```rust
|
||||
leo new {$Name} --bin
|
||||
```
|
||||
This will create a new directory with a given package name. The new package will have a directory structure as above.
|
||||
|
||||
```rust
|
||||
leo new {$Name} --lib
|
||||
```
|
||||
This will create a new directory with a given package name. The new package will have a directory structure as follows:
|
||||
```
|
||||
- src
|
||||
- lib.leo # Your program library
|
||||
- Leo.toml # Your program manifest
|
||||
```
|
||||
|
||||
### `leo init`
|
||||
|
||||
To initialize an existing directory, run:
|
||||
```
|
||||
leo init
|
||||
```
|
||||
This will initialize the current directory with the same package directory setup.
|
||||
|
||||
#### Flags
|
||||
`leo init` supports the same flags as `leo new`
|
||||
```rust
|
||||
leo init --bin
|
||||
```
|
||||
```rust
|
||||
leo init --lib
|
||||
```
|
||||
|
||||
|
||||
### `leo build`
|
||||
|
||||
To compile your program and verify that it builds properly, run:
|
||||
```
|
||||
leo build
|
||||
```
|
||||
|
||||
### `leo test`
|
||||
|
||||
To execute unit tests on your program, run:
|
||||
```
|
||||
leo test
|
||||
```
|
||||
The results of test compilation and the constraint system will be printed:
|
||||
```
|
||||
INFO leo Running 2 tests
|
||||
INFO leo test language::expect_pass compiled. Constraint system satisfied: true
|
||||
ERROR leo test language::expect_fail errored: Assertion 1u8 == 0u8 failed
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
### `leo setup`
|
||||
|
||||
To perform the program setup, producing a proving key and verification key, run:
|
||||
```
|
||||
leo setup
|
||||
```
|
||||
Leo uses cryptographic randomness from your machine to perform the setup. The proving key and verification key are stored in the `target` directory as `.leo.pk` and `.leo.vk`:
|
||||
|
||||
```
|
||||
{$LIBRARY}/target/{$PROGRAM}.leo.pk
|
||||
{$LIBRARY}/target/{$PROGRAM}.leo.vk
|
||||
```
|
||||
|
||||
### `leo prove`
|
||||
|
||||
To execute the program and produce an execution proof, run:
|
||||
```
|
||||
leo prove
|
||||
```
|
||||
Leo starts by checking the `target` directory for an existing `.leo.pk` file. If it doesn't exist, it will proceed to run `leo setup` and then continue.
|
||||
|
||||
Next any input files in the `inputs` directory are parsed and all input values are passed to the program.
|
||||
|
||||
Once again, Leo uses cryptographic randomness from your machine to produce the proof. The proof is stored in the `target` directory as `.leo.proof`:
|
||||
|
||||
```
|
||||
{$LIBRARY}/target/{$PROGRAM}.leo.proof
|
||||
```
|
||||
|
||||
### `leo verify`
|
||||
|
||||
To verify the program proof, run:
|
||||
```
|
||||
leo verify
|
||||
```
|
||||
Leo starts by checking the `target` directory for an existing `.leo.proof` file. If it doesn't exist, it will proceed to run `leo prove` and then continue.
|
||||
|
||||
After the verifier is run, Leo will output either `true` or `false` based on the verification.
|
||||
|
||||
## Remote
|
||||
|
||||
To use remote compilation features, start by authentication with:
|
||||
```
|
||||
leo login
|
||||
```
|
||||
You will proceed to authenticate using your username and password. Next, Leo will parse your `Leo.toml` file for `remote = True` to confirm whether remote compilation is enabled.
|
||||
|
||||
If remote compilation is enabled, Leo syncs your workspace so when you run `leo build`, `leo test`, `leo setup` and `leo prove`, your program will run the program setup and execution performantly on remote machines.
|
||||
|
||||
This speeds up the testing cycle and helps the developer to iterate significantly faster.
|
||||
|
||||
## Publish
|
||||
|
||||
To package your program as a gadget and publish it online, run:
|
||||
```
|
||||
leo publish
|
||||
```
|
||||
Leo will proceed to snapshot your directory and upload your directory to the circuit manager. Leo will verify that `leo build` succeeds and that `leo test` passes without error.
|
||||
|
||||
If your gadget name has already been taken, `leo publish` will fail.
|
||||
|
||||
## Deploy
|
||||
|
||||
To deploy your program to Aleo, run:
|
||||
```
|
||||
leo deploy
|
||||
```
|
||||
|
||||
# Install
|
||||
|
||||
To install Leo from source, in the root directory of the repository, run:
|
||||
```
|
||||
cargo install --path .
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
- Change `target` directory to some other directory to avoid collision.
|
||||
- Figure out how `leo prove` should take in assignments.
|
||||
- Come up with a serialization format for `.leo.pk`, `.leo.vk`, and `.leo.proof`.
|
||||
## 6. License
|
||||
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE.md)
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use leo_ast::{errors::ParserError, files::File, LeoAst};
|
||||
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{access::*, ast::Rule};
|
||||
|
||||
use pest_ast::FromPest;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::RangeOrExpression, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
access::{ArrayAccess, MemberAccess, TupleAccess},
|
||||
ast::Rule,
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, expressions::TupleExpression, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::Identifier, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod access;
|
||||
pub use access::*;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::Identifier, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, values::PositiveNumber, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::{span_into_string, Rule},
|
||||
SpanDef,
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
annotations::{AnnotationArguments, AnnotationName, AnnotationSymbol},
|
||||
ast::Rule,
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod annotations;
|
||||
pub use annotations::*;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
//! Abstract syntax tree (ast) representation from leo.pest.
|
||||
use crate::{
|
||||
common::Identifier,
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, circuits::CircuitMember, common::Identifier, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::Identifier, expressions::Expression, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::Identifier, types::Type, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::Static, functions::Function, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
circuits::{CircuitFieldDefinition, CircuitFunction},
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod circuit;
|
||||
pub use circuit::*;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{access::AssigneeAccess, ast::Rule, common::Identifier, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest_ast::FromPest;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest_ast::FromPest;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::{span_into_string, Rule},
|
||||
SpanDef,
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest_ast::FromPest;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod assignee;
|
||||
pub use assignee::*;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest_ast::FromPest;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, expressions::Expression, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::Range, expressions::Expression};
|
||||
|
||||
use pest_ast::FromPest;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, expressions::Expression, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::Spread, expressions::Expression};
|
||||
|
||||
use pest_ast::FromPest;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest_ast::FromPest;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
common::{Identifier, Mutable},
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::VariableName, types::Type, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -6,16 +6,16 @@ use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::formatted_parameter))]
|
||||
pub struct FormattedParameter<'ast> {
|
||||
#[pest_ast(rule(Rule::console_assert))]
|
||||
pub struct ConsoleAssert<'ast> {
|
||||
pub expression: Expression<'ast>,
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for FormattedParameter<'ast> {
|
||||
impl<'ast> fmt::Display for ConsoleAssert<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.expression)
|
||||
write!(f, "assert({})", self.expression)
|
||||
}
|
||||
}
|
37
ast/src/console/console_debug.rs
Normal file
37
ast/src/console/console_debug.rs
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, console::FormattedString, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::console_debug))]
|
||||
pub struct ConsoleDebug<'ast> {
|
||||
pub string: FormattedString<'ast>,
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for ConsoleDebug<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "debug({})", self.string)
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
use crate::{ast::Rule, SpanDef};
|
||||
use crate::{ast::Rule, console::FormattedString, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
@ -6,15 +6,16 @@ use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::print))]
|
||||
pub struct Print<'ast> {
|
||||
#[pest_ast(rule(Rule::console_error))]
|
||||
pub struct ConsoleError<'ast> {
|
||||
pub string: FormattedString<'ast>,
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for Print<'ast> {
|
||||
impl<'ast> fmt::Display for ConsoleError<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "print")
|
||||
write!(f, "error({})", self.string)
|
||||
}
|
||||
}
|
28
ast/src/console/console_function.rs
Normal file
28
ast/src/console/console_function.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
console::{ConsoleAssert, ConsoleDebug, ConsoleError, ConsoleLog},
|
||||
};
|
||||
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::console_function))]
|
||||
pub enum ConsoleFunction<'ast> {
|
||||
Assert(ConsoleAssert<'ast>),
|
||||
Debug(ConsoleDebug<'ast>),
|
||||
Error(ConsoleError<'ast>),
|
||||
Log(ConsoleLog<'ast>),
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for ConsoleFunction<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
ConsoleFunction::Assert(assert) => write!(f, "{}", assert),
|
||||
ConsoleFunction::Debug(debug) => write!(f, "{}", debug),
|
||||
ConsoleFunction::Error(error) => write!(f, "{}", error),
|
||||
ConsoleFunction::Log(log) => write!(f, "{}", log),
|
||||
}
|
||||
}
|
||||
}
|
28
ast/src/console/console_function_call.rs
Normal file
28
ast/src/console/console_function_call.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
common::LineEnd,
|
||||
console::{ConsoleFunction, ConsoleKeyword},
|
||||
SpanDef,
|
||||
};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::console_function_call))]
|
||||
pub struct ConsoleFunctionCall<'ast> {
|
||||
pub keyword: ConsoleKeyword<'ast>,
|
||||
pub function: ConsoleFunction<'ast>,
|
||||
pub line_end: LineEnd,
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for ConsoleFunctionCall<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "console.{};", self.function)
|
||||
}
|
||||
}
|
29
ast/src/console/console_keyword.rs
Normal file
29
ast/src/console/console_keyword.rs
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::console_keyword))]
|
||||
pub struct ConsoleKeyword<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
37
ast/src/console/console_log.rs
Normal file
37
ast/src/console/console_log.rs
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, console::FormattedString, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::console_log))]
|
||||
pub struct ConsoleLog<'ast> {
|
||||
pub string: FormattedString<'ast>,
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for ConsoleLog<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "log({})", self.string)
|
||||
}
|
||||
}
|
36
ast/src/console/formatted_container.rs
Normal file
36
ast/src/console/formatted_container.rs
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::formatted_container))]
|
||||
pub struct FormattedContainer<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for FormattedContainer<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{{}}")
|
||||
}
|
||||
}
|
37
ast/src/console/formatted_parameter.rs
Normal file
37
ast/src/console/formatted_parameter.rs
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, expressions::Expression, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::formatted_parameter))]
|
||||
pub struct FormattedParameter<'ast> {
|
||||
pub expression: Expression<'ast>,
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for FormattedParameter<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.expression)
|
||||
}
|
||||
}
|
44
ast/src/console/formatted_string.rs
Normal file
44
ast/src/console/formatted_string.rs
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::{span_into_string, Rule},
|
||||
console::{FormattedContainer, FormattedParameter},
|
||||
SpanDef,
|
||||
};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::formatted_string))]
|
||||
pub struct FormattedString<'ast> {
|
||||
#[pest_ast(outer(with(span_into_string)))]
|
||||
pub string: String,
|
||||
pub containers: Vec<FormattedContainer<'ast>>,
|
||||
pub parameters: Vec<FormattedParameter<'ast>>,
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for FormattedString<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.string)
|
||||
}
|
||||
}
|
29
ast/src/console/mod.rs
Normal file
29
ast/src/console/mod.rs
Normal file
@ -0,0 +1,29 @@
|
||||
pub mod console_assert;
|
||||
pub use console_assert::*;
|
||||
|
||||
pub mod console_debug;
|
||||
pub use console_debug::*;
|
||||
|
||||
pub mod console_error;
|
||||
pub use console_error::*;
|
||||
|
||||
pub mod console_function;
|
||||
pub use console_function::*;
|
||||
|
||||
pub mod console_function_call;
|
||||
pub use console_function_call::*;
|
||||
|
||||
pub mod console_keyword;
|
||||
pub use console_keyword::*;
|
||||
|
||||
pub mod console_log;
|
||||
pub use console_log::*;
|
||||
|
||||
pub mod formatted_container;
|
||||
pub use formatted_container::*;
|
||||
|
||||
pub mod formatted_parameter;
|
||||
pub use formatted_parameter::*;
|
||||
|
||||
pub mod formatted_string;
|
||||
pub use formatted_string::*;
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{annotations::Annotation, ast::Rule, definitions::Definition, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
circuits::Circuit,
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod annotated_definition;
|
||||
pub use annotated_definition::*;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod parser;
|
||||
pub use parser::*;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, errors::SyntaxError};
|
||||
|
||||
use pest::error::Error;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest::error::Error;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::SpreadOrExpression, values::PositiveNumber, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::SpreadOrExpression, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{expressions::Expression, operations::BinaryOperation, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, circuits::CircuitField, common::Identifier, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{common::Identifier, expressions::*, operations::BinaryOperation, values::Value};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod array_initializer_expression;
|
||||
pub use array_initializer_expression::*;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{access::Access, ast::Rule, common::Identifier, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, expressions::Expression, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, expressions::Expression, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, expressions::Expression, operations::UnaryOperation, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::EOI, definitions::Definition, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,2 +1,18 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod file;
|
||||
pub use file::*;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::Identifier, functions::input::Input, statements::Statement, types::Type, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
common::{Identifier, Mutable},
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
functions::{FunctionInput, InputKeyword},
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::{span_into_string, Rule},
|
||||
SpanDef,
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod function_input;
|
||||
pub use function_input::*;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod function;
|
||||
pub use function::*;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, functions::Function, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::LineEnd, imports::Package, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, common::Identifier, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod import;
|
||||
pub use import::*;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
imports::{PackageAccess, PackageName},
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
imports::{ImportSymbol, Package, Star},
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::{span_into_string, Rule},
|
||||
SpanDef,
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{ast::Rule, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
|
@ -25,6 +25,7 @@ protected_name = {
|
||||
| "as"
|
||||
| "circuit"
|
||||
| "const"
|
||||
| "console"
|
||||
| "else"
|
||||
| "false"
|
||||
| "field"
|
||||
@ -234,7 +235,8 @@ value_boolean = { "true" | "false" }
|
||||
value_field = ${ value_number ~ type_field }
|
||||
|
||||
// Declared in values/group_value.rs
|
||||
value_group = ${ group_tuple ~ type_group }
|
||||
value_group = ${ group_single_or_tuple ~ type_group }
|
||||
group_single_or_tuple = {value_number | group_tuple}
|
||||
group_tuple = !{"(" ~ group_coordinate ~ "," ~ group_coordinate ~ ")"}
|
||||
|
||||
// Declared in values/group_coordinate.rs
|
||||
@ -345,18 +347,13 @@ statement = {
|
||||
(statement_return
|
||||
| statement_conditional
|
||||
| statement_for
|
||||
| statement_macro
|
||||
| console_function_call
|
||||
| statement_definition
|
||||
| statement_assign
|
||||
| statement_expression
|
||||
) ~ NEWLINE*
|
||||
}
|
||||
|
||||
// Declared in statements/macro_statement.rs
|
||||
statement_macro = {
|
||||
assert_eq
|
||||
| formatted_macro
|
||||
}
|
||||
|
||||
// Declared in statements/assign_statement.rs
|
||||
statement_assign = { assignee ~ operation_assign ~ expression ~ LINE_END }
|
||||
@ -431,15 +428,35 @@ import_symbol = { identifier ~ ("as " ~ identifier)? }
|
||||
COMMENT = _{ ("/*" ~ (!"*/" ~ ANY)* ~ "*/") | ("//" ~ (!NEWLINE ~ ANY)*) }
|
||||
WHITESPACE = _{ " " | "\t" ~ (NEWLINE)* } // pest implicit whitespace keyword
|
||||
|
||||
/// Macros
|
||||
/// Console Functions
|
||||
|
||||
// Declared in macros/assert_eq.rs
|
||||
assert_eq = {"assert_eq!" ~ "(" ~ NEWLINE* ~ expression ~ "," ~ NEWLINE* ~ expression ~ NEWLINE* ~ ")" ~ LINE_END}
|
||||
// Declared in console/console_function_call.rs
|
||||
console_function_call = ${console_keyword ~ "." ~ console_function ~ LINE_END}
|
||||
|
||||
// Declared in macros/formatted_macro.rs
|
||||
formatted_macro = { macro_name ~ macro_symbol ~ "(" ~ formatted_string? ~ ")" ~ LINE_END}
|
||||
// Declared in console/console_keyword.rs
|
||||
console_keyword = {"console"}
|
||||
|
||||
// Declared in macros/formatted_string.rs
|
||||
// Declared in console/console_function.rs
|
||||
console_function = {
|
||||
console_assert
|
||||
| console_debug
|
||||
| console_error
|
||||
| console_log
|
||||
}
|
||||
|
||||
// Declared in console/console_assert.rs
|
||||
console_assert = !{"assert(" ~ expression ~ ")"}
|
||||
|
||||
// Declared in console/console_debug.rs
|
||||
console_debug = !{"debug(" ~ formatted_string? ~ ")"}
|
||||
|
||||
// Declared in console/console_error.rs
|
||||
console_error = !{"error(" ~ formatted_string? ~ ")"}
|
||||
|
||||
// Declared in console/console_log.rs
|
||||
console_log = !{"log(" ~ formatted_string? ~ ")"}
|
||||
|
||||
// Declared in console/formatted_string.rs
|
||||
formatted_string = {
|
||||
"\""
|
||||
~ (!"\"" ~ (formatted_container | ANY))*
|
||||
@ -447,31 +464,12 @@ formatted_string = {
|
||||
~ ("," ~ formatted_parameter)*
|
||||
}
|
||||
|
||||
// Declared in macros/formatted_container.rs
|
||||
// Declared in console/formatted_container.rs
|
||||
formatted_container = { "{" ~ "}"}
|
||||
|
||||
// Declared in macros/formatted_parameter.rs
|
||||
// Declared in console/formatted_parameter.rs
|
||||
formatted_parameter = { expression }
|
||||
|
||||
// Declared in macros/macro_symbol.rs
|
||||
macro_symbol = {"!"}
|
||||
|
||||
// Declared in macros/macro_name.rs
|
||||
macro_name = {
|
||||
debug
|
||||
| error
|
||||
| print
|
||||
}
|
||||
|
||||
// Declared in macros/print.rs
|
||||
print = {"print"}
|
||||
|
||||
// Declared in macros/debug.rs
|
||||
debug = {"debug"}
|
||||
|
||||
// Declared in macros/error.rs
|
||||
error = {"error"}
|
||||
|
||||
/// Annotations
|
||||
|
||||
// Declared in annotations/annotation.rs
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
#[macro_use]
|
||||
@ -11,12 +27,12 @@ pub mod access;
|
||||
pub mod annotations;
|
||||
pub mod circuits;
|
||||
pub mod common;
|
||||
pub mod console;
|
||||
pub mod definitions;
|
||||
pub mod expressions;
|
||||
pub mod files;
|
||||
pub mod functions;
|
||||
pub mod imports;
|
||||
pub mod macros;
|
||||
pub mod operations;
|
||||
pub mod statements;
|
||||
pub mod types;
|
||||
|
@ -1,23 +0,0 @@
|
||||
use crate::{ast::Rule, common::LineEnd, expressions::Expression, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::assert_eq))]
|
||||
pub struct AssertEq<'ast> {
|
||||
pub left: Expression<'ast>,
|
||||
pub right: Expression<'ast>,
|
||||
pub line_end: LineEnd,
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for AssertEq<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "assert_eq({}, {});", self.left, self.right)
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
use crate::{ast::Rule, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::debug))]
|
||||
pub struct Debug<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for Debug<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "debug")
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
use crate::{ast::Rule, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::error))]
|
||||
pub struct Error<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for Error<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "error")
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
use crate::{ast::Rule, SpanDef};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::formatted_container))]
|
||||
pub struct FormattedContainer<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for FormattedContainer<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{{}}")
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
common::LineEnd,
|
||||
macros::{FormattedString, MacroName, MacroSymbol},
|
||||
SpanDef,
|
||||
};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::formatted_macro))]
|
||||
pub struct FormattedMacro<'ast> {
|
||||
pub name: MacroName<'ast>,
|
||||
pub symbol: MacroSymbol,
|
||||
pub string: Option<FormattedString<'ast>>,
|
||||
pub line_end: LineEnd,
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for FormattedMacro<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}{}({}){}",
|
||||
self.name,
|
||||
self.symbol,
|
||||
self.string.as_ref().map(|s| s.to_string()).unwrap_or("".to_string()),
|
||||
self.line_end
|
||||
)
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
use crate::{
|
||||
ast::{span_into_string, Rule},
|
||||
macros::{FormattedContainer, FormattedParameter},
|
||||
SpanDef,
|
||||
};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::formatted_string))]
|
||||
pub struct FormattedString<'ast> {
|
||||
#[pest_ast(outer(with(span_into_string)))]
|
||||
pub string: String,
|
||||
pub containers: Vec<FormattedContainer<'ast>>,
|
||||
pub parameters: Vec<FormattedParameter<'ast>>,
|
||||
#[pest_ast(outer())]
|
||||
#[serde(with = "SpanDef")]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for FormattedString<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.string)
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
macros::{Debug, Error, Print},
|
||||
};
|
||||
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::macro_name))]
|
||||
pub enum MacroName<'ast> {
|
||||
Debug(Debug<'ast>),
|
||||
Error(Error<'ast>),
|
||||
Print(Print<'ast>),
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for MacroName<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
MacroName::Debug(ref debug) => write!(f, "{}", debug),
|
||||
MacroName::Error(ref error) => write!(f, "{}", error),
|
||||
MacroName::Print(ref print_line) => write!(f, "{}", print_line),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest_ast::FromPest;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::macro_symbol))]
|
||||
pub struct MacroSymbol {}
|
||||
|
||||
impl fmt::Display for MacroSymbol {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "!")
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
pub mod assert_eq;
|
||||
pub use assert_eq::*;
|
||||
|
||||
pub mod debug;
|
||||
pub use debug::*;
|
||||
|
||||
pub mod error;
|
||||
pub use error::*;
|
||||
|
||||
pub mod formatted_container;
|
||||
pub use formatted_container::*;
|
||||
|
||||
pub mod formatted_parameter;
|
||||
pub use formatted_parameter::*;
|
||||
|
||||
pub mod formatted_string;
|
||||
pub use formatted_string::*;
|
||||
|
||||
pub mod formatted_macro;
|
||||
pub use formatted_macro::*;
|
||||
|
||||
pub mod macro_name;
|
||||
pub use macro_name::*;
|
||||
|
||||
pub mod macro_symbol;
|
||||
pub use macro_symbol::*;
|
||||
|
||||
pub mod print;
|
||||
pub use print::*;
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use leo_ast::{LeoAst, ParserError};
|
||||
use std::{env, fs, path::Path};
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest_ast::FromPest;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest_ast::FromPest;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod assign_operation;
|
||||
pub use assign_operation::*;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest_ast::FromPest;
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use pest::Span;
|
||||
use serde::Serialize;
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
common::{Assignee, LineEnd},
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user