mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-25 02:22:44 +03:00
finish docs, setup ci to publish docs pages, test docs generation
This commit is contained in:
parent
2f045e13cc
commit
622ff5a9c3
@ -46,7 +46,7 @@ commands:
|
||||
jobs:
|
||||
check-style:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- checkout
|
||||
@ -61,7 +61,7 @@ jobs:
|
||||
|
||||
clippy:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- checkout
|
||||
@ -76,7 +76,7 @@ jobs:
|
||||
|
||||
# code-cov:
|
||||
# docker:
|
||||
# - image: cimg/rust:1.54.0
|
||||
# - image: cimg/rust:1.54.0.0
|
||||
# resource_class: xlarge
|
||||
# environment:
|
||||
# RUSTC_BOOTSTRAP: 1
|
||||
@ -118,7 +118,7 @@ jobs:
|
||||
|
||||
leo-executable:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- checkout
|
||||
@ -136,7 +136,7 @@ jobs:
|
||||
|
||||
leo-new:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- attach_workspace:
|
||||
@ -149,7 +149,7 @@ jobs:
|
||||
|
||||
leo-init:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- attach_workspace:
|
||||
@ -162,7 +162,7 @@ jobs:
|
||||
|
||||
leo-clean:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- attach_workspace:
|
||||
@ -175,7 +175,7 @@ jobs:
|
||||
|
||||
leo-setup:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- attach_workspace:
|
||||
@ -188,7 +188,7 @@ jobs:
|
||||
|
||||
leo-add-remove:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- attach_workspace:
|
||||
@ -201,7 +201,7 @@ jobs:
|
||||
|
||||
leo-check-constraints:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- attach_workspace:
|
||||
@ -214,7 +214,7 @@ jobs:
|
||||
|
||||
leo-login-logout:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- attach_workspace:
|
||||
@ -227,7 +227,7 @@ jobs:
|
||||
|
||||
leo-clone:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- attach_workspace:
|
||||
@ -240,7 +240,7 @@ jobs:
|
||||
|
||||
leo-publish:
|
||||
docker:
|
||||
- image: cimg/rust:1.54
|
||||
- image: cimg/rust:1.54.0
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- attach_workspace:
|
||||
|
60
.github/workflows/ci.yml
vendored
60
.github/workflows/ci.yml
vendored
@ -178,6 +178,66 @@ jobs:
|
||||
- name: Stop sccache server
|
||||
run: sccache --stop-server || true
|
||||
|
||||
test-docs:
|
||||
name: Test Docs
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUSTC_WRAPPER: sccache
|
||||
SCCACHE_CACHE_SIZE: 2G
|
||||
SCCACHE_DIR: /home/runner/.cache/sccache
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: master
|
||||
|
||||
- name: Install sccache
|
||||
env:
|
||||
LINK: https://github.com/mozilla/sccache/releases/download
|
||||
SCCACHE_VERSION: v0.2.15
|
||||
run: |
|
||||
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl
|
||||
mkdir -p $HOME/.local/bin
|
||||
curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
|
||||
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
|
||||
chmod +x $HOME/.local/bin/sccache
|
||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v2
|
||||
continue-on-error: false
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-
|
||||
|
||||
- name: Install Rust Stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Start sccache server
|
||||
run: sccache --start-server
|
||||
|
||||
- name: Build Cargo Docs
|
||||
env:
|
||||
RUSTDOCFLAGS: "--enable-index-page -Zunstable-options"
|
||||
RUSTC_BOOTSTRAP: "1"
|
||||
run: |
|
||||
cargo doc --no-deps --document-private-items --workspace
|
||||
rm -rf ./tests
|
||||
|
||||
- name: Print sccache stats
|
||||
run: sccache --show-stats
|
||||
|
||||
- name: Stop sccache server
|
||||
run: sccache --stop-server || true
|
||||
|
||||
codecov:
|
||||
name: Code Coverage
|
||||
runs-on: ubuntu-latest
|
||||
|
60
.github/workflows/docs.yml
vendored
60
.github/workflows/docs.yml
vendored
@ -8,9 +8,27 @@ jobs:
|
||||
build-crates-docs:
|
||||
name: Build Crates Docs
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUSTC_WRAPPER: sccache
|
||||
SCCACHE_CACHE_SIZE: 2G
|
||||
SCCACHE_DIR: /home/runner/.cache/sccache
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: master
|
||||
|
||||
- name: Install sccache
|
||||
env:
|
||||
LINK: https://github.com/mozilla/sccache/releases/download
|
||||
SCCACHE_VERSION: v0.2.15
|
||||
run: |
|
||||
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl
|
||||
mkdir -p $HOME/.local/bin
|
||||
curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
|
||||
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
|
||||
chmod +x $HOME/.local/bin/sccache
|
||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Install Rust Stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
@ -18,30 +36,34 @@ jobs:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Save sccache
|
||||
uses: actions/cache@v2
|
||||
continue-on-error: false
|
||||
with:
|
||||
path: /home/runner/.cache/sccache
|
||||
key: ubuntu-sccache-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: ubuntu-sccache-
|
||||
|
||||
- name: Start sccache server
|
||||
run: sccache --start-server
|
||||
|
||||
- name: Build Cargo Docs
|
||||
env:
|
||||
RUSTDOCFLAGS: "--enable-index-page -Zunstable-options"
|
||||
RUSTC_BOOTSTRAP: "1"
|
||||
run: |
|
||||
cargo doc
|
||||
mv -r ./target/doc/leo /tmp/
|
||||
|
||||
- name: Save Docs
|
||||
uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: leo-docs
|
||||
path: /tmp/target/doc/leo
|
||||
|
||||
deploy-crates-docs:
|
||||
name: Deploy Crates Docs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Load Docs
|
||||
uses: actions/download-artifact@master
|
||||
with:
|
||||
name: leo-docs
|
||||
path: /tmp/target/doc/leo
|
||||
cargo doc --no-deps --document-private-items --workspace
|
||||
rm -rf ./tests
|
||||
|
||||
- name: Deploy
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./target/doc/leo
|
||||
publish_dir: ./target/doc/
|
||||
|
||||
- name: Print sccache stats
|
||||
run: sccache --show-stats
|
||||
|
||||
- name: Stop sccache server
|
||||
run: sccache --stop-server || true
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,6 +9,9 @@
|
||||
**/.crates2.json
|
||||
**/bin/
|
||||
|
||||
# sccache from pipeline
|
||||
sccache*/
|
||||
|
||||
# Emacs gitignore files
|
||||
*~
|
||||
\#*\#
|
||||
|
@ -1,4 +1,5 @@
|
||||
# leo-ast
|
||||
|
||||
[![Crates.io](https://img.shields.io/crates/v/leo-ast.svg?color=neon)](https://crates.io/crates/leo-ast)
|
||||
[![Authors](https://img.shields.io/badge/authors-Aleo-orange.svg)](../AUTHORS)
|
||||
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE.md)
|
||||
|
@ -35,6 +35,4 @@ pub use self_keyword::*;
|
||||
pub mod spread_or_expression;
|
||||
pub use spread_or_expression::*;
|
||||
|
||||
pub mod tendril_json;
|
||||
|
||||
pub mod vec_tendril_json;
|
||||
|
@ -23,7 +23,7 @@ use tendril::StrTendril;
|
||||
/// A number string guaranteed to be positive by the pest grammar.
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct PositiveNumber {
|
||||
#[serde(with = "crate::common::tendril_json")]
|
||||
#[serde(with = "leo_errors::common::tendril_json")]
|
||||
pub value: StrTendril,
|
||||
}
|
||||
|
||||
|
@ -1,120 +0,0 @@
|
||||
// Copyright (C) 2019-2021 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 std::{fmt, sync::Arc};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tendril::StrTendril;
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||
pub struct Span {
|
||||
pub line_start: usize,
|
||||
pub line_stop: usize,
|
||||
pub col_start: usize,
|
||||
pub col_stop: usize,
|
||||
pub path: Arc<String>,
|
||||
#[serde(with = "crate::common::tendril_json")]
|
||||
pub content: StrTendril,
|
||||
}
|
||||
|
||||
impl fmt::Display for Span {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if self.line_start == self.line_stop {
|
||||
write!(f, "{}:{}-{}", self.line_start, self.col_start, self.col_stop)
|
||||
} else {
|
||||
write!(
|
||||
f,
|
||||
"{}:{}-{}:{}",
|
||||
self.line_start, self.col_start, self.line_stop, self.col_stop
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast> From<pest::Span<'ast>> for Span {
|
||||
fn from(span: pest::Span) -> Self {
|
||||
let start = span.start_pos().line_col();
|
||||
let end = span.end_pos().line_col();
|
||||
|
||||
Span {
|
||||
line_start: start.0,
|
||||
line_stop: end.0,
|
||||
col_start: start.1,
|
||||
col_stop: end.1,
|
||||
path: Arc::new(String::new()),
|
||||
content: span.as_str().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Add for &Span {
|
||||
type Output = Span;
|
||||
|
||||
fn add(self, other: &Span) -> Span {
|
||||
self.clone() + other.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Add for Span {
|
||||
type Output = Self;
|
||||
|
||||
#[allow(clippy::comparison_chain)]
|
||||
fn add(self, other: Self) -> Self {
|
||||
if self.line_start == other.line_stop {
|
||||
Span {
|
||||
line_start: self.line_start,
|
||||
line_stop: self.line_stop,
|
||||
col_start: self.col_start.min(other.col_start),
|
||||
col_stop: self.col_stop.max(other.col_stop),
|
||||
path: self.path,
|
||||
content: self.content,
|
||||
}
|
||||
} else {
|
||||
let mut new_content = vec![];
|
||||
let self_lines = self.content.lines().collect::<Vec<_>>();
|
||||
let other_lines = other.content.lines().collect::<Vec<_>>();
|
||||
for line in self.line_start.min(other.line_start)..self.line_stop.max(other.line_stop) + 1 {
|
||||
if line >= self.line_start && line <= self.line_stop {
|
||||
new_content.push(self_lines.get(line - self.line_start).copied().unwrap_or_default());
|
||||
} else if line >= other.line_start && line <= other.line_stop {
|
||||
new_content.push(other_lines.get(line - other.line_start).copied().unwrap_or_default());
|
||||
} else if new_content.last().map(|x| *x != "...").unwrap_or(true) {
|
||||
new_content.push("...");
|
||||
}
|
||||
}
|
||||
let new_content = new_content.join("\n").into();
|
||||
if self.line_start < other.line_stop {
|
||||
Span {
|
||||
line_start: self.line_start,
|
||||
line_stop: other.line_stop,
|
||||
col_start: self.col_start,
|
||||
col_stop: other.col_stop,
|
||||
path: self.path,
|
||||
content: new_content,
|
||||
}
|
||||
} else {
|
||||
Span {
|
||||
line_start: other.line_start,
|
||||
line_stop: self.line_stop,
|
||||
col_start: other.col_start,
|
||||
col_stop: self.col_stop,
|
||||
path: self.path,
|
||||
content: new_content,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
// Copyright (C) 2019-2021 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 serde::{Deserialize, Deserializer, Serializer};
|
||||
use tendril::StrTendril;
|
||||
|
||||
pub fn serialize<S: Serializer>(tendril: &StrTendril, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
serializer.serialize_str(&tendril[..])
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<StrTendril, D::Error> {
|
||||
Ok(String::deserialize(deserializer)?.into())
|
||||
}
|
@ -22,15 +22,15 @@ use crate::{Char, CharValue};
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum ValueExpression {
|
||||
// todo: deserialize values here
|
||||
Address(#[serde(with = "crate::common::tendril_json")] StrTendril, Span),
|
||||
Boolean(#[serde(with = "crate::common::tendril_json")] StrTendril, Span),
|
||||
Address(#[serde(with = "leo_errors::common::tendril_json")] StrTendril, Span),
|
||||
Boolean(#[serde(with = "leo_errors::common::tendril_json")] StrTendril, Span),
|
||||
Char(CharValue),
|
||||
Field(#[serde(with = "crate::common::tendril_json")] StrTendril, Span),
|
||||
Field(#[serde(with = "leo_errors::common::tendril_json")] StrTendril, Span),
|
||||
Group(Box<GroupValue>),
|
||||
Implicit(#[serde(with = "crate::common::tendril_json")] StrTendril, Span),
|
||||
Implicit(#[serde(with = "leo_errors::common::tendril_json")] StrTendril, Span),
|
||||
Integer(
|
||||
IntegerType,
|
||||
#[serde(with = "crate::common::tendril_json")] StrTendril,
|
||||
#[serde(with = "leo_errors::common::tendril_json")] StrTendril,
|
||||
Span,
|
||||
),
|
||||
String(Vec<Char>, Span),
|
||||
|
@ -26,7 +26,7 @@ use tendril::StrTendril;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum GroupCoordinate {
|
||||
Number(#[serde(with = "crate::common::tendril_json")] StrTendril, Span),
|
||||
Number(#[serde(with = "leo_errors::common::tendril_json")] StrTendril, Span),
|
||||
SignHigh,
|
||||
SignLow,
|
||||
Inferred,
|
||||
|
@ -26,7 +26,7 @@ use tendril::StrTendril;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum GroupValue {
|
||||
Single(#[serde(with = "crate::common::tendril_json")] StrTendril, Span),
|
||||
Single(#[serde(with = "leo_errors::common::tendril_json")] StrTendril, Span),
|
||||
Tuple(GroupTuple),
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,64 @@
|
||||
# leo-errors
|
||||
|
||||
[![Crates.io](https://img.shields.io/crates/v/leo-ast.svg?color=neon)](https://crates.io/crates/leo-errors)
|
||||
[![Authors](https://img.shields.io/badge/authors-Aleo-orange.svg)](../AUTHORS)
|
||||
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE.md)
|
||||
|
||||
This directory contains the code for the Errors for all the Leo crates.
|
||||
|
||||
## [Common](./src/common)
|
||||
|
||||
The common section of this crate contains a few sub files:
|
||||
|
||||
- [Backtraced Error](./src/common/backtraced.rs): Which contains the information needed to create a backtraceable error for Leo.
|
||||
- [Formatted Error](./src/common/formatted.rs): Which contains the information needed to create a formatted error for Leo.
|
||||
- [Macros](./src/common/macros.rs): Which contains the logic to make creating errors easy through a DSL. It also figures out the error codes for each error via a **top down** method. Meaning all new errors should be added to the bottom of the file. You can specify whether an error is formatted or backtraced through a decorator above a function name, where the formatted ones require a Span as an argument by default. The body takes any additional arguments you want provided to the function, the message, and the optional help message for the error. The additional arguments are just specified to implement traits to avoid as many type conversions in other Leo crates.
|
||||
- [Span](./src/common/span.rs): Which contains the span object used throughout the other Leo crates(with the exception of the Input crate see more [below](#input)).
|
||||
- [Tendril JSON](./src/common/tendril_json.rs): Which contains the common logic for how to searlize a StrTendril from the tendril crate.
|
||||
- [Traits](./src/common/traits.rs): Which contains the common traits in errors to make defining errors easier.
|
||||
|
||||
## Error Types
|
||||
|
||||
These are the different kinds of errors that are made in this crate. Note that if you want more information about the errors please check the crates documentation or the [Error Index](./ERROR_INDEX.md). All errors here with the exception of [SnarkVM Errors](#snarkvm) have a 037 prefixed to their error codes.
|
||||
|
||||
### ASG
|
||||
|
||||
The errors for the `leo-asg` crate. It's error codes will range from 0-999, and be prefixed with the characters `ASG`.
|
||||
|
||||
### AST
|
||||
|
||||
The errors for the `leo-ast` crate. It's error codes will range from 1_000-1_999, and be prefixed with the characters `AST`.
|
||||
|
||||
### CLI
|
||||
|
||||
The errors for the `leo-lang` crate. It's error codes will range from 7_000-7_999, and be prefixed with the characters `CLI`.
|
||||
|
||||
### Compiler
|
||||
|
||||
The errors for the `leo-compiler` crate. It's error codes will range from 2_000-2_999, and be prefixed with the characters `CMP`.
|
||||
|
||||
### Import
|
||||
|
||||
The errors for the `leo-imports` crate. It's error codes will range from 3_000-3_999, and be prefixed with the characters `IMP`.
|
||||
|
||||
### Input
|
||||
|
||||
The errors for the `leo-input` crate. For right now they just have an exit code of 1, as they aren't ported.
|
||||
The reason they aren't ported is due to a desire for 0 deps in case this crate moves to SnarkVM.
|
||||
|
||||
### Package
|
||||
|
||||
The errors for the `leo-package` crate. It's error codes will range from 4_000-4_999, and be prefixed with the characters `PAK`.
|
||||
|
||||
### Parser
|
||||
|
||||
The errors for the `leo-parser` crate. It's error codes will range from 5_000-5_999, and be prefixed with the characters `PAR`.
|
||||
|
||||
### SnarkVM
|
||||
|
||||
The errors from SnarkVM that bubble up into Leo in some situations. For right now they just have an exit code of 1.
|
||||
When SnarkVM implments better error codes and messages we can just bubble them up.
|
||||
|
||||
### State
|
||||
|
||||
The errors for the `leo-state` crate. It's error codes will range from 6000-6_999, and be prefixed with the characters `STA`.
|
@ -22,7 +22,7 @@ macro_rules! create_errors {
|
||||
(@step $_code:expr,) => {};
|
||||
($(#[$error_type_docs:meta])* $error_type:ident, exit_code_mask: $exit_code_mask:expr, error_code_prefix: $error_code_prefix:expr, $($(#[$docs:meta])* @$formatted_or_backtraced_list:ident $names:ident { args: ($($arg_names:ident: $arg_types:ty$(,)?)*), msg: $messages:expr, help: $helps:expr, })*) => {
|
||||
#[allow(unused_imports)] // Allow unused for errors that only use formatted or backtraced errors.
|
||||
use crate::{BacktracedError, ErrorCode, FormattedError, LeoErrorCode, Span};
|
||||
use crate::{BacktracedError, FormattedError, LeoErrorCode, Span};
|
||||
|
||||
use backtrace::Backtrace;
|
||||
|
||||
@ -38,10 +38,7 @@ macro_rules! create_errors {
|
||||
}
|
||||
|
||||
/// Implements the trait for LeoError Codes.
|
||||
impl LeoErrorCode for $error_type {}
|
||||
|
||||
/// Implements the Error code trait for each error.
|
||||
impl ErrorCode for $error_type {
|
||||
impl LeoErrorCode for $error_type {
|
||||
#[inline(always)]
|
||||
fn exit_code(&self) -> i32 {
|
||||
match self {
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
/// ErrorCode trait that all Errors should implement.
|
||||
pub trait ErrorCode: Sized {
|
||||
pub trait LeoErrorCode: Sized {
|
||||
/// Returns the error's exit code for the program.
|
||||
fn exit_code(&self) -> i32;
|
||||
|
||||
@ -24,12 +24,10 @@ pub trait ErrorCode: Sized {
|
||||
|
||||
/// Returns the error's code type for the program.
|
||||
fn error_type() -> String;
|
||||
}
|
||||
|
||||
/// The LeoErrorCode which has a code identifier of 037(Leo upsidedown and backwards).
|
||||
/// This is to make the exit codes unique to Leo itself.
|
||||
pub trait LeoErrorCode: ErrorCode {
|
||||
/// Inlined function for efficiency.
|
||||
/// The LeoErrorCode which has a default code identifier of 037
|
||||
/// (Leo upsidedown and backwards). This is to make the exit codes
|
||||
/// unique to Leo itself.
|
||||
#[inline(always)]
|
||||
fn code_identifier() -> i8 {
|
||||
37
|
||||
|
@ -119,10 +119,10 @@ impl LeoError {
|
||||
CliError(error) => error.exit_code(),
|
||||
CompilerError(error) => error.exit_code(),
|
||||
ImportError(error) => error.exit_code(),
|
||||
InputError(_error) => 0, // TODO migrate me, or not cause we want inputs to have 0 deps.
|
||||
InputError(_error) => 1, // TODO migrate me, or not cause we want inputs to have 0 deps.
|
||||
PackageError(error) => error.exit_code(),
|
||||
ParserError(error) => error.exit_code(),
|
||||
SnarkVMError(_error) => 0, // TODO update once snarkvm implments a global top level error similar to LeoError.
|
||||
SnarkVMError(_error) => 1, // TODO update once snarkvm implments a global top level error similar to LeoError.
|
||||
StateError(error) => error.exit_code(),
|
||||
}
|
||||
}
|
||||
|
@ -48,14 +48,14 @@ impl fmt::Display for Char {
|
||||
pub enum Token {
|
||||
// Lexical Grammar
|
||||
// Literals
|
||||
CommentLine(#[serde(with = "leo_ast::common::tendril_json")] StrTendril),
|
||||
CommentBlock(#[serde(with = "leo_ast::common::tendril_json")] StrTendril),
|
||||
CommentLine(#[serde(with = "leo_errors::common::tendril_json")] StrTendril),
|
||||
CommentBlock(#[serde(with = "leo_errors::common::tendril_json")] StrTendril),
|
||||
StringLit(Vec<leo_ast::Char>),
|
||||
Ident(#[serde(with = "leo_ast::common::tendril_json")] StrTendril),
|
||||
Int(#[serde(with = "leo_ast::common::tendril_json")] StrTendril),
|
||||
Ident(#[serde(with = "leo_errors::common::tendril_json")] StrTendril),
|
||||
Int(#[serde(with = "leo_errors::common::tendril_json")] StrTendril),
|
||||
True,
|
||||
False,
|
||||
AddressLit(#[serde(with = "leo_ast::common::tendril_json")] StrTendril),
|
||||
AddressLit(#[serde(with = "leo_errors::common::tendril_json")] StrTendril),
|
||||
CharLit(Char),
|
||||
|
||||
// Symbols
|
||||
|
Loading…
Reference in New Issue
Block a user