mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-27 04:01:47 +03:00
Merge pull request #1711 from AleoHQ/remove-ast-to-match-grammar
Remove ast to match grammar testnet3-dev
This commit is contained in:
commit
ff1958e134
38
Cargo.lock
generated
38
Cargo.lock
generated
@ -1150,7 +1150,7 @@ dependencies = [
|
||||
"toml",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"zip 0.6.0",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1164,7 +1164,7 @@ dependencies = [
|
||||
"toml",
|
||||
"tracing",
|
||||
"walkdir",
|
||||
"zip 0.6.0",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1719,9 +1719,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.20.0"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26aab6b48e2590e4a64d1ed808749ba06257882b461d01ca71baeb747074a6dd"
|
||||
checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
@ -2018,9 +2018,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "self_update"
|
||||
version = "0.28.0"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bc3e89793fe56c82104ddc103c998e4e94713cb975202207829e61031eb4be6"
|
||||
checksum = "710b9f39843957861314222c3bad16b9138f664665125ba277a48930253c4ed5"
|
||||
dependencies = [
|
||||
"hyper",
|
||||
"indicatif",
|
||||
@ -2031,7 +2031,7 @@ dependencies = [
|
||||
"semver 0.11.0",
|
||||
"serde_json",
|
||||
"tempfile",
|
||||
"zip 0.5.13",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2363,16 +2363,6 @@ dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.7"
|
||||
@ -2819,18 +2809,6 @@ dependencies = [
|
||||
"linked-hash-map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "0.5.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93ab48844d61251bb3835145c521d88aa4031d7139e8485990f60ca911fa0815"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"crc32fast",
|
||||
"thiserror",
|
||||
"time 0.1.43",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "0.6.0"
|
||||
@ -2846,7 +2824,7 @@ dependencies = [
|
||||
"hmac",
|
||||
"pbkdf2",
|
||||
"sha1",
|
||||
"time 0.3.7",
|
||||
"time",
|
||||
"zstd",
|
||||
]
|
||||
|
||||
|
@ -86,7 +86,7 @@ version = "0.11.10"
|
||||
features = [ "blocking", "json", "multipart" ]
|
||||
|
||||
[dependencies.self_update]
|
||||
version = "0.28.0"
|
||||
version = "0.29.0"
|
||||
features = [ "archive-zip" ]
|
||||
|
||||
[dependencies.serde]
|
||||
|
@ -16,8 +16,10 @@
|
||||
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
pub mod canonicalization;
|
||||
// disable
|
||||
/* pub mod canonicalization;
|
||||
pub use canonicalization::*;
|
||||
*/
|
||||
|
||||
// Temporarily disable import resolution
|
||||
// until we migrate stdlib and then import resolution.
|
||||
|
@ -1,49 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Expression, Node};
|
||||
use leo_span::Span;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// An array element access expression `array[index]`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ArrayAccess {
|
||||
/// The expression, evaluating to an array, that is being indexed.
|
||||
pub array: Box<Expression>,
|
||||
/// The index in `array` that is being accessed.
|
||||
pub index: Box<Expression>,
|
||||
/// The span of the entire expression `array[index]`.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Display for ArrayAccess {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}[{}]", self.array, self.index)
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for ArrayAccess {
|
||||
fn span(&self) -> &Span {
|
||||
&self.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.span = span;
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Expression, Node};
|
||||
use leo_span::Span;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// An access to a certain range of elements in an `array`.
|
||||
///
|
||||
/// Examples include `array[0..3]`, `array[3..]`, `array[..3]`, and `array[..]`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ArrayRangeAccess {
|
||||
/// The array to extract a range of elements from.
|
||||
pub array: Box<Expression>,
|
||||
/// The lower bound of the index-range, or the start of the array when `None`.
|
||||
pub left: Option<Box<Expression>>,
|
||||
/// The higher bound of the index-range, or the end of the array when `None`.
|
||||
pub right: Option<Box<Expression>>,
|
||||
/// A span for the entire expression `array[<range>]`.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Display for ArrayRangeAccess {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}[{}..{}]",
|
||||
self.array,
|
||||
self.left.as_ref().map(|e| e.to_string()).unwrap_or_default(),
|
||||
self.right.as_ref().map(|e| e.to_string()).unwrap_or_default()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for ArrayRangeAccess {
|
||||
fn span(&self) -> &Span {
|
||||
&self.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.span = span;
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Expression, Identifier, Node};
|
||||
use leo_span::Span;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A field access expression `inner.name` to some structure with *named fields*.
|
||||
///
|
||||
/// For accesses to a positional fields in e.g., a tuple, see `TupleAccess`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct MemberAccess {
|
||||
/// The structure that the field `name` is being extracted from.
|
||||
pub inner: Box<Expression>,
|
||||
/// The name of the field to extract in `inner`.
|
||||
pub name: Identifier,
|
||||
/// The span covering all of `inner.name`.
|
||||
pub span: Span,
|
||||
// FIXME(Centril): Type information shouldn't be injected into an AST,
|
||||
// so this field should eventually be removed.
|
||||
pub type_: Option<crate::Type>,
|
||||
}
|
||||
|
||||
impl fmt::Display for MemberAccess {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}.{}", self.inner, self.name)
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for MemberAccess {
|
||||
fn span(&self) -> &Span {
|
||||
&self.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.span = span;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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/>.
|
||||
|
||||
mod array_access;
|
||||
pub use array_access::*;
|
||||
|
||||
mod array_range_access;
|
||||
pub use array_range_access::*;
|
||||
|
||||
mod member_access;
|
||||
pub use member_access::*;
|
||||
|
||||
mod tuple_access;
|
||||
pub use tuple_access::*;
|
||||
|
||||
mod static_access;
|
||||
pub use static_access::*;
|
@ -1,54 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Expression, Identifier, Node, Type};
|
||||
|
||||
use leo_span::Span;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
/// An access expression to a static member, e.g., a constant in a circuit.
|
||||
/// An example would be `Foo::Const` or `Foo::function` in `Foo::function()`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct StaticAccess {
|
||||
/// Represents the container for the static member to access.
|
||||
/// Usually this is a circuit.
|
||||
pub inner: Box<Expression>,
|
||||
/// The static member in `inner` that is being accessed.
|
||||
pub name: Identifier,
|
||||
/// An optional type initially None, it is later assigned during type inference snapshot if necessary.
|
||||
// FIXME(Centril): Shouldn't be in an AST. Remove it as part of an architectural revamp.
|
||||
pub type_: Option<Type>,
|
||||
/// The span for the entire expression `inner::name`.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Display for StaticAccess {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}::{}", self.inner, self.name)
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for StaticAccess {
|
||||
fn span(&self) -> &Span {
|
||||
&self.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.span = span;
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Expression, Node, PositiveNumber};
|
||||
use leo_span::Span;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// An tuple access expression, e.g., `tuple.index`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct TupleAccess {
|
||||
/// An expression evaluating to some tuple type, e.g., `(5, 2)`.
|
||||
pub tuple: Box<Expression>,
|
||||
/// The index to access in the tuple expression. E.g., `0` for `(5, 2)` would yield `5`.
|
||||
pub index: PositiveNumber,
|
||||
/// The span for the entire expression `tuple.index`.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Display for TupleAccess {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}.{}", self.tuple, self.index)
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for TupleAccess {
|
||||
fn span(&self) -> &Span {
|
||||
&self.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.span = span;
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Identifier, Type};
|
||||
use leo_span::Span;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A type alias `type name = represents;`.
|
||||
///
|
||||
/// That is, `name` will become another name for `represents`.
|
||||
/// This does not create a new type, that is, `name` is the same type as `represents`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Alias {
|
||||
/// The new name for `represents`.
|
||||
pub name: Identifier,
|
||||
/// A span for the entire `type name = represents;`.
|
||||
pub span: Span,
|
||||
/// The type that `name` will evaluate and is equal to.
|
||||
pub represents: Type,
|
||||
}
|
||||
|
||||
impl fmt::Display for Alias {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{} : {}", self.name.name, self.represents)
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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 alias;
|
||||
pub use self::alias::*;
|
@ -1,52 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::Identifier;
|
||||
use leo_span::{sym, Span, Symbol};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
/// An annotation `@name (arguments)?`.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct Annotation {
|
||||
/// The span including `name ( arguments )`.
|
||||
pub span: Span,
|
||||
/// The name of the annotation.
|
||||
pub name: Identifier,
|
||||
/// Arguments for the annotation, if any.
|
||||
pub arguments: Vec<Symbol>,
|
||||
}
|
||||
|
||||
/// The set of allowed annotations.
|
||||
const ALLOWED_ANNOTATIONS: &[Symbol] = &[sym::test];
|
||||
|
||||
impl Annotation {
|
||||
/// Is the annotation valid?
|
||||
pub fn is_valid_annotation(&self) -> bool {
|
||||
ALLOWED_ANNOTATIONS.iter().any(|name| self.name.name == *name)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Annotation {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "@{:}(", self.name)?;
|
||||
for arg in &self.arguments {
|
||||
write!(f, "{:},", arg)?;
|
||||
}
|
||||
write!(f, ")")
|
||||
}
|
||||
}
|
@ -53,6 +53,18 @@ impl fmt::Display for Char {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Chars(pub Vec<Char>);
|
||||
|
||||
impl fmt::Display for Chars {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
for character in self.0.iter() {
|
||||
write!(f, "{}", character)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CharValue {
|
||||
pub character: Char,
|
||||
|
@ -1,56 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{CircuitMember, Identifier};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
/// A record type definition, e.g., `circuit Foo { my_field: Bar }`.
|
||||
/// In some languages these are called `struct`s.
|
||||
///
|
||||
/// Type identity is decided by the full path including `circuit_name`,
|
||||
/// as the record is nominal, not structural.
|
||||
/// The fields are named so `circuit Foo(u8, u16)` is not allowed.
|
||||
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Circuit {
|
||||
/// The name of the type in the type system in this module.
|
||||
pub circuit_name: Identifier,
|
||||
/// The fields, constant variables, and functions of this structure.
|
||||
pub members: Vec<CircuitMember>,
|
||||
}
|
||||
|
||||
impl Circuit {
|
||||
fn format(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
writeln!(f, "circuit {} {{ ", self.circuit_name)?;
|
||||
for field in self.members.iter() {
|
||||
writeln!(f, " {}", field)?;
|
||||
}
|
||||
write!(f, "}}")
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Circuit {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.format(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Circuit {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.format(f)
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Expression, Identifier};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CircuitImpliedVariableDefinition {
|
||||
pub identifier: Identifier,
|
||||
pub expression: Option<Expression>,
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Expression, Function, Identifier, Type};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
/// A member of a circuit definition.
|
||||
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum CircuitMember {
|
||||
/// A static constant in a circuit.
|
||||
/// For example: `const foobar: u8 = 42;`.
|
||||
CircuitConst(
|
||||
/// The identifier of the constant.
|
||||
Identifier,
|
||||
/// The type the constant has.
|
||||
Type,
|
||||
/// The expression representing the constant's value.
|
||||
/// Checked to be of the type above.
|
||||
Expression,
|
||||
),
|
||||
/// A varible definition in a circuit;
|
||||
/// For example: `foobar: u8;`.
|
||||
CircuitVariable(
|
||||
/// The identifier of the constant.
|
||||
Identifier,
|
||||
/// The type the constant has.
|
||||
Type,
|
||||
),
|
||||
/// A function definition in a circuit.
|
||||
/// For example: `function bar() -> u8 { return 2u8; }`.
|
||||
CircuitFunction(
|
||||
/// The function.
|
||||
Box<Function>,
|
||||
),
|
||||
}
|
||||
|
||||
impl fmt::Display for CircuitMember {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
CircuitMember::CircuitConst(ref identifier, ref type_, ref value) => {
|
||||
write!(f, "{}: {} = {}", identifier, type_, value)
|
||||
}
|
||||
CircuitMember::CircuitVariable(ref identifier, ref type_) => write!(f, "{}: {}", identifier, type_),
|
||||
CircuitMember::CircuitFunction(ref function) => write!(f, "{}", function),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Expression, Identifier};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CircuitVariableDefinition {
|
||||
pub identifier: Identifier,
|
||||
pub expression: Expression,
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::*;
|
||||
|
||||
pub mod circuit_member;
|
||||
pub use circuit_member::*;
|
@ -1,86 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::PositiveNumber;
|
||||
|
||||
use serde::{ser::SerializeSeq, Deserialize, Serialize, Serializer};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use std::{fmt, ops::Deref};
|
||||
|
||||
/// Specifies array dimensions for array [`Type`]s or in array initializer [`Expression`]s.
|
||||
#[derive(Clone, Deserialize, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct ArrayDimensions(pub SmallVec<[PositiveNumber; 1]>);
|
||||
|
||||
impl Deref for ArrayDimensions {
|
||||
type Target = [PositiveNumber];
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&*self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl ArrayDimensions {
|
||||
/// Returns a single-dimensional array dimension.
|
||||
pub fn single(dim: PositiveNumber) -> Self {
|
||||
Self(smallvec![dim])
|
||||
}
|
||||
|
||||
/// Returns `true` if there is an array dimension equal to zero.
|
||||
pub fn is_zero(&self) -> bool {
|
||||
self.iter().any(|d| d.is_zero())
|
||||
}
|
||||
|
||||
/// Attempts to remove the first dimension from the array, or returns `None` if it doesn't.
|
||||
pub fn remove_first(&mut self) -> Option<PositiveNumber> {
|
||||
if self.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(self.0.remove(0))
|
||||
}
|
||||
}
|
||||
|
||||
/// Attempts to remove the last dimension from the array, or returns `None` if it doesn't.
|
||||
pub fn remove_last(&mut self) -> Option<PositiveNumber> {
|
||||
self.0.pop()
|
||||
}
|
||||
}
|
||||
|
||||
/// Custom Serializer for ArrayDimensions is required to ignore internal ArrayDimension nodes in the AST.
|
||||
impl Serialize for ArrayDimensions {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let mut seq = serializer.serialize_seq(Some(self.0.len()))?;
|
||||
for dim in self.0.iter() {
|
||||
seq.serialize_element(&dim)?;
|
||||
}
|
||||
seq.end()
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ArrayDimensions {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match &*self.0 {
|
||||
[dim] => write!(f, "{}", dim),
|
||||
dimensions => write!(
|
||||
f,
|
||||
"({})",
|
||||
dimensions.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(", ")
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Identifier, Node};
|
||||
use leo_span::Span;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
/// The `self` keyword can view circuit values inside of a circuit function.
|
||||
/// Circuit values cannot be modified. To modify values use the `mut self` [MutSelfKeyword].
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
#[serde(transparent)]
|
||||
pub struct ConstSelfKeyword {
|
||||
/// Always `const self`.
|
||||
pub identifier: Identifier,
|
||||
}
|
||||
|
||||
impl fmt::Display for ConstSelfKeyword {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "const self")
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for ConstSelfKeyword {
|
||||
fn span(&self) -> &Span {
|
||||
&self.identifier.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.identifier.span = span;
|
||||
}
|
||||
}
|
@ -14,12 +14,6 @@
|
||||
// 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_dimensions;
|
||||
pub use array_dimensions::*;
|
||||
|
||||
pub mod const_self_keyword;
|
||||
pub use const_self_keyword::*;
|
||||
|
||||
pub mod global_consts_json;
|
||||
|
||||
pub mod identifier;
|
||||
@ -28,16 +22,5 @@ pub use identifier::*;
|
||||
pub mod imported_modules;
|
||||
pub use imported_modules::*;
|
||||
|
||||
pub mod mut_self_keyword;
|
||||
pub use mut_self_keyword::*;
|
||||
|
||||
pub mod positive_number;
|
||||
pub use positive_number::*;
|
||||
|
||||
pub mod self_keyword;
|
||||
pub use self_keyword::*;
|
||||
|
||||
pub mod spread_or_expression;
|
||||
pub use spread_or_expression::*;
|
||||
|
||||
pub mod vec_tendril_json;
|
||||
|
@ -1,45 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Identifier, Node};
|
||||
use leo_span::Span;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
/// The `&self` keyword can view and modify circuit values inside of a circuit function.
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
#[serde(transparent)]
|
||||
pub struct RefSelfKeyword {
|
||||
/// Always `&self`.
|
||||
pub identifier: Identifier,
|
||||
}
|
||||
|
||||
impl fmt::Display for RefSelfKeyword {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "&self")
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for RefSelfKeyword {
|
||||
fn span(&self) -> &Span {
|
||||
&self.identifier.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.identifier.span = span;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Identifier, Node};
|
||||
use leo_span::Span;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
/// The `self` keyword can view circuit values inside of a circuit function.
|
||||
/// Circuit values cannot be modified. To modify values use the `mut self` [MutSelfKeyword].
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
#[serde(transparent)]
|
||||
pub struct SelfKeyword {
|
||||
/// Always just `self`.
|
||||
pub identifier: Identifier,
|
||||
}
|
||||
|
||||
impl fmt::Display for SelfKeyword {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "self")
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for SelfKeyword {
|
||||
fn span(&self) -> &Span {
|
||||
&self.identifier.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.identifier.span = span;
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::{Expression, Node};
|
||||
use leo_span::Span;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
/// Either a spread expression or a normal expression.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum SpreadOrExpression {
|
||||
/// A spread expression, i.e., `...other_array`.
|
||||
Spread(Expression),
|
||||
/// A normal element expression.
|
||||
Expression(Expression),
|
||||
}
|
||||
|
||||
impl fmt::Display for SpreadOrExpression {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
SpreadOrExpression::Spread(ref spread) => write!(f, "...{}", spread),
|
||||
SpreadOrExpression::Expression(ref expression) => write!(f, "{}", expression),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for SpreadOrExpression {
|
||||
fn span(&self) -> &Span {
|
||||
use SpreadOrExpression::*;
|
||||
match self {
|
||||
Spread(expression) | Expression(expression) => expression.span(),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
use SpreadOrExpression::*;
|
||||
match self {
|
||||
Spread(expression) | Expression(expression) => expression.set_span(span),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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, Serialize, Serializer};
|
||||
use tendril::StrTendril;
|
||||
|
||||
#[allow(clippy::ptr_arg)]
|
||||
pub fn serialize<S: Serializer>(tendril: &Vec<StrTendril>, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
tendril
|
||||
.iter()
|
||||
.map(|x| x.as_ref())
|
||||
.collect::<Vec<_>>()
|
||||
.serialize(serializer)
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Vec<StrTendril>, D::Error> {
|
||||
Ok(Vec::<String>::deserialize(deserializer)?
|
||||
.into_iter()
|
||||
.map(|x| x.into())
|
||||
.collect())
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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 super::*;
|
||||
use crate::accesses::*;
|
||||
|
||||
/// An access expressions, extracting a smaller part out of a whole.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum AccessExpression {
|
||||
/// An `array[index]` expression.
|
||||
Array(ArrayAccess),
|
||||
/// An expression accessing a range of an array.
|
||||
ArrayRange(ArrayRangeAccess),
|
||||
/// An expression accessing a field in a structure, e.g., `circuit_var.field`.
|
||||
Member(MemberAccess),
|
||||
/// Access to a tuple field using its position, e.g., `tuple.1`.
|
||||
Tuple(TupleAccess),
|
||||
/// Access to a member constant or a static function of a circuit.
|
||||
Static(StaticAccess),
|
||||
}
|
||||
|
||||
impl fmt::Display for AccessExpression {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use AccessExpression::*;
|
||||
|
||||
match self {
|
||||
Array(access) => access.fmt(f),
|
||||
ArrayRange(access) => access.fmt(f),
|
||||
Member(access) => access.fmt(f),
|
||||
Tuple(access) => access.fmt(f),
|
||||
Static(access) => access.fmt(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for AccessExpression {
|
||||
fn span(&self) -> &Span {
|
||||
use AccessExpression::*;
|
||||
|
||||
match &self {
|
||||
Array(access) => access.span(),
|
||||
ArrayRange(access) => access.span(),
|
||||
Member(access) => access.span(),
|
||||
Tuple(access) => access.span(),
|
||||
Static(access) => access.span(),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
use AccessExpression::*;
|
||||
|
||||
match self {
|
||||
Array(access) => access.set_span(span),
|
||||
ArrayRange(access) => access.set_span(span),
|
||||
Member(access) => access.set_span(span),
|
||||
Tuple(access) => access.set_span(span),
|
||||
Static(access) => access.set_span(span),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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 super::*;
|
||||
|
||||
/// An array initializer expression, e.g., `[42; 5]`.
|
||||
/// constructing an array of `element` repeated according to `dimensions`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ArrayInitExpression {
|
||||
/// The expression that all elements in the array will evaluate to.
|
||||
pub element: Box<Expression>,
|
||||
/// The dimensions of the array.
|
||||
///
|
||||
/// This could be a multi-dimensional array,
|
||||
/// e.g., `[42; (2, 2)]`, giving you a matrix `[[42, 42], [42, 42]]`.
|
||||
pub dimensions: ArrayDimensions,
|
||||
/// The span of the entire expression from `[` to `]`.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Display for ArrayInitExpression {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "[{}; {}]", self.element, self.dimensions)
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for ArrayInitExpression {
|
||||
fn span(&self) -> &Span {
|
||||
&self.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.span = span;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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 super::*;
|
||||
|
||||
/// An expression constructing an array by listing the individual elements inline,
|
||||
/// for example `[4, 6, 5, 2]`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ArrayInlineExpression {
|
||||
/// A list, where a part can be either an element,
|
||||
/// or list of elements to construct the array with.
|
||||
pub elements: Vec<SpreadOrExpression>,
|
||||
/// The span of the entire expression from `[` to `]`.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Display for ArrayInlineExpression {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "[")?;
|
||||
for (i, e) in self.elements.iter().enumerate() {
|
||||
write!(f, "{}", e)?;
|
||||
if i < self.elements.len() - 1 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
}
|
||||
write!(f, "]")
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for ArrayInlineExpression {
|
||||
fn span(&self) -> &Span {
|
||||
&self.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.span = span;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::Type;
|
||||
|
||||
use super::*;
|
||||
|
||||
/// A cast expression `e as U`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CastExpression {
|
||||
/// The expression `e` of a type `T` that is being cast to `U`.
|
||||
pub inner: Box<Expression>,
|
||||
/// The type `U` to cast `e` to.
|
||||
pub target_type: Type,
|
||||
/// Span for the entire expression `e as U` to.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Display for CastExpression {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{} as {}", self.inner, self.target_type)
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for CastExpression {
|
||||
fn span(&self) -> &Span {
|
||||
&self.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.span = span;
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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 super::*;
|
||||
|
||||
/// An initializer for a single field / variable of a circuit initializer expression.
|
||||
/// That is, in `Foo { bar: 42, baz }`, this is either `bar: 42`, or `baz`.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CircuitVariableInitializer {
|
||||
/// The name of the field / variable to be initialized.
|
||||
pub identifier: Identifier,
|
||||
/// The expression to initialize the field with.
|
||||
/// When `None`, a binding, in scope, with the name will be used instead.
|
||||
pub expression: Option<Expression>,
|
||||
}
|
||||
|
||||
impl fmt::Display for CircuitVariableInitializer {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if let Some(expr) = &self.expression {
|
||||
write!(f, "{}: {}", self.identifier, expr)
|
||||
} else {
|
||||
write!(f, "{}", self.identifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A circuit initialization expression, e.g., `Foo { bar: 42, baz }`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CircuitInitExpression {
|
||||
/// The name of the structure type to initialize.
|
||||
pub name: Identifier,
|
||||
/// Initializer expressions for each of the fields in the circuit.
|
||||
///
|
||||
/// N.B. Any functions or member constants in the circuit definition
|
||||
/// are excluded from this list.
|
||||
pub members: Vec<CircuitVariableInitializer>,
|
||||
/// A span from `name` to `}`.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Display for CircuitInitExpression {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{} {{", self.name)?;
|
||||
for member in self.members.iter() {
|
||||
write!(f, "{}", member)?;
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
write!(f, "}}")
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for CircuitInitExpression {
|
||||
fn span(&self) -> &Span {
|
||||
&self.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.span = span;
|
||||
}
|
||||
}
|
@ -14,35 +14,23 @@
|
||||
// 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::{ArrayDimensions, GroupValue, Identifier, IntegerType, Node, SpreadOrExpression};
|
||||
use crate::{GroupValue, Identifier, IntegerType, Node};
|
||||
|
||||
use leo_span::Span;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
mod accesses;
|
||||
pub use accesses::*;
|
||||
mod binary;
|
||||
pub use binary::*;
|
||||
mod unary;
|
||||
pub use unary::*;
|
||||
mod ternary;
|
||||
pub use ternary::*;
|
||||
mod array_inline;
|
||||
pub use array_inline::*;
|
||||
mod array_init;
|
||||
pub use array_init::*;
|
||||
mod tuple_init;
|
||||
pub use tuple_init::*;
|
||||
mod circuit_init;
|
||||
pub use circuit_init::*;
|
||||
mod value;
|
||||
pub use value::*;
|
||||
mod call;
|
||||
pub use call::*;
|
||||
mod cast;
|
||||
pub use cast::*;
|
||||
mod err;
|
||||
pub use err::*;
|
||||
|
||||
@ -59,19 +47,6 @@ pub enum Expression {
|
||||
Unary(UnaryExpression),
|
||||
/// A ternary conditional expression `cond ? if_expr : else_expr`.
|
||||
Ternary(TernaryExpression),
|
||||
/// A cast expression `expr as type`.
|
||||
Cast(CastExpression),
|
||||
/// An access expression of some sort, e.g., `array[idx]` or `foo.bar`.
|
||||
Access(AccessExpression),
|
||||
/// An array expression where individual elements are listed inline,
|
||||
/// for example `[4, 6, ...[5, 7], 2]`.
|
||||
ArrayInline(ArrayInlineExpression),
|
||||
/// An array-repeat expression, e.g., `[42; 3]` yielding `[42, 42, 42]`.
|
||||
ArrayInit(ArrayInitExpression),
|
||||
/// A tuple expression e.g., `(foo, 42, true)`.
|
||||
TupleInit(TupleInitExpression),
|
||||
/// An expression constructing a structure like `Foo { bar: 42, baz }`.
|
||||
CircuitInit(CircuitInitExpression),
|
||||
/// A call expression like `my_fun(args)`.
|
||||
Call(CallExpression),
|
||||
/// An expression of type "error".
|
||||
@ -88,13 +63,7 @@ impl Node for Expression {
|
||||
Binary(n) => n.span(),
|
||||
Unary(n) => n.span(),
|
||||
Ternary(n) => n.span(),
|
||||
ArrayInline(n) => n.span(),
|
||||
ArrayInit(n) => n.span(),
|
||||
TupleInit(n) => n.span(),
|
||||
CircuitInit(n) => n.span(),
|
||||
Call(n) => n.span(),
|
||||
Cast(n) => n.span(),
|
||||
Access(n) => n.span(),
|
||||
Err(n) => n.span(),
|
||||
}
|
||||
}
|
||||
@ -107,13 +76,7 @@ impl Node for Expression {
|
||||
Binary(n) => n.set_span(span),
|
||||
Unary(n) => n.set_span(span),
|
||||
Ternary(n) => n.set_span(span),
|
||||
ArrayInline(n) => n.set_span(span),
|
||||
ArrayInit(n) => n.set_span(span),
|
||||
TupleInit(n) => n.set_span(span),
|
||||
CircuitInit(n) => n.set_span(span),
|
||||
Call(n) => n.set_span(span),
|
||||
Cast(n) => n.set_span(span),
|
||||
Access(n) => n.set_span(span),
|
||||
Err(n) => n.set_span(span),
|
||||
}
|
||||
}
|
||||
@ -128,13 +91,7 @@ impl fmt::Display for Expression {
|
||||
Binary(n) => n.fmt(f),
|
||||
Unary(n) => n.fmt(f),
|
||||
Ternary(n) => n.fmt(f),
|
||||
ArrayInline(n) => n.fmt(f),
|
||||
ArrayInit(n) => n.fmt(f),
|
||||
TupleInit(n) => n.fmt(f),
|
||||
CircuitInit(n) => n.fmt(f),
|
||||
Call(n) => n.fmt(f),
|
||||
Cast(n) => n.fmt(f),
|
||||
Access(n) => n.fmt(f),
|
||||
Err(n) => n.fmt(f),
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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 super::*;
|
||||
|
||||
/// A tuple construction expression, e.g., `(foo, false, 42)`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct TupleInitExpression {
|
||||
/// The elements of the tuple.
|
||||
/// In the example above, it would be `foo`, `false`, and `42`.
|
||||
pub elements: Vec<Expression>,
|
||||
/// The span from `(` to `)`.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Display for TupleInitExpression {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "(")?;
|
||||
for (i, member) in self.elements.iter().enumerate() {
|
||||
write!(f, "{}", member)?;
|
||||
if i < self.elements.len() - 1 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
}
|
||||
write!(f, ")")
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for TupleInitExpression {
|
||||
fn span(&self) -> &Span {
|
||||
&self.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.span = span;
|
||||
}
|
||||
}
|
@ -14,10 +14,9 @@
|
||||
// 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::{Annotation, Block, FunctionInput, Identifier, Node, Type};
|
||||
use crate::{Block, FunctionInput, Identifier, Node, Type};
|
||||
use leo_span::{sym, Span, Symbol};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cell::Cell;
|
||||
use std::fmt;
|
||||
@ -25,8 +24,6 @@ use std::fmt;
|
||||
/// A function definition.
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct Function {
|
||||
/// A map of all the annotations from their base names to the whole.
|
||||
pub annotations: IndexMap<Symbol, Annotation>,
|
||||
/// The function identifier, e.g., `foo` in `function foo(...) { ... }`.
|
||||
pub identifier: Identifier,
|
||||
/// The function's parameters.
|
||||
@ -63,29 +60,6 @@ impl Function {
|
||||
self.name() == sym::main
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns `true` if the function has input `self` or `mut self`.
|
||||
/// Returns `false` otherwise.
|
||||
///
|
||||
pub fn contains_self(&self) -> bool {
|
||||
self.input.iter().any(|param| param.is_self())
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns `true` if the function has input `mut self`.
|
||||
/// Returns `false` otherwise.
|
||||
///
|
||||
pub fn contains_mut_self(&self) -> bool {
|
||||
self.input.iter().any(|param| param.is_mut_self())
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns an iterator of [&FunctionInput] removing `self` and `mut self` inputs.
|
||||
///
|
||||
pub fn filter_self_inputs(&self) -> impl Iterator<Item = &FunctionInput> {
|
||||
self.input.iter().filter(|input| !input.is_self())
|
||||
}
|
||||
|
||||
///
|
||||
/// Private formatting method used for optimizing [fmt::Debug] and [fmt::Display] implementations.
|
||||
///
|
||||
|
@ -14,7 +14,7 @@
|
||||
// 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::{ConstSelfKeyword, FunctionInputVariable, Node, RefSelfKeyword, SelfKeyword};
|
||||
use crate::{FunctionInputVariable, Node};
|
||||
use leo_span::Span;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -23,74 +23,24 @@ use std::fmt;
|
||||
/// Enumerates the possible inputs to a function.
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub enum FunctionInput {
|
||||
/// A `self` parameter.
|
||||
SelfKeyword(SelfKeyword),
|
||||
/// A `const self` parameter.
|
||||
ConstSelfKeyword(ConstSelfKeyword),
|
||||
/// A `&self` parameter.
|
||||
RefSelfKeyword(RefSelfKeyword),
|
||||
/// A normal function parameter.
|
||||
Variable(FunctionInputVariable),
|
||||
}
|
||||
|
||||
impl FunctionInput {
|
||||
///
|
||||
/// Returns `true` if the function input is the `self` or `mut self` keyword.
|
||||
/// Returns `false` otherwise.
|
||||
///
|
||||
pub fn is_self(&self) -> bool {
|
||||
match self {
|
||||
FunctionInput::SelfKeyword(_) => true,
|
||||
FunctionInput::ConstSelfKeyword(_) => true,
|
||||
FunctionInput::RefSelfKeyword(_) => true,
|
||||
FunctionInput::Variable(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns `true` if the function input is the `const self` keyword.
|
||||
/// Returns `false` otherwise.
|
||||
///
|
||||
pub fn is_const_self(&self) -> bool {
|
||||
match self {
|
||||
FunctionInput::SelfKeyword(_) => false,
|
||||
FunctionInput::ConstSelfKeyword(_) => true,
|
||||
FunctionInput::RefSelfKeyword(_) => false,
|
||||
FunctionInput::Variable(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns `true` if the function input is the `mut self` keyword.
|
||||
/// Returns `false` otherwise.
|
||||
///
|
||||
pub fn is_mut_self(&self) -> bool {
|
||||
match self {
|
||||
FunctionInput::SelfKeyword(_) => false,
|
||||
FunctionInput::ConstSelfKeyword(_) => false,
|
||||
FunctionInput::RefSelfKeyword(_) => true,
|
||||
FunctionInput::Variable(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns Option with FunctionInputVariable if the input is a variable.
|
||||
/// Returns None otherwise.
|
||||
///
|
||||
pub fn get_variable(&self) -> Option<&FunctionInputVariable> {
|
||||
if let FunctionInput::Variable(var) = self {
|
||||
Some(var)
|
||||
} else {
|
||||
None
|
||||
pub fn get_variable(&self) -> &FunctionInputVariable {
|
||||
match self {
|
||||
Self::Variable(var) => var,
|
||||
}
|
||||
}
|
||||
|
||||
/// Formats the parameter to `f`.
|
||||
fn format(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
FunctionInput::SelfKeyword(keyword) => write!(f, "{}", keyword),
|
||||
FunctionInput::ConstSelfKeyword(keyword) => write!(f, "{}", keyword),
|
||||
FunctionInput::RefSelfKeyword(keyword) => write!(f, "{}", keyword),
|
||||
FunctionInput::Variable(function_input) => write!(f, "{}", function_input),
|
||||
}
|
||||
}
|
||||
@ -112,11 +62,7 @@ impl PartialEq for FunctionInput {
|
||||
/// Returns true if `self == other`. Does not compare spans.
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(FunctionInput::SelfKeyword(_), FunctionInput::SelfKeyword(_)) => true,
|
||||
(FunctionInput::ConstSelfKeyword(_), FunctionInput::ConstSelfKeyword(_)) => true,
|
||||
(FunctionInput::RefSelfKeyword(_), FunctionInput::RefSelfKeyword(_)) => true,
|
||||
(FunctionInput::Variable(left), FunctionInput::Variable(right)) => left.eq(right),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -127,9 +73,6 @@ impl Node for FunctionInput {
|
||||
fn span(&self) -> &Span {
|
||||
use FunctionInput::*;
|
||||
match self {
|
||||
SelfKeyword(keyword) => &keyword.identifier.span,
|
||||
ConstSelfKeyword(keyword) => &keyword.identifier.span,
|
||||
RefSelfKeyword(keyword) => &keyword.identifier.span,
|
||||
Variable(variable) => &variable.span,
|
||||
}
|
||||
}
|
||||
@ -137,9 +80,6 @@ impl Node for FunctionInput {
|
||||
fn set_span(&mut self, span: Span) {
|
||||
use FunctionInput::*;
|
||||
match self {
|
||||
SelfKeyword(keyword) => keyword.identifier.span = span,
|
||||
ConstSelfKeyword(keyword) => keyword.identifier.span = span,
|
||||
RefSelfKeyword(keyword) => keyword.identifier.span = span,
|
||||
Variable(variable) => variable.span = span,
|
||||
}
|
||||
}
|
||||
|
@ -1,119 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// 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::Identifier;
|
||||
use leo_span::{Span, Symbol};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
/// Represents an import statement in a Leo program.
|
||||
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ImportStatement {
|
||||
/// The tree specifying what items or packages to import.
|
||||
pub tree: ImportTree,
|
||||
/// The span, excluding the `;`.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl ImportStatement {
|
||||
/// Returns the the package file name of the self import statement.
|
||||
pub fn get_file_name(&self) -> Symbol {
|
||||
self.tree.base.first().unwrap().name
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ImportStatement {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "import {};", self.tree)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for ImportStatement {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
/// An import tree specifies item(s) to import.
|
||||
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ImportTree {
|
||||
/// A path to the base item or package to import or import from.
|
||||
/// The list is always non-empty.
|
||||
pub base: Vec<Identifier>,
|
||||
/// Specifies the kind of import and the meaning of `base`.
|
||||
/// This includes plain imports, renames, globs (`*`), and nested imports.
|
||||
pub kind: ImportTreeKind,
|
||||
/// The span for the import excluding `import` and `;`.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Display for ImportTree {
|
||||
/// Formats `self` to `f`.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
// Format the path.
|
||||
for (i, part) in self.base.iter().enumerate() {
|
||||
write!(f, "{}", part)?;
|
||||
if i < self.base.len() - 1 {
|
||||
write!(f, ".")?;
|
||||
}
|
||||
}
|
||||
|
||||
// Format the kind.
|
||||
match &self.kind {
|
||||
ImportTreeKind::Glob { .. } => write!(f, ".*"),
|
||||
ImportTreeKind::Leaf { alias: None } => Ok(()),
|
||||
ImportTreeKind::Leaf { alias: Some(alias) } => write!(f, "as {}", alias),
|
||||
ImportTreeKind::Nested { tree } => {
|
||||
write!(f, ".(")?;
|
||||
for (i, node) in tree.iter().enumerate() {
|
||||
write!(f, "{}", node)?;
|
||||
if i < tree.len() - 1 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
}
|
||||
write!(f, ")")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for ImportTree {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
/// Specifies the import kind and the meaning of `base`.
|
||||
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub enum ImportTreeKind {
|
||||
/// A glob import `*`.
|
||||
Glob {
|
||||
/// The span for the `*`.
|
||||
span: Span,
|
||||
},
|
||||
/// A leaf package to import.
|
||||
Leaf {
|
||||
/// When specified, the package is imported under a different name.
|
||||
/// Otherwise, the `base` name is used as in the `ImportTree`.
|
||||
alias: Option<Identifier>,
|
||||
},
|
||||
/// A nested import of items or sub-packages.
|
||||
Nested {
|
||||
/// The sub-tree specifying what to import from the `base`.
|
||||
tree: Vec<ImportTree>,
|
||||
},
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
// 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::{CharValue, Expression, GroupValue, IntegerType, Node, SpreadOrExpression, Type, ValueExpression};
|
||||
use crate::{CharValue, Expression, GroupValue, IntegerType, Node, Type, ValueExpression};
|
||||
use leo_errors::{InputError, LeoError, ParserError, Result};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -28,8 +28,6 @@ pub enum InputValue {
|
||||
Field(String),
|
||||
Group(GroupValue),
|
||||
Integer(IntegerType, String),
|
||||
Array(Vec<InputValue>),
|
||||
Tuple(Vec<InputValue>),
|
||||
}
|
||||
|
||||
impl TryFrom<(Type, Expression)> for InputValue {
|
||||
@ -56,89 +54,11 @@ impl TryFrom<(Type, Expression)> for InputValue {
|
||||
return Err(InputError::unexpected_type(expected.to_string(), actual, &span).into());
|
||||
}
|
||||
}
|
||||
(Type::Array(type_, _), ValueExpression::String(string, span)) => {
|
||||
if !matches!(*type_, Type::Char) {
|
||||
return Err(InputError::string_is_array_of_chars(type_, &span).into());
|
||||
}
|
||||
|
||||
Self::Array(
|
||||
string
|
||||
.into_iter()
|
||||
.map(|c| {
|
||||
Self::Char(CharValue {
|
||||
character: c,
|
||||
span: span.clone(),
|
||||
})
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
(x, y) => {
|
||||
return Err(InputError::unexpected_type(x, &y, y.span()).into());
|
||||
}
|
||||
}
|
||||
}
|
||||
(Type::Array(type_, type_dimensions), Expression::ArrayInit(mut array_init)) => {
|
||||
let span = array_init.span.clone();
|
||||
|
||||
if type_dimensions != array_init.dimensions || array_init.dimensions.is_zero() {
|
||||
return Err(InputError::invalid_array_dimension_size(&span).into());
|
||||
}
|
||||
|
||||
if let Some(dimension) = array_init.dimensions.remove_first() {
|
||||
let size = dimension.value.parse::<usize>().unwrap();
|
||||
let mut values = Vec::with_capacity(size);
|
||||
|
||||
// For when Dimensions are specified in a canonical way: [[u8; 3], 2];
|
||||
// Else treat as math notation: [u8; (2, 3)];
|
||||
if array_init.dimensions.len() == 0 {
|
||||
for _ in 0..size {
|
||||
values.push(InputValue::try_from((*type_.clone(), *array_init.element.clone()))?);
|
||||
}
|
||||
// Faking canonical array init is relatively easy: instead of using a straightforward
|
||||
// recursion, with each iteration we manually modify ArrayInitExpression cutting off
|
||||
// dimension by dimension.
|
||||
} else {
|
||||
for _ in 0..size {
|
||||
values.push(InputValue::try_from((
|
||||
Type::Array(type_.clone(), array_init.dimensions.clone()),
|
||||
Expression::ArrayInit(array_init.clone()),
|
||||
))?);
|
||||
}
|
||||
};
|
||||
|
||||
Self::Array(values)
|
||||
} else {
|
||||
unreachable!("dimensions are checked for zero");
|
||||
}
|
||||
}
|
||||
(Type::Tuple(types), Expression::TupleInit(tuple_init)) => {
|
||||
let size = tuple_init.elements.len();
|
||||
let mut elements = Vec::with_capacity(size);
|
||||
|
||||
if size != types.len() {
|
||||
return Err(InputError::tuple_length_mismatch(size, types.len(), tuple_init.span()).into());
|
||||
}
|
||||
|
||||
for (i, element) in tuple_init.elements.into_iter().enumerate() {
|
||||
elements.push(Self::try_from((types[i].clone(), element))?);
|
||||
}
|
||||
|
||||
Self::Tuple(elements)
|
||||
}
|
||||
(Type::Array(element_type, _dimensions), Expression::ArrayInline(array_inline)) => {
|
||||
let mut elements = Vec::with_capacity(array_inline.elements.len());
|
||||
let span = array_inline.span().clone();
|
||||
|
||||
for element in array_inline.elements.into_iter() {
|
||||
if let SpreadOrExpression::Expression(value_expression) = element {
|
||||
elements.push(Self::try_from((*element_type.clone(), value_expression))?);
|
||||
} else {
|
||||
return Err(InputError::array_spread_is_not_allowed(&span).into());
|
||||
}
|
||||
}
|
||||
Self::Array(elements)
|
||||
}
|
||||
(_type_, expr) => return Err(InputError::illegal_expression(&expr, expr.span()).into()),
|
||||
})
|
||||
}
|
||||
@ -153,14 +73,6 @@ impl fmt::Display for InputValue {
|
||||
InputValue::Group(ref group) => write!(f, "{}", group),
|
||||
InputValue::Field(ref field) => write!(f, "{}", field),
|
||||
InputValue::Integer(ref type_, ref number) => write!(f, "{}{:?}", number, type_),
|
||||
InputValue::Array(ref array) => {
|
||||
let values = array.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(", ");
|
||||
write!(f, "array [{}]", values)
|
||||
}
|
||||
InputValue::Tuple(ref tuple) => {
|
||||
let values = tuple.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(", ");
|
||||
write!(f, "({})", values)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,18 +22,6 @@
|
||||
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
pub mod accesses;
|
||||
pub use self::accesses::*;
|
||||
|
||||
pub mod aliases;
|
||||
pub use self::aliases::*;
|
||||
|
||||
pub mod annotation;
|
||||
pub use self::annotation::*;
|
||||
|
||||
pub mod circuits;
|
||||
pub use self::circuits::*;
|
||||
|
||||
pub mod chars;
|
||||
pub use self::chars::*;
|
||||
|
||||
@ -49,9 +37,6 @@ pub use self::functions::*;
|
||||
pub mod groups;
|
||||
pub use self::groups::*;
|
||||
|
||||
pub mod imports;
|
||||
pub use self::imports::*;
|
||||
|
||||
pub mod input;
|
||||
pub use self::input::*;
|
||||
|
||||
|
@ -17,9 +17,7 @@
|
||||
//! A Leo program consists of import, circuit, and function definitions.
|
||||
//! Each defined type consists of ast statements and expressions.
|
||||
|
||||
use crate::{Alias, Circuit, CircuitMember, DefinitionStatement, Function, FunctionInput, Identifier, ImportStatement};
|
||||
|
||||
use leo_span::{sym, Symbol};
|
||||
use crate::{Function, FunctionInput, Identifier};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -34,18 +32,6 @@ pub struct Program {
|
||||
/// Expected main function inputs.
|
||||
/// Empty after parsing.
|
||||
pub expected_input: Vec<FunctionInput>,
|
||||
/// The collected import statements.
|
||||
pub import_statements: Vec<ImportStatement>,
|
||||
#[serde(with = "crate::common::imported_modules")]
|
||||
/// A map from paths to injected programs.
|
||||
pub imports: IndexMap<Vec<Symbol>, Program>,
|
||||
/// A map from alias names to type aliases.
|
||||
pub aliases: IndexMap<Identifier, Alias>,
|
||||
/// A map from circuit names to circuit definitions.
|
||||
pub circuits: IndexMap<Identifier, Circuit>,
|
||||
/// A map from constant names to their definitions.
|
||||
#[serde(with = "crate::common::global_consts_json")]
|
||||
pub global_consts: IndexMap<Vec<Identifier>, DefinitionStatement>,
|
||||
/// A map from function names to their definitions.
|
||||
pub functions: IndexMap<Identifier, Function>,
|
||||
}
|
||||
@ -58,26 +44,6 @@ impl AsRef<Program> for Program {
|
||||
|
||||
impl fmt::Display for Program {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
for import in self.import_statements.iter() {
|
||||
import.fmt(f)?;
|
||||
writeln!(f,)?;
|
||||
}
|
||||
writeln!(f,)?;
|
||||
for (_, alias) in self.aliases.iter() {
|
||||
alias.fmt(f)?;
|
||||
writeln!(f,)?;
|
||||
}
|
||||
writeln!(f,)?;
|
||||
for (_, import) in self.imports.iter() {
|
||||
import.fmt(f)?;
|
||||
writeln!(f,)?;
|
||||
}
|
||||
writeln!(f,)?;
|
||||
for (_, circuit) in self.circuits.iter() {
|
||||
circuit.fmt(f)?;
|
||||
writeln!(f,)?;
|
||||
}
|
||||
writeln!(f,)?;
|
||||
for (_, function) in self.functions.iter() {
|
||||
function.fmt(f)?;
|
||||
writeln!(f,)?;
|
||||
@ -92,47 +58,10 @@ impl Program {
|
||||
Self {
|
||||
name,
|
||||
expected_input: vec![],
|
||||
import_statements: vec![],
|
||||
imports: IndexMap::new(),
|
||||
aliases: IndexMap::new(),
|
||||
circuits: IndexMap::new(),
|
||||
global_consts: IndexMap::new(),
|
||||
functions: IndexMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles all internal annotations like `@CoreFunction` and `@AlwaysConst`.
|
||||
pub fn handle_internal_annotations(&mut self) {
|
||||
self.circuits
|
||||
.iter_mut()
|
||||
.flat_map(|(_, circuit)| &mut circuit.members)
|
||||
.filter_map(|member| {
|
||||
if let CircuitMember::CircuitFunction(function) = member {
|
||||
Some(function)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.for_each(|function| {
|
||||
function.annotations.retain(|name, core_map| {
|
||||
match *name {
|
||||
sym::CoreFunction => {
|
||||
let new = core_map.arguments.get(0).copied().or(Some(function.identifier.name));
|
||||
function.core_mapping.replace(new);
|
||||
false
|
||||
}
|
||||
sym::AlwaysConst => {
|
||||
function.const_ = true;
|
||||
false
|
||||
}
|
||||
// Could still be a valid annotation.
|
||||
// Carry on and let ASG handle.
|
||||
_ => true,
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/// Extract the name of the program.
|
||||
pub fn get_name(&self) -> String {
|
||||
self.name.to_string()
|
||||
|
@ -20,7 +20,7 @@
|
||||
use crate::*;
|
||||
|
||||
use leo_errors::{AstError, Result};
|
||||
use leo_span::{Span, Symbol};
|
||||
use leo_span::Span;
|
||||
|
||||
use indexmap::IndexMap;
|
||||
|
||||
@ -35,15 +35,6 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
|
||||
pub fn reduce_type(&mut self, type_: &Type, span: &Span) -> Result<Type> {
|
||||
let new = match type_ {
|
||||
Type::Array(type_, dimensions) => Type::Array(Box::new(self.reduce_type(type_, span)?), dimensions.clone()),
|
||||
Type::Tuple(types) => {
|
||||
let mut reduced_types = vec![];
|
||||
for type_ in types.iter() {
|
||||
reduced_types.push(self.reduce_type(type_, span)?);
|
||||
}
|
||||
|
||||
Type::Tuple(reduced_types)
|
||||
}
|
||||
Type::Identifier(identifier) => Type::Identifier(self.reduce_identifier(identifier)?),
|
||||
_ => type_.clone(),
|
||||
};
|
||||
@ -59,16 +50,6 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
Expression::Binary(binary) => Expression::Binary(self.reduce_binary(binary)?),
|
||||
Expression::Unary(unary) => Expression::Unary(self.reduce_unary(unary)?),
|
||||
Expression::Ternary(ternary) => Expression::Ternary(self.reduce_ternary(ternary)?),
|
||||
Expression::Cast(cast) => Expression::Cast(self.reduce_cast(cast)?),
|
||||
Expression::Access(access) => Expression::Access(self.reduce_access(access)?),
|
||||
|
||||
Expression::ArrayInline(array_inline) => Expression::ArrayInline(self.reduce_array_inline(array_inline)?),
|
||||
Expression::ArrayInit(array_init) => Expression::ArrayInit(self.reduce_array_init(array_init)?),
|
||||
|
||||
Expression::TupleInit(tuple_init) => Expression::TupleInit(self.reduce_tuple_init(tuple_init)?),
|
||||
|
||||
Expression::CircuitInit(circuit_init) => Expression::CircuitInit(self.reduce_circuit_init(circuit_init)?),
|
||||
|
||||
Expression::Call(call) => Expression::Call(self.reduce_call(call)?),
|
||||
Expression::Err(s) => Expression::Err(s.clone()),
|
||||
};
|
||||
@ -130,140 +111,6 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
self.reducer.reduce_ternary(ternary, condition, if_true, if_false)
|
||||
}
|
||||
|
||||
pub fn reduce_cast(&mut self, cast: &CastExpression) -> Result<CastExpression> {
|
||||
let inner = self.reduce_expression(&cast.inner)?;
|
||||
let target_type = self.reduce_type(&cast.target_type, &cast.span)?;
|
||||
|
||||
self.reducer.reduce_cast(cast, inner, target_type)
|
||||
}
|
||||
|
||||
pub fn reduce_array_access(&mut self, array_access: &ArrayAccess) -> Result<ArrayAccess> {
|
||||
let array = self.reduce_expression(&array_access.array)?;
|
||||
let index = self.reduce_expression(&array_access.index)?;
|
||||
|
||||
self.reducer.reduce_array_access(array_access, array, index)
|
||||
}
|
||||
|
||||
pub fn reduce_array_range_access(&mut self, array_range_access: &ArrayRangeAccess) -> Result<ArrayRangeAccess> {
|
||||
let array = self.reduce_expression(&array_range_access.array)?;
|
||||
let left = array_range_access
|
||||
.left
|
||||
.as_ref()
|
||||
.map(|left| self.reduce_expression(left))
|
||||
.transpose()?;
|
||||
let right = array_range_access
|
||||
.right
|
||||
.as_ref()
|
||||
.map(|right| self.reduce_expression(right))
|
||||
.transpose()?;
|
||||
|
||||
self.reducer
|
||||
.reduce_array_range_access(array_range_access, array, left, right)
|
||||
}
|
||||
|
||||
pub fn reduce_member_access(&mut self, member_access: &MemberAccess) -> Result<MemberAccess> {
|
||||
let inner = self.reduce_expression(&member_access.inner)?;
|
||||
let name = self.reduce_identifier(&member_access.name)?;
|
||||
let type_ = member_access
|
||||
.type_
|
||||
.as_ref()
|
||||
.map(|type_| self.reduce_type(type_, &member_access.span))
|
||||
.transpose()?;
|
||||
|
||||
self.reducer.reduce_member_access(member_access, inner, name, type_)
|
||||
}
|
||||
|
||||
pub fn reduce_tuple_access(&mut self, tuple_access: &TupleAccess) -> Result<TupleAccess> {
|
||||
let tuple = self.reduce_expression(&tuple_access.tuple)?;
|
||||
|
||||
self.reducer.reduce_tuple_access(tuple_access, tuple)
|
||||
}
|
||||
|
||||
pub fn reduce_static_access(&mut self, static_access: &StaticAccess) -> Result<StaticAccess> {
|
||||
let value = self.reduce_expression(&static_access.inner)?;
|
||||
let name = self.reduce_identifier(&static_access.name)?;
|
||||
let type_ = static_access
|
||||
.type_
|
||||
.as_ref()
|
||||
.map(|type_| self.reduce_type(type_, &static_access.span))
|
||||
.transpose()?;
|
||||
|
||||
self.reducer.reduce_static_access(static_access, value, type_, name)
|
||||
}
|
||||
|
||||
pub fn reduce_access(&mut self, access: &AccessExpression) -> Result<AccessExpression> {
|
||||
use AccessExpression::*;
|
||||
|
||||
let new = match access {
|
||||
Array(access) => Array(self.reduce_array_access(access)?),
|
||||
ArrayRange(access) => ArrayRange(self.reduce_array_range_access(access)?),
|
||||
Member(access) => Member(self.reduce_member_access(access)?),
|
||||
Tuple(access) => Tuple(self.reduce_tuple_access(access)?),
|
||||
Static(access) => Static(self.reduce_static_access(access)?),
|
||||
};
|
||||
|
||||
Ok(new)
|
||||
}
|
||||
|
||||
pub fn reduce_array_inline(&mut self, array_inline: &ArrayInlineExpression) -> Result<ArrayInlineExpression> {
|
||||
let mut elements = vec![];
|
||||
for element in array_inline.elements.iter() {
|
||||
let reduced_element = match element {
|
||||
SpreadOrExpression::Expression(expression) => {
|
||||
SpreadOrExpression::Expression(self.reduce_expression(expression)?)
|
||||
}
|
||||
SpreadOrExpression::Spread(expression) => {
|
||||
SpreadOrExpression::Spread(self.reduce_expression(expression)?)
|
||||
}
|
||||
};
|
||||
|
||||
elements.push(reduced_element);
|
||||
}
|
||||
|
||||
self.reducer.reduce_array_inline(array_inline, elements)
|
||||
}
|
||||
|
||||
pub fn reduce_array_init(&mut self, array_init: &ArrayInitExpression) -> Result<ArrayInitExpression> {
|
||||
let element = self.reduce_expression(&array_init.element)?;
|
||||
|
||||
self.reducer.reduce_array_init(array_init, element)
|
||||
}
|
||||
|
||||
pub fn reduce_tuple_init(&mut self, tuple_init: &TupleInitExpression) -> Result<TupleInitExpression> {
|
||||
let mut elements = vec![];
|
||||
for element in tuple_init.elements.iter() {
|
||||
elements.push(self.reduce_expression(element)?);
|
||||
}
|
||||
|
||||
self.reducer.reduce_tuple_init(tuple_init, elements)
|
||||
}
|
||||
|
||||
pub fn reduce_circuit_variable_initializer(
|
||||
&mut self,
|
||||
variable: &CircuitVariableInitializer,
|
||||
) -> Result<CircuitVariableInitializer> {
|
||||
let identifier = self.reduce_identifier(&variable.identifier)?;
|
||||
let expression = variable
|
||||
.expression
|
||||
.as_ref()
|
||||
.map(|expr| self.reduce_expression(expr))
|
||||
.transpose()?;
|
||||
|
||||
self.reducer
|
||||
.reduce_circuit_variable_initializer(variable, identifier, expression)
|
||||
}
|
||||
|
||||
pub fn reduce_circuit_init(&mut self, circuit_init: &CircuitInitExpression) -> Result<CircuitInitExpression> {
|
||||
let name = self.reduce_identifier(&circuit_init.name)?;
|
||||
|
||||
let mut members = vec![];
|
||||
for member in circuit_init.members.iter() {
|
||||
members.push(self.reduce_circuit_variable_initializer(member)?);
|
||||
}
|
||||
|
||||
self.reducer.reduce_circuit_init(circuit_init, name, members)
|
||||
}
|
||||
|
||||
pub fn reduce_call(&mut self, call: &CallExpression) -> Result<CallExpression> {
|
||||
let function = self.reduce_expression(&call.function)?;
|
||||
|
||||
@ -422,57 +269,12 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
inputs.push(self.reduce_function_input(input)?);
|
||||
}
|
||||
|
||||
let mut import_statements = vec![];
|
||||
for import in program.import_statements.iter() {
|
||||
import_statements.push(self.reduce_import_statement(import)?);
|
||||
}
|
||||
|
||||
let mut imports = IndexMap::new();
|
||||
for (identifier, program) in program.imports.iter() {
|
||||
let (ident, import) = self.reduce_import(identifier, program)?;
|
||||
imports.insert(ident, import);
|
||||
}
|
||||
|
||||
let mut aliases = IndexMap::new();
|
||||
for (name, alias) in program.aliases.iter() {
|
||||
let represents = self.reduce_type(&alias.represents, &alias.name.span)?;
|
||||
aliases.insert(
|
||||
name.clone(),
|
||||
Alias {
|
||||
name: alias.name.clone(),
|
||||
span: alias.span.clone(),
|
||||
represents,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
let mut circuits = IndexMap::new();
|
||||
self.reducer.swap_in_circuit();
|
||||
for (name, circuit) in program.circuits.iter() {
|
||||
circuits.insert(name.clone(), self.reduce_circuit(circuit)?);
|
||||
}
|
||||
self.reducer.swap_in_circuit();
|
||||
|
||||
let mut functions = IndexMap::new();
|
||||
for (name, function) in program.functions.iter() {
|
||||
functions.insert(name.clone(), self.reduce_function(function)?);
|
||||
}
|
||||
|
||||
let mut global_consts = IndexMap::new();
|
||||
for (name, definition) in program.global_consts.iter() {
|
||||
global_consts.insert(name.clone(), self.reduce_definition(definition)?);
|
||||
}
|
||||
|
||||
self.reducer.reduce_program(
|
||||
program,
|
||||
inputs,
|
||||
import_statements,
|
||||
imports,
|
||||
aliases,
|
||||
circuits,
|
||||
functions,
|
||||
global_consts,
|
||||
)
|
||||
self.reducer.reduce_program(program, inputs, functions)
|
||||
}
|
||||
|
||||
pub fn reduce_function_input_variable(
|
||||
@ -490,91 +292,14 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
FunctionInput::Variable(function_input_variable) => {
|
||||
FunctionInput::Variable(self.reduce_function_input_variable(function_input_variable)?)
|
||||
}
|
||||
_ => input.clone(),
|
||||
};
|
||||
|
||||
self.reducer.reduce_function_input(input, new)
|
||||
}
|
||||
|
||||
pub fn reduce_import_tree(&mut self, tree: &ImportTree) -> Result<ImportTree> {
|
||||
let new = ImportTree {
|
||||
base: tree
|
||||
.base
|
||||
.iter()
|
||||
.map(|i| self.reduce_identifier(i))
|
||||
.collect::<Result<_>>()?,
|
||||
|
||||
kind: match &tree.kind {
|
||||
ImportTreeKind::Glob { .. } | ImportTreeKind::Leaf { alias: None } => tree.kind.clone(),
|
||||
ImportTreeKind::Leaf { alias: Some(alias) } => {
|
||||
let alias = self.reduce_identifier(alias)?;
|
||||
ImportTreeKind::Leaf { alias: Some(alias) }
|
||||
}
|
||||
ImportTreeKind::Nested { tree } => ImportTreeKind::Nested {
|
||||
tree: tree.iter().map(|n| self.reduce_import_tree(n)).collect::<Result<_>>()?,
|
||||
},
|
||||
},
|
||||
span: tree.span.clone(),
|
||||
};
|
||||
|
||||
self.reducer.reduce_import_tree(tree, new)
|
||||
}
|
||||
|
||||
pub fn reduce_import_statement(&mut self, import: &ImportStatement) -> Result<ImportStatement> {
|
||||
let tree = self.reduce_import_tree(&import.tree)?;
|
||||
self.reducer.reduce_import_statement(import, tree)
|
||||
}
|
||||
|
||||
pub fn reduce_import(&mut self, identifier: &[Symbol], import: &Program) -> Result<(Vec<Symbol>, Program)> {
|
||||
let new_identifer = identifier.to_vec();
|
||||
let new_import = self.reduce_program(import)?;
|
||||
self.reducer.reduce_import(new_identifer, new_import)
|
||||
}
|
||||
|
||||
pub fn reduce_circuit_member(&mut self, circuit_member: &CircuitMember) -> Result<CircuitMember> {
|
||||
let new = match circuit_member {
|
||||
CircuitMember::CircuitConst(identifier, type_, value) => CircuitMember::CircuitConst(
|
||||
self.reduce_identifier(identifier)?,
|
||||
self.reduce_type(type_, &identifier.span)?,
|
||||
self.reduce_expression(value)?,
|
||||
),
|
||||
CircuitMember::CircuitVariable(identifier, type_) => CircuitMember::CircuitVariable(
|
||||
self.reduce_identifier(identifier)?,
|
||||
self.reduce_type(type_, &identifier.span)?,
|
||||
),
|
||||
CircuitMember::CircuitFunction(function) => {
|
||||
CircuitMember::CircuitFunction(Box::new(self.reduce_function(function)?))
|
||||
}
|
||||
};
|
||||
|
||||
self.reducer.reduce_circuit_member(circuit_member, new)
|
||||
}
|
||||
|
||||
pub fn reduce_circuit(&mut self, circuit: &Circuit) -> Result<Circuit> {
|
||||
let circuit_name = self.reduce_identifier(&circuit.circuit_name)?;
|
||||
|
||||
let mut members = vec![];
|
||||
for member in circuit.members.iter() {
|
||||
members.push(self.reduce_circuit_member(member)?);
|
||||
}
|
||||
|
||||
self.reducer.reduce_circuit(circuit, circuit_name, members)
|
||||
}
|
||||
|
||||
fn reduce_annotation(&mut self, annotation: &Annotation) -> Result<Annotation> {
|
||||
let name = self.reduce_identifier(&annotation.name)?;
|
||||
|
||||
self.reducer.reduce_annotation(annotation, name)
|
||||
}
|
||||
|
||||
pub fn reduce_function(&mut self, function: &Function) -> Result<Function> {
|
||||
let identifier = self.reduce_identifier(&function.identifier)?;
|
||||
|
||||
let mut annotations = IndexMap::new();
|
||||
for (name, annotation) in function.annotations.iter() {
|
||||
annotations.insert(*name, self.reduce_annotation(annotation)?);
|
||||
}
|
||||
|
||||
let mut inputs = vec![];
|
||||
for input in function.input.iter() {
|
||||
inputs.push(self.reduce_function_input(input)?);
|
||||
@ -588,14 +313,7 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
|
||||
let block = self.reduce_block(&function.block)?;
|
||||
|
||||
self.reducer.reduce_function(
|
||||
function,
|
||||
identifier,
|
||||
annotations,
|
||||
inputs,
|
||||
function.const_,
|
||||
output,
|
||||
block,
|
||||
)
|
||||
self.reducer
|
||||
.reduce_function(function, identifier, inputs, function.const_, output, block)
|
||||
}
|
||||
}
|
||||
|
@ -113,136 +113,6 @@ pub trait ReconstructingReducer {
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_cast(&mut self, cast: &CastExpression, inner: Expression, target_type: Type) -> Result<CastExpression> {
|
||||
Ok(CastExpression {
|
||||
inner: Box::new(inner),
|
||||
target_type,
|
||||
span: cast.span.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_array_access(
|
||||
&mut self,
|
||||
array_access: &ArrayAccess,
|
||||
array: Expression,
|
||||
index: Expression,
|
||||
) -> Result<ArrayAccess> {
|
||||
Ok(ArrayAccess {
|
||||
array: Box::new(array),
|
||||
index: Box::new(index),
|
||||
span: array_access.span.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_array_range_access(
|
||||
&mut self,
|
||||
array_rage_access: &ArrayRangeAccess,
|
||||
array: Expression,
|
||||
left: Option<Expression>,
|
||||
right: Option<Expression>,
|
||||
) -> Result<ArrayRangeAccess> {
|
||||
Ok(ArrayRangeAccess {
|
||||
array: Box::new(array),
|
||||
left: left.map(|expr| Box::new(expr)),
|
||||
right: right.map(|expr| Box::new(expr)),
|
||||
span: array_rage_access.span.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_member_access(
|
||||
&mut self,
|
||||
member_access: &MemberAccess,
|
||||
inner: Expression,
|
||||
name: Identifier,
|
||||
type_: Option<Type>,
|
||||
) -> Result<MemberAccess> {
|
||||
Ok(MemberAccess {
|
||||
inner: Box::new(inner),
|
||||
name,
|
||||
span: member_access.span.clone(),
|
||||
type_,
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_tuple_access(&mut self, tuple_access: &TupleAccess, tuple: Expression) -> Result<TupleAccess> {
|
||||
Ok(TupleAccess {
|
||||
tuple: Box::new(tuple),
|
||||
index: tuple_access.index.clone(),
|
||||
span: tuple_access.span.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_static_access(
|
||||
&mut self,
|
||||
static_access: &StaticAccess,
|
||||
value: Expression,
|
||||
type_: Option<Type>,
|
||||
name: Identifier,
|
||||
) -> Result<StaticAccess> {
|
||||
Ok(StaticAccess {
|
||||
inner: Box::new(value),
|
||||
name,
|
||||
type_,
|
||||
span: static_access.span.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_array_inline(
|
||||
&mut self,
|
||||
array_inline: &ArrayInlineExpression,
|
||||
elements: Vec<SpreadOrExpression>,
|
||||
) -> Result<ArrayInlineExpression> {
|
||||
Ok(ArrayInlineExpression {
|
||||
elements,
|
||||
span: array_inline.span.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_array_init(
|
||||
&mut self,
|
||||
array_init: &ArrayInitExpression,
|
||||
element: Expression,
|
||||
) -> Result<ArrayInitExpression> {
|
||||
Ok(ArrayInitExpression {
|
||||
element: Box::new(element),
|
||||
dimensions: array_init.dimensions.clone(),
|
||||
span: array_init.span.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_tuple_init(
|
||||
&mut self,
|
||||
tuple_init: &TupleInitExpression,
|
||||
elements: Vec<Expression>,
|
||||
) -> Result<TupleInitExpression> {
|
||||
Ok(TupleInitExpression {
|
||||
elements,
|
||||
span: tuple_init.span.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_circuit_variable_initializer(
|
||||
&mut self,
|
||||
_variable: &CircuitVariableInitializer,
|
||||
identifier: Identifier,
|
||||
expression: Option<Expression>,
|
||||
) -> Result<CircuitVariableInitializer> {
|
||||
Ok(CircuitVariableInitializer { identifier, expression })
|
||||
}
|
||||
|
||||
fn reduce_circuit_init(
|
||||
&mut self,
|
||||
circuit_init: &CircuitInitExpression,
|
||||
name: Identifier,
|
||||
members: Vec<CircuitVariableInitializer>,
|
||||
) -> Result<CircuitInitExpression> {
|
||||
Ok(CircuitInitExpression {
|
||||
name,
|
||||
members,
|
||||
span: circuit_init.span.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_call(
|
||||
&mut self,
|
||||
call: &CallExpression,
|
||||
@ -387,22 +257,12 @@ pub trait ReconstructingReducer {
|
||||
&mut self,
|
||||
program: &Program,
|
||||
expected_input: Vec<FunctionInput>,
|
||||
import_statements: Vec<ImportStatement>,
|
||||
imports: IndexMap<Vec<Symbol>, Program>,
|
||||
aliases: IndexMap<Identifier, Alias>,
|
||||
circuits: IndexMap<Identifier, Circuit>,
|
||||
functions: IndexMap<Identifier, Function>,
|
||||
global_consts: IndexMap<Vec<Identifier>, DefinitionStatement>,
|
||||
) -> Result<Program> {
|
||||
Ok(Program {
|
||||
name: program.name.clone(),
|
||||
expected_input,
|
||||
import_statements,
|
||||
imports,
|
||||
aliases,
|
||||
circuits,
|
||||
functions,
|
||||
global_consts,
|
||||
})
|
||||
}
|
||||
|
||||
@ -425,48 +285,15 @@ pub trait ReconstructingReducer {
|
||||
Ok(new)
|
||||
}
|
||||
|
||||
fn reduce_import_tree(&mut self, _tree: &ImportTree, new: ImportTree) -> Result<ImportTree> {
|
||||
Ok(new)
|
||||
}
|
||||
|
||||
fn reduce_import_statement(&mut self, import: &ImportStatement, tree: ImportTree) -> Result<ImportStatement> {
|
||||
Ok(ImportStatement {
|
||||
tree,
|
||||
span: import.span.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn reduce_import(&mut self, identifier: Vec<Symbol>, import: Program) -> Result<(Vec<Symbol>, Program)> {
|
||||
Ok((identifier, import))
|
||||
}
|
||||
|
||||
fn reduce_circuit_member(&mut self, _circuit_member: &CircuitMember, new: CircuitMember) -> Result<CircuitMember> {
|
||||
Ok(new)
|
||||
}
|
||||
|
||||
fn reduce_circuit(
|
||||
&mut self,
|
||||
_circuit: &Circuit,
|
||||
circuit_name: Identifier,
|
||||
members: Vec<CircuitMember>,
|
||||
) -> Result<Circuit> {
|
||||
Ok(Circuit { circuit_name, members })
|
||||
}
|
||||
|
||||
fn reduce_annotation(&mut self, annotation: &Annotation, name: Identifier) -> Result<Annotation> {
|
||||
Ok(Annotation {
|
||||
span: annotation.span.clone(),
|
||||
name,
|
||||
arguments: annotation.arguments.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn reduce_function(
|
||||
&mut self,
|
||||
function: &Function,
|
||||
identifier: Identifier,
|
||||
annotations: IndexMap<Symbol, Annotation>,
|
||||
input: Vec<FunctionInput>,
|
||||
const_: bool,
|
||||
output: Option<Type>,
|
||||
@ -474,7 +301,6 @@ pub trait ReconstructingReducer {
|
||||
) -> Result<Function> {
|
||||
Ok(Function {
|
||||
identifier,
|
||||
annotations,
|
||||
input,
|
||||
const_,
|
||||
output,
|
||||
|
@ -14,7 +14,7 @@
|
||||
// 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::{ArrayDimensions, Identifier, IntegerType};
|
||||
use crate::{Identifier, IntegerType};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
@ -36,32 +36,15 @@ pub enum Type {
|
||||
/// An integer type.
|
||||
IntegerType(IntegerType),
|
||||
|
||||
// Data type wrappers
|
||||
/// An array type `[element; dimensions]`.
|
||||
Array(Box<Type>, ArrayDimensions),
|
||||
|
||||
/// A tuple type `(T_0, T_1, ...)` made up of a list of types.
|
||||
Tuple(Vec<Type>),
|
||||
|
||||
/// A reference to either a nominal type (e.g., a `circuit`) or a type alias.
|
||||
Identifier(Identifier),
|
||||
|
||||
/// The `Self` type, allowed within `circuit` definitions.
|
||||
SelfType,
|
||||
|
||||
/// Placeholder for a type that could not be resolved or was not well-formed.
|
||||
/// Will eventually lead to a compile error.
|
||||
Err,
|
||||
}
|
||||
|
||||
impl Type {
|
||||
///
|
||||
/// Returns `true` if the self `Type` is the `SelfType`.
|
||||
///
|
||||
pub fn is_self(&self) -> bool {
|
||||
matches!(self, Type::SelfType)
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns `true` if the self `Type` is a `Circuit`.
|
||||
///
|
||||
@ -83,32 +66,7 @@ impl Type {
|
||||
(Type::Group, Type::Group) => true,
|
||||
(Type::IntegerType(left), Type::IntegerType(right)) => left.eq(right),
|
||||
(Type::Identifier(left), Type::Identifier(right)) => left.eq(right),
|
||||
(Type::SelfType, Type::SelfType) => true,
|
||||
(Type::Array(left_type, left_dims), Type::Array(right_type, right_dims)) => {
|
||||
// Convert array dimensions to owned.
|
||||
let mut left_dims = left_dims.to_owned();
|
||||
let mut right_dims = right_dims.to_owned();
|
||||
|
||||
// Remove the first element from both dimensions.
|
||||
let left_first = left_dims.remove_first();
|
||||
let right_first = right_dims.remove_first();
|
||||
|
||||
// Compare the first dimensions.
|
||||
if left_first.ne(&right_first) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a new array type from the remaining array dimensions.
|
||||
let left_new_type = inner_array_type(*left_type.to_owned(), left_dims);
|
||||
let right_new_type = inner_array_type(*right_type.to_owned(), right_dims);
|
||||
|
||||
// Call eq_flat() on the new left and right types.
|
||||
left_new_type.eq_flat(&right_new_type)
|
||||
}
|
||||
(Type::Tuple(left), Type::Tuple(right)) => left
|
||||
.iter()
|
||||
.zip(right)
|
||||
.all(|(left_type, right_type)| left_type.eq_flat(right_type)),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -124,32 +82,7 @@ impl fmt::Display for Type {
|
||||
Type::Group => write!(f, "group"),
|
||||
Type::IntegerType(ref integer_type) => write!(f, "{}", integer_type),
|
||||
Type::Identifier(ref variable) => write!(f, "circuit {}", variable),
|
||||
Type::SelfType => write!(f, "SelfType"),
|
||||
Type::Array(ref array, ref dimensions) => write!(f, "[{}; {}]", *array, dimensions),
|
||||
Type::Tuple(ref tuple) => {
|
||||
let types = tuple.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(", ");
|
||||
|
||||
write!(f, "({})", types)
|
||||
}
|
||||
Type::Err => write!(f, "error"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the type of the inner array given an array element and array dimensions.
|
||||
///
|
||||
/// If the array has no dimensions, then an inner array does not exist. Simply return the given
|
||||
/// element type.
|
||||
///
|
||||
/// If the array has dimensions, then an inner array exists. Create a new type for the
|
||||
/// inner array. The element type of the new array should be the same as the old array. The
|
||||
/// dimensions of the new array should be the old array dimensions with the first dimension removed.
|
||||
pub fn inner_array_type(element_type: Type, dimensions: ArrayDimensions) -> Type {
|
||||
if dimensions.is_empty() {
|
||||
// The array has one dimension.
|
||||
element_type
|
||||
} else {
|
||||
// The array has multiple dimensions.
|
||||
Type::Array(Box::new(element_type), dimensions)
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
pub use leo_ast::Ast;
|
||||
use leo_ast::AstPass;
|
||||
use leo_errors::emitter::Handler;
|
||||
use leo_errors::{CompilerError, Result};
|
||||
use leo_span::symbol::create_session_if_not_set_then;
|
||||
@ -76,18 +75,18 @@ impl<'a> Compiler<'a> {
|
||||
.map_err(|e| CompilerError::file_read_error(self.main_file_path.clone(), e))?;
|
||||
|
||||
// Use the parser to construct the abstract syntax tree (ast).
|
||||
let mut ast: leo_ast::Ast = leo_parser::parse_ast(
|
||||
let ast: leo_ast::Ast = leo_parser::parse_ast(
|
||||
self.handler,
|
||||
self.main_file_path.to_str().unwrap_or_default(),
|
||||
program_string,
|
||||
)?;
|
||||
// Write the AST snapshot post parsing.
|
||||
ast.to_json_file_without_keys(self.output_directory.clone(), "initial_ast.json", &["span"])?;
|
||||
ast.to_json_file_without_keys(self.output_directory, "initial_ast.json", &["span"])?;
|
||||
|
||||
// Canonicalize the AST.
|
||||
ast = leo_ast_passes::Canonicalizer::do_pass(Default::default(), ast.into_repr())?;
|
||||
// ast = leo_ast_passes::Canonicalizer::do_pass(Default::default(), ast.into_repr())?;
|
||||
// Write the AST snapshot post parsing
|
||||
ast.to_json_file_without_keys(self.output_directory, "canonicalization_ast.json", &["span"])?;
|
||||
// ast.to_json_file_without_keys(self.output_directory, "canonicalization_ast.json", &["span"])?;
|
||||
|
||||
Ok(ast)
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ pub struct ParserContext<'a> {
|
||||
pub(crate) handler: &'a Handler,
|
||||
tokens: Vec<SpannedToken>,
|
||||
end_span: Span,
|
||||
// true if parsing an expression for an if statement -- means circuit inits are not legal
|
||||
pub(crate) fuzzy_struct_state: bool,
|
||||
// true if parsing an expression for if and loop statements -- means circuit inits are not legal
|
||||
pub(crate) disallow_circuit_construction: bool,
|
||||
}
|
||||
|
||||
impl Iterator for ParserContext<'_> {
|
||||
@ -61,7 +61,7 @@ impl<'a> ParserContext<'a> {
|
||||
.map(|x| x.span.clone())
|
||||
.unwrap_or_default(),
|
||||
tokens,
|
||||
fuzzy_struct_state: false,
|
||||
disallow_circuit_construction: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ impl<'a> ParserContext<'a> {
|
||||
};
|
||||
Ok(matches!(
|
||||
(first, next),
|
||||
(Token::Function | Token::At, _) | (Token::Const, Token::Function)
|
||||
(Token::Function, _) | (Token::Const, Token::Function)
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -41,16 +41,16 @@ impl ParserContext<'_> {
|
||||
///
|
||||
pub fn parse_expression(&mut self) -> Result<Expression> {
|
||||
// Store current parser state.
|
||||
let prior_fuzzy_state = self.fuzzy_struct_state;
|
||||
let prior_fuzzy_state = self.disallow_circuit_construction;
|
||||
|
||||
// Allow circuit init expressions.
|
||||
self.fuzzy_struct_state = false;
|
||||
self.disallow_circuit_construction = false;
|
||||
|
||||
// Parse expression.
|
||||
let result = self.parse_conditional_expression();
|
||||
|
||||
// Restore prior parser state.
|
||||
self.fuzzy_struct_state = prior_fuzzy_state;
|
||||
self.disallow_circuit_construction = prior_fuzzy_state;
|
||||
|
||||
result
|
||||
}
|
||||
@ -199,9 +199,9 @@ impl ParserContext<'_> {
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// binary exponentiation expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_cast_expression`].
|
||||
/// Otherwise, tries to parse the next token using [`parse_unary_expression`].
|
||||
pub fn parse_exponential_expression(&mut self) -> Result<Expression> {
|
||||
let mut expr = self.parse_cast_expression()?;
|
||||
let mut expr = self.parse_unary_expression()?;
|
||||
|
||||
if self.eat(Token::Exp).is_some() {
|
||||
let right = self.parse_exponential_expression()?;
|
||||
@ -211,25 +211,6 @@ impl ParserContext<'_> {
|
||||
Ok(expr)
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// type cast expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_unary_expression`].
|
||||
///
|
||||
pub fn parse_cast_expression(&mut self) -> Result<Expression> {
|
||||
let mut expr = self.parse_unary_expression()?;
|
||||
while self.eat(Token::As).is_some() {
|
||||
let (type_, type_span) = self.parse_type()?;
|
||||
expr = Expression::Cast(CastExpression {
|
||||
span: expr.span() + &type_span,
|
||||
inner: Box::new(expr),
|
||||
target_type: type_,
|
||||
})
|
||||
}
|
||||
Ok(expr)
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// unary not, negate, or bitwise not expression.
|
||||
@ -248,16 +229,6 @@ impl ParserContext<'_> {
|
||||
Token::Minus => UnaryOperation::Negate,
|
||||
_ => unreachable!("parse_unary_expression_ shouldn't produce this"),
|
||||
};
|
||||
// hack for const signed integer overflow issues
|
||||
if matches!(operation, UnaryOperation::Negate) {
|
||||
if let Expression::Value(ValueExpression::Integer(type_, value, span)) = inner {
|
||||
inner = Expression::Value(ValueExpression::Integer(type_, format!("-{}", value), &op.span + &span));
|
||||
continue;
|
||||
} else if let Expression::Value(ValueExpression::Implicit(value, span)) = inner {
|
||||
inner = Expression::Value(ValueExpression::Implicit(format!("-{}", value), &op.span + &span));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
inner = Expression::Unary(UnaryExpression {
|
||||
span: &op.span + inner.span(),
|
||||
op: operation,
|
||||
@ -278,68 +249,11 @@ impl ParserContext<'_> {
|
||||
// the ABNF states. Rather the primary expression already
|
||||
// handle those. The ABNF is more specific for language reasons.
|
||||
let mut expr = self.parse_primary_expression()?;
|
||||
while let Some(token) = self.eat_any(&[Token::LeftSquare, Token::Dot, Token::LeftParen, Token::DoubleColon]) {
|
||||
while let Some(token) = self.eat_any(&[Token::Dot, Token::LeftParen]) {
|
||||
match token.token {
|
||||
Token::LeftSquare => {
|
||||
if self.eat(Token::DotDot).is_some() {
|
||||
let right = if self.peek_token().as_ref() != &Token::RightSquare {
|
||||
Some(Box::new(self.parse_expression()?))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let end = self.expect(Token::RightSquare)?;
|
||||
expr = Expression::Access(AccessExpression::ArrayRange(ArrayRangeAccess {
|
||||
span: expr.span() + &end,
|
||||
array: Box::new(expr),
|
||||
left: None,
|
||||
right,
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
let left = self.parse_expression()?;
|
||||
if self.eat(Token::DotDot).is_some() {
|
||||
let right = if self.peek_token().as_ref() != &Token::RightSquare {
|
||||
Some(Box::new(self.parse_expression()?))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let end = self.expect(Token::RightSquare)?;
|
||||
expr = Expression::Access(AccessExpression::ArrayRange(ArrayRangeAccess {
|
||||
span: expr.span() + &end,
|
||||
array: Box::new(expr),
|
||||
left: Some(Box::new(left)),
|
||||
right,
|
||||
}));
|
||||
} else {
|
||||
let end = self.expect(Token::RightSquare)?;
|
||||
expr = Expression::Access(AccessExpression::Array(ArrayAccess {
|
||||
span: expr.span() + &end,
|
||||
array: Box::new(expr),
|
||||
index: Box::new(left),
|
||||
}));
|
||||
}
|
||||
}
|
||||
Token::Dot => {
|
||||
if let Some(ident) = self.eat_identifier() {
|
||||
expr = Expression::Access(AccessExpression::Member(MemberAccess {
|
||||
span: expr.span() + &ident.span,
|
||||
inner: Box::new(expr),
|
||||
name: ident,
|
||||
type_: None,
|
||||
}));
|
||||
} else if let Some((num, span)) = self.eat_int() {
|
||||
expr = Expression::Access(AccessExpression::Tuple(TupleAccess {
|
||||
span: expr.span() + &span,
|
||||
tuple: Box::new(expr),
|
||||
index: num,
|
||||
}));
|
||||
} else {
|
||||
let next = self.peek()?;
|
||||
return Err(ParserError::unexpected_str(&next.token, "int or ident", &next.span).into());
|
||||
}
|
||||
let next = self.peek()?;
|
||||
return Err(ParserError::unexpected_str(&next.token, "int or ident", &next.span).into());
|
||||
}
|
||||
Token::LeftParen => {
|
||||
let mut arguments = Vec::new();
|
||||
@ -361,51 +275,12 @@ impl ParserContext<'_> {
|
||||
arguments,
|
||||
});
|
||||
}
|
||||
Token::DoubleColon => {
|
||||
let ident = self.expect_ident()?;
|
||||
expr = Expression::Access(AccessExpression::Static(StaticAccess {
|
||||
span: expr.span() + &ident.span,
|
||||
inner: Box::new(expr),
|
||||
type_: None,
|
||||
name: ident,
|
||||
}));
|
||||
}
|
||||
_ => unreachable!("parse_postfix_expression_ shouldn't produce this"),
|
||||
}
|
||||
}
|
||||
Ok(expr)
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a [`SpreadOrExpression`] AST node if the next tokens represent a
|
||||
/// spread or expression.
|
||||
///
|
||||
/// This method should only be called in the context of an array construction expression.
|
||||
///
|
||||
pub fn parse_spread_or_expression(&mut self) -> Result<SpreadOrExpression> {
|
||||
Ok(if self.eat(Token::DotDotDot).is_some() {
|
||||
SpreadOrExpression::Spread(self.parse_expression()?)
|
||||
} else {
|
||||
SpreadOrExpression::Expression(self.parse_expression()?)
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// circuit initialization expression.
|
||||
pub fn parse_circuit_expression(&mut self, identifier: Identifier) -> Result<Expression> {
|
||||
let (members, _, span) = self.parse_list(Token::LeftCurly, Token::RightCurly, Token::Comma, |p| {
|
||||
Ok(Some(CircuitVariableInitializer {
|
||||
identifier: p.expect_ident()?,
|
||||
expression: p.eat(Token::Colon).map(|_| p.parse_expression()).transpose()?,
|
||||
}))
|
||||
})?;
|
||||
Ok(Expression::CircuitInit(CircuitInitExpression {
|
||||
span: &identifier.span + &span,
|
||||
name: identifier,
|
||||
members,
|
||||
}))
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// tuple initialization expression or an affine group literal.
|
||||
@ -438,67 +313,7 @@ impl ParserContext<'_> {
|
||||
if args.len() == 1 {
|
||||
Ok(args.remove(0))
|
||||
} else {
|
||||
Ok(Expression::TupleInit(TupleInitExpression {
|
||||
span: span + &end_span,
|
||||
elements: args,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent an
|
||||
/// array initialization expression.
|
||||
///
|
||||
pub fn parse_array_expression(&mut self, span: &Span) -> Result<Expression> {
|
||||
if let Some(end) = self.eat(Token::RightSquare) {
|
||||
return Ok(Expression::ArrayInline(ArrayInlineExpression {
|
||||
elements: Vec::new(),
|
||||
span: span + &end.span,
|
||||
}));
|
||||
}
|
||||
let first = self.parse_spread_or_expression()?;
|
||||
if self.eat(Token::Semicolon).is_some() {
|
||||
let dimensions = self
|
||||
.parse_array_dimensions()
|
||||
.map_err(|_| ParserError::unable_to_parse_array_dimensions(span))?;
|
||||
let end = self.expect(Token::RightSquare)?;
|
||||
let first = match first {
|
||||
SpreadOrExpression::Spread(first) => {
|
||||
let span = span + first.span();
|
||||
return Err(ParserError::spread_in_array_init(&span).into());
|
||||
}
|
||||
SpreadOrExpression::Expression(x) => x,
|
||||
};
|
||||
Ok(Expression::ArrayInit(ArrayInitExpression {
|
||||
span: span + &end,
|
||||
element: Box::new(first),
|
||||
dimensions,
|
||||
}))
|
||||
} else {
|
||||
let end_span;
|
||||
let mut elements = vec![first];
|
||||
loop {
|
||||
if let Some(token) = self.eat(Token::RightSquare) {
|
||||
end_span = token.span;
|
||||
break;
|
||||
}
|
||||
if elements.len() == 1 {
|
||||
self.expect(Token::Comma)?;
|
||||
if let Some(token) = self.eat(Token::RightSquare) {
|
||||
end_span = token.span;
|
||||
break;
|
||||
}
|
||||
}
|
||||
elements.push(self.parse_spread_or_expression()?);
|
||||
if self.eat(Token::Comma).is_none() {
|
||||
end_span = self.expect(Token::RightSquare)?;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Ok(Expression::ArrayInline(ArrayInlineExpression {
|
||||
elements,
|
||||
span: span + &end_span,
|
||||
}))
|
||||
Err(ParserError::unexpected("A tuple expression.", "A valid expression.", &(span + &end_span)).into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -554,30 +369,10 @@ impl ParserContext<'_> {
|
||||
})),
|
||||
Token::StringLit(value) => Expression::Value(ValueExpression::String(value, span)),
|
||||
Token::LeftParen => self.parse_tuple_expression(&span)?,
|
||||
Token::LeftSquare => self.parse_array_expression(&span)?,
|
||||
Token::Ident(name) => {
|
||||
let ident = Identifier { name, span };
|
||||
if !self.fuzzy_struct_state && self.peek_token().as_ref() == &Token::LeftCurly {
|
||||
self.parse_circuit_expression(ident)?
|
||||
} else {
|
||||
Expression::Identifier(ident)
|
||||
}
|
||||
Expression::Identifier(ident)
|
||||
}
|
||||
Token::BigSelf => {
|
||||
let ident = Identifier {
|
||||
name: sym::SelfUpper,
|
||||
span,
|
||||
};
|
||||
if !self.fuzzy_struct_state && self.peek_token().as_ref() == &Token::LeftCurly {
|
||||
self.parse_circuit_expression(ident)?
|
||||
} else {
|
||||
Expression::Identifier(ident)
|
||||
}
|
||||
}
|
||||
Token::LittleSelf => Expression::Identifier(Identifier {
|
||||
name: sym::SelfLower,
|
||||
span,
|
||||
}),
|
||||
Token::Input => Expression::Identifier(Identifier { name: sym::input, span }),
|
||||
t if crate::type_::TYPE_TOKENS.contains(&t) => Expression::Identifier(Identifier {
|
||||
name: t.keyword_to_symbol().unwrap(),
|
||||
|
@ -15,7 +15,6 @@
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use super::*;
|
||||
use crate::KEYWORD_TOKENS;
|
||||
|
||||
use leo_errors::{ParserError, Result};
|
||||
use leo_span::sym;
|
||||
@ -25,372 +24,50 @@ impl ParserContext<'_> {
|
||||
/// Returns a [`Program`] AST if all tokens can be consumed and represent a valid Leo program.
|
||||
///
|
||||
pub fn parse_program(&mut self) -> Result<Program> {
|
||||
let mut import_statements = Vec::new();
|
||||
let mut aliases = IndexMap::new();
|
||||
let mut circuits = IndexMap::new();
|
||||
let mut functions = IndexMap::new();
|
||||
let mut global_consts = IndexMap::new();
|
||||
// let mut tests = IndexMap::new();
|
||||
|
||||
while self.has_next() {
|
||||
let token = self.peek()?;
|
||||
match &token.token {
|
||||
Token::Import => {
|
||||
import_statements.push(self.parse_import_statement()?);
|
||||
}
|
||||
Token::Circuit => {
|
||||
self.expect(Token::Circuit)?;
|
||||
let (id, circuit) = self.parse_circuit()?;
|
||||
circuits.insert(id, circuit);
|
||||
}
|
||||
Token::Ident(ident) => match *ident {
|
||||
sym::test => return Err(ParserError::test_function(&token.span).into()),
|
||||
kw @ (sym::Struct | sym::Class) => {
|
||||
self.emit_err(ParserError::unexpected(kw, "circuit", &token.span));
|
||||
self.bump().unwrap();
|
||||
let (id, circuit) = self.parse_circuit()?;
|
||||
circuits.insert(id, circuit);
|
||||
}
|
||||
_ => return Err(Self::unexpected_item(token).into()),
|
||||
},
|
||||
Token::Ident(sym::test) => return Err(ParserError::test_function(&token.span).into()),
|
||||
// Const functions share the first token with the global Const.
|
||||
Token::Const if self.peek_is_function()? => {
|
||||
let (id, function) = self.parse_function_declaration()?;
|
||||
functions.insert(id, function);
|
||||
}
|
||||
Token::Const => {
|
||||
let (name, global_const) = self.parse_global_const_declaration()?;
|
||||
global_consts.insert(name, global_const);
|
||||
}
|
||||
Token::Function | Token::At => {
|
||||
Token::Function => {
|
||||
let (id, function) = self.parse_function_declaration()?;
|
||||
functions.insert(id, function);
|
||||
}
|
||||
Token::Type => {
|
||||
let (name, alias) = self.parse_type_alias()?;
|
||||
aliases.insert(name, alias);
|
||||
}
|
||||
_ => return Err(Self::unexpected_item(token).into()),
|
||||
}
|
||||
}
|
||||
Ok(Program {
|
||||
name: String::new(),
|
||||
expected_input: Vec::new(),
|
||||
import_statements,
|
||||
imports: IndexMap::new(),
|
||||
aliases,
|
||||
circuits,
|
||||
functions,
|
||||
global_consts,
|
||||
})
|
||||
}
|
||||
|
||||
fn unexpected_item(token: &SpannedToken) -> ParserError {
|
||||
ParserError::unexpected(
|
||||
&token.token,
|
||||
[
|
||||
Token::Import,
|
||||
Token::Circuit,
|
||||
Token::Function,
|
||||
Token::Ident(sym::test),
|
||||
Token::At,
|
||||
]
|
||||
.iter()
|
||||
.map(|x| format!("'{}'", x))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", "),
|
||||
[Token::Function, Token::Ident(sym::test)]
|
||||
.iter()
|
||||
.map(|x| format!("'{}'", x))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", "),
|
||||
&token.span,
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns an [`Annotation`] AST node if the next tokens represent a supported annotation.
|
||||
pub fn parse_annotation(&mut self) -> Result<Annotation> {
|
||||
let start = self.expect(Token::At)?;
|
||||
let name = self.parse_annotation_name()?;
|
||||
|
||||
assert_no_whitespace(&start, &name.span, &name.name.as_str(), "@")?;
|
||||
|
||||
let (end_span, arguments) = if self.peek_is_left_par() {
|
||||
let (args, _, span) = self.parse_paren_comma_list(|p| {
|
||||
Ok(if let Some(ident) = p.eat_identifier() {
|
||||
Some(ident.name)
|
||||
} else {
|
||||
let token = p.expect_any()?;
|
||||
p.emit_err(ParserError::unexpected_str(&token.token, "ident", &token.span));
|
||||
None
|
||||
})
|
||||
})?;
|
||||
(span, args)
|
||||
} else {
|
||||
(name.span.clone(), Vec::new())
|
||||
};
|
||||
Ok(Annotation {
|
||||
name,
|
||||
arguments,
|
||||
span: start + end_span,
|
||||
})
|
||||
}
|
||||
|
||||
/// Parses `foo` in an annotation `@foo . That is, the name of the annotation.
|
||||
fn parse_annotation_name(&mut self) -> Result<Identifier> {
|
||||
let mut name = self.expect_ident()?;
|
||||
|
||||
// Recover `context` instead of `test`.
|
||||
if name.name == sym::context {
|
||||
self.emit_err(ParserError::context_annotation(&name.span));
|
||||
name.name = sym::test;
|
||||
}
|
||||
|
||||
Ok(name)
|
||||
}
|
||||
|
||||
/// Returns an [`Identifier`] AST node if the next tokens represent a valid package name.
|
||||
pub fn parse_package_name(&mut self) -> Result<Identifier> {
|
||||
// Build the package name, starting with valid characters up to a dash `-` (Token::Minus).
|
||||
let base = self.expect_loose_identifier()?;
|
||||
|
||||
// Return an error if the package name contains a keyword.
|
||||
if let Some(token) = KEYWORD_TOKENS.iter().find(|x| x.keyword_to_symbol() == Some(base.name)) {
|
||||
self.emit_err(ParserError::unexpected_str(token, "package name", &base.span));
|
||||
}
|
||||
|
||||
// Return the package name.
|
||||
Ok(base)
|
||||
}
|
||||
|
||||
/// Returns an [`ImportTree`] AST node if the next tokens represent a valid package import
|
||||
/// with accesses.
|
||||
// Public solely for writing import parsing tests.
|
||||
pub fn parse_import_tree(&mut self) -> Result<ImportTree> {
|
||||
// Parse the first part of the path.
|
||||
let first_name = self.parse_package_name()?;
|
||||
let start = first_name.span.clone();
|
||||
let mut base = vec![first_name];
|
||||
|
||||
let make = |base, end, kind| {
|
||||
let span = start + end;
|
||||
ImportTree { base, span, kind }
|
||||
};
|
||||
|
||||
// Paths are separated by `.`s.
|
||||
while self.eat(Token::Dot).is_some() {
|
||||
if self.peek_is_left_par() {
|
||||
// Encountered `.(`, so we have a nested import. Recurse!
|
||||
let (tree, _, end) = self.parse_paren_comma_list(|p| p.parse_import_tree().map(Some))?;
|
||||
|
||||
if tree.is_empty() {
|
||||
self.emit_err(ParserError::invalid_import_list(&end));
|
||||
}
|
||||
|
||||
return Ok(make(base, end, ImportTreeKind::Nested { tree }));
|
||||
} else if let Some(SpannedToken { span, .. }) = self.eat(Token::Mul) {
|
||||
// Encountered `.*`, so we have a glob import.
|
||||
return Ok(make(base, span.clone(), ImportTreeKind::Glob { span }));
|
||||
}
|
||||
|
||||
// Parse another path segment.
|
||||
base.push(self.parse_package_name()?);
|
||||
}
|
||||
|
||||
let (end, alias) = if self.eat(Token::As).is_some() {
|
||||
// Encountered `as`, so interpret as `path as rename`.
|
||||
let alias = self.expect_ident()?;
|
||||
(alias.span.clone(), Some(alias))
|
||||
} else {
|
||||
(base.last().unwrap().span.clone(), None)
|
||||
};
|
||||
Ok(make(base, end, ImportTreeKind::Leaf { alias }))
|
||||
}
|
||||
|
||||
/// Returns a [`ImportStatement`] AST node if the next tokens represent an import statement.
|
||||
pub fn parse_import_statement(&mut self) -> Result<ImportStatement> {
|
||||
self.expect(Token::Import)?;
|
||||
let tree = self.parse_import_tree()?;
|
||||
self.expect(Token::Semicolon)?;
|
||||
Ok(ImportStatement {
|
||||
span: tree.span.clone(),
|
||||
tree,
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns a [`CircuitMember`] AST node if the next tokens represent a circuit member variable
|
||||
/// or circuit member function or circuit member constant.
|
||||
pub fn parse_circuit_declaration(&mut self) -> Result<Vec<CircuitMember>> {
|
||||
let mut members = Vec::new();
|
||||
|
||||
let (mut semi_colons, mut commas) = (false, false);
|
||||
|
||||
while self.eat(Token::RightCurly).is_none() {
|
||||
members.push(if self.peek_is_function()? {
|
||||
// function
|
||||
self.parse_member_function_declaration()?
|
||||
} else if *self.peek_token() == Token::Static {
|
||||
// static const
|
||||
self.parse_const_member_variable_declaration()?
|
||||
} else {
|
||||
// variable
|
||||
let variable = self.parse_member_variable_declaration()?;
|
||||
|
||||
if let Some(semi) = self.eat(Token::Semicolon) {
|
||||
if commas {
|
||||
self.emit_err(ParserError::mixed_commas_and_semicolons(&semi.span));
|
||||
}
|
||||
semi_colons = true;
|
||||
}
|
||||
|
||||
if let Some(comma) = self.eat(Token::Comma) {
|
||||
if semi_colons {
|
||||
self.emit_err(ParserError::mixed_commas_and_semicolons(&comma.span));
|
||||
}
|
||||
commas = true;
|
||||
}
|
||||
|
||||
variable
|
||||
});
|
||||
}
|
||||
|
||||
self.ban_mixed_member_order(&members);
|
||||
|
||||
Ok(members)
|
||||
}
|
||||
|
||||
/// Emits errors if order isn't `consts variables functions`.
|
||||
fn ban_mixed_member_order(&self, members: &[CircuitMember]) {
|
||||
let mut had_var = false;
|
||||
let mut had_fun = false;
|
||||
for member in members {
|
||||
match member {
|
||||
CircuitMember::CircuitConst(id, _, e) if had_var => {
|
||||
self.emit_err(ParserError::member_const_after_var(&(id.span() + e.span())));
|
||||
}
|
||||
CircuitMember::CircuitConst(id, _, e) if had_fun => {
|
||||
self.emit_err(ParserError::member_const_after_fun(&(id.span() + e.span())));
|
||||
}
|
||||
CircuitMember::CircuitVariable(id, _) if had_fun => {
|
||||
self.emit_err(ParserError::member_var_after_fun(id.span()));
|
||||
}
|
||||
CircuitMember::CircuitConst(..) => {}
|
||||
CircuitMember::CircuitVariable(..) => had_var = true,
|
||||
CircuitMember::CircuitFunction(..) => had_fun = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Parses `IDENT: TYPE`.
|
||||
fn parse_typed_field_name(&mut self) -> Result<(Identifier, Type)> {
|
||||
let name = self.expect_ident()?;
|
||||
self.expect(Token::Colon)?;
|
||||
let type_ = self.parse_type()?.0;
|
||||
|
||||
Ok((name, type_))
|
||||
}
|
||||
|
||||
/// Returns a [`CircuitMember`] AST node if the next tokens represent a circuit member static constant.
|
||||
pub fn parse_const_member_variable_declaration(&mut self) -> Result<CircuitMember> {
|
||||
self.expect(Token::Static)?;
|
||||
self.expect(Token::Const)?;
|
||||
|
||||
// `IDENT: TYPE = EXPR`:
|
||||
let (name, type_) = self.parse_typed_field_name()?;
|
||||
self.expect(Token::Assign)?;
|
||||
let literal = self.parse_primary_expression()?;
|
||||
|
||||
self.expect(Token::Semicolon)?;
|
||||
|
||||
Ok(CircuitMember::CircuitConst(name, type_, literal))
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a [`CircuitMember`] AST node if the next tokens represent a circuit member variable.
|
||||
///
|
||||
pub fn parse_member_variable_declaration(&mut self) -> Result<CircuitMember> {
|
||||
let (name, type_) = self.parse_typed_field_name()?;
|
||||
|
||||
Ok(CircuitMember::CircuitVariable(name, type_))
|
||||
}
|
||||
|
||||
/// Returns a [`CircuitMember`] AST node if the next tokens represent a circuit member function.
|
||||
pub fn parse_member_function_declaration(&mut self) -> Result<CircuitMember> {
|
||||
let peeked = self.peek()?.clone();
|
||||
if self.peek_is_function()? {
|
||||
let function = self.parse_function_declaration()?;
|
||||
Ok(CircuitMember::CircuitFunction(Box::new(function.1)))
|
||||
} else {
|
||||
return Err(ParserError::unexpected(
|
||||
&peeked.token,
|
||||
[Token::Function, Token::At, Token::Const]
|
||||
.iter()
|
||||
.map(|x| format!("'{}'", x))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", "),
|
||||
&peeked.span,
|
||||
)
|
||||
.into());
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns an [`(Identifier, Circuit)`] tuple of AST nodes if the next tokens represent a
|
||||
/// circuit name and definition statement.
|
||||
///
|
||||
pub fn parse_circuit(&mut self) -> Result<(Identifier, Circuit)> {
|
||||
let name = if let Some(ident) = self.eat_identifier() {
|
||||
ident
|
||||
} else if let Some(scalar_type) = self.eat_any(crate::type_::TYPE_TOKENS) {
|
||||
Identifier {
|
||||
name: scalar_type.token.keyword_to_symbol().unwrap(),
|
||||
span: scalar_type.span,
|
||||
}
|
||||
} else {
|
||||
let next = self.peek()?;
|
||||
return Err(ParserError::unexpected_str(&next.token, "ident", &next.span).into());
|
||||
};
|
||||
|
||||
self.expect(Token::LeftCurly)?;
|
||||
let members = self.parse_circuit_declaration()?;
|
||||
|
||||
Ok((
|
||||
name.clone(),
|
||||
Circuit {
|
||||
circuit_name: name,
|
||||
members,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a [`FunctionInput`] AST node if the next tokens represent a function parameter.
|
||||
///
|
||||
pub fn parse_function_parameters(&mut self, first: bool) -> Result<FunctionInput> {
|
||||
pub fn parse_function_parameters(&mut self) -> Result<FunctionInput> {
|
||||
let const_ = self.eat(Token::Const);
|
||||
let mutable = self.eat(Token::Mut);
|
||||
let reference = self.eat(Token::Ampersand);
|
||||
let mut name = if let Some(token) = self.eat(Token::LittleSelf) {
|
||||
Identifier {
|
||||
name: sym::SelfLower,
|
||||
span: token.span,
|
||||
}
|
||||
} else {
|
||||
self.expect_ident()?
|
||||
};
|
||||
if name.name == sym::SelfLower {
|
||||
if !first {
|
||||
return Err(ParserError::parser_self_outside_first_argument().into());
|
||||
} else if let Some(mutable) = &mutable {
|
||||
self.emit_err(ParserError::mut_self_parameter(&(&mutable.span + &name.span)));
|
||||
return Ok(Self::build_ref_self(name, mutable));
|
||||
} else if let Some(reference) = &reference {
|
||||
// Handle `&self`.
|
||||
return Ok(Self::build_ref_self(name, reference));
|
||||
} else if let Some(const_) = &const_ {
|
||||
// Handle `const self`.
|
||||
name.span = &const_.span + &name.span;
|
||||
name.name = Symbol::intern("const self");
|
||||
return Ok(FunctionInput::ConstSelfKeyword(ConstSelfKeyword { identifier: name }));
|
||||
}
|
||||
// Handle `self`.
|
||||
return Ok(FunctionInput::SelfKeyword(SelfKeyword { identifier: name }));
|
||||
}
|
||||
let name = self.expect_ident()?;
|
||||
|
||||
if let Some(mutable) = &mutable {
|
||||
self.emit_err(ParserError::mut_function_input(&(&mutable.span + &name.span)));
|
||||
@ -407,24 +84,9 @@ impl ParserContext<'_> {
|
||||
}))
|
||||
}
|
||||
|
||||
/// Builds a function parameter `&self`.
|
||||
fn build_ref_self(mut name: Identifier, reference: &SpannedToken) -> FunctionInput {
|
||||
name.span = &reference.span + &name.span;
|
||||
// FIXME(Centril): This should be *two* tokens, NOT one!
|
||||
name.name = Symbol::intern("&self");
|
||||
FunctionInput::RefSelfKeyword(RefSelfKeyword { identifier: name })
|
||||
}
|
||||
|
||||
/// Returns an [`(Identifier, Function)`] AST node if the next tokens represent a function name
|
||||
/// and function definition.
|
||||
pub fn parse_function_declaration(&mut self) -> Result<(Identifier, Function)> {
|
||||
// Parse any annotations.
|
||||
let mut annotations = IndexMap::new();
|
||||
while self.peek_token().as_ref() == &Token::At {
|
||||
let annotation = self.parse_annotation()?;
|
||||
annotations.insert(annotation.name.name, annotation);
|
||||
}
|
||||
|
||||
// Parse optional const modifier.
|
||||
let const_ = self.eat(Token::Const).is_some();
|
||||
|
||||
@ -433,12 +95,7 @@ impl ParserContext<'_> {
|
||||
let name = self.expect_ident()?;
|
||||
|
||||
// Parse parameters.
|
||||
let mut first = true;
|
||||
let (inputs, ..) = self.parse_paren_comma_list(|p| {
|
||||
let param = p.parse_function_parameters(first).map(Some);
|
||||
first = false;
|
||||
param
|
||||
})?;
|
||||
let (inputs, ..) = self.parse_paren_comma_list(|p| p.parse_function_parameters().map(Some))?;
|
||||
|
||||
// Parse return type.
|
||||
let output = if self.eat(Token::Arrow).is_some() {
|
||||
@ -453,7 +110,6 @@ impl ParserContext<'_> {
|
||||
Ok((
|
||||
name.clone(),
|
||||
Function {
|
||||
annotations,
|
||||
identifier: name,
|
||||
input: inputs,
|
||||
const_,
|
||||
@ -479,17 +135,4 @@ impl ParserContext<'_> {
|
||||
|
||||
Ok((variable_names, statement))
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a [`(String, Alias)`] AST node if the next tokens represent a type alias declaration.
|
||||
///
|
||||
pub fn parse_type_alias(&mut self) -> Result<(Identifier, Alias)> {
|
||||
let start = self.expect(Token::Type)?;
|
||||
let name = self.expect_ident()?;
|
||||
self.expect(Token::Assign)?;
|
||||
let (represents, _) = self.parse_type()?;
|
||||
let span = start + self.expect(Token::Semicolon)?;
|
||||
|
||||
Ok((name.clone(), Alias { represents, span, name }))
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use crate::{tokenizer::*, Token};
|
||||
use leo_ast::*;
|
||||
use leo_errors::emitter::Handler;
|
||||
use leo_errors::{ParserError, Result};
|
||||
use leo_span::{Span, Symbol};
|
||||
use leo_span::Span;
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use std::unreachable;
|
||||
|
@ -33,36 +33,11 @@ impl ParserContext<'_> {
|
||||
/// Returns an [`Identifier`] AST node if the given [`Expression`] AST node evaluates to an
|
||||
/// identifier access. The access is stored in the given accesses.
|
||||
///
|
||||
pub fn construct_assignee_access(expr: Expression, accesses: &mut Vec<AssigneeAccess>) -> Result<Identifier> {
|
||||
let identifier;
|
||||
pub fn construct_assignee_access(expr: Expression, _accesses: &mut Vec<AssigneeAccess>) -> Result<Identifier> {
|
||||
match expr {
|
||||
Expression::Access(access) => match access {
|
||||
AccessExpression::Member(expr) => {
|
||||
identifier = Self::construct_assignee_access(*expr.inner, accesses)?;
|
||||
accesses.push(AssigneeAccess::Member(expr.name));
|
||||
}
|
||||
AccessExpression::Tuple(expr) => {
|
||||
identifier = Self::construct_assignee_access(*expr.tuple, accesses)?;
|
||||
accesses.push(AssigneeAccess::Tuple(expr.index, expr.span));
|
||||
}
|
||||
AccessExpression::ArrayRange(expr) => {
|
||||
identifier = Self::construct_assignee_access(*expr.array, accesses)?;
|
||||
accesses.push(AssigneeAccess::ArrayRange(
|
||||
expr.left.map(|x| *x),
|
||||
expr.right.map(|x| *x),
|
||||
));
|
||||
}
|
||||
AccessExpression::Array(expr) => {
|
||||
identifier = Self::construct_assignee_access(*expr.array, accesses)?;
|
||||
accesses.push(AssigneeAccess::ArrayIndex(*expr.index));
|
||||
}
|
||||
_ => return Err(ParserError::invalid_assignment_target(access.span()).into()),
|
||||
},
|
||||
|
||||
Expression::Identifier(id) => identifier = id,
|
||||
Expression::Identifier(id) => Ok(id),
|
||||
_ => return Err(ParserError::invalid_assignment_target(expr.span()).into()),
|
||||
}
|
||||
Ok(identifier)
|
||||
}
|
||||
|
||||
///
|
||||
@ -167,9 +142,9 @@ impl ParserContext<'_> {
|
||||
/// Returns a [`ConditionalStatement`] AST node if the next tokens represent a conditional statement.
|
||||
pub fn parse_conditional_statement(&mut self) -> Result<ConditionalStatement> {
|
||||
let start = self.expect(Token::If)?;
|
||||
self.fuzzy_struct_state = true;
|
||||
self.disallow_circuit_construction = true;
|
||||
let expr = self.parse_conditional_expression()?;
|
||||
self.fuzzy_struct_state = false;
|
||||
self.disallow_circuit_construction = false;
|
||||
let body = self.parse_block()?;
|
||||
let next = if self.eat(Token::Else).is_some() {
|
||||
let s = self.parse_statement()?;
|
||||
@ -199,9 +174,9 @@ impl ParserContext<'_> {
|
||||
let start = self.parse_expression()?;
|
||||
self.expect(Token::DotDot)?;
|
||||
let inclusive = self.eat(Token::Assign).is_some();
|
||||
self.fuzzy_struct_state = true;
|
||||
self.disallow_circuit_construction = true;
|
||||
let stop = self.parse_conditional_expression()?;
|
||||
self.fuzzy_struct_state = false;
|
||||
self.disallow_circuit_construction = false;
|
||||
|
||||
let block = self.parse_block()?;
|
||||
|
||||
|
@ -15,9 +15,7 @@
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use super::*;
|
||||
use leo_errors::{ParserError, Result};
|
||||
|
||||
use smallvec::smallvec;
|
||||
use leo_errors::Result;
|
||||
|
||||
pub(crate) const TYPE_TOKENS: &[Token] = &[
|
||||
Token::I8,
|
||||
@ -57,48 +55,12 @@ impl ParserContext<'_> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns an [`ArrayDimensions`] AST node if the next tokens represent dimensions for an array type.
|
||||
pub fn parse_array_dimensions(&mut self) -> Result<ArrayDimensions> {
|
||||
Ok(if let Some((dim, _)) = self.eat_int() {
|
||||
ArrayDimensions(smallvec![dim])
|
||||
} else {
|
||||
let mut had_item_err = false;
|
||||
let (dims, _, span) = self.parse_paren_comma_list(|p| {
|
||||
Ok(if let Some((dim, _)) = p.eat_int() {
|
||||
Some(dim)
|
||||
} else {
|
||||
let token = p.expect_any()?;
|
||||
p.emit_err(ParserError::unexpected_str(&token.token, "int", &token.span));
|
||||
had_item_err = true;
|
||||
None
|
||||
})
|
||||
})?;
|
||||
if dims.is_empty() && !had_item_err {
|
||||
self.emit_err(ParserError::array_tuple_dimensions_empty(&span));
|
||||
} else if dims.len() == 1 {
|
||||
self.emit_err(ParserError::invalid_parens_around_single_array_dimension_size(&span));
|
||||
}
|
||||
ArrayDimensions(dims.into())
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns a [`(Type, Span)`] tuple of AST nodes if the next token represents a type.
|
||||
/// Also returns the span of the parsed token.
|
||||
pub fn parse_type(&mut self) -> Result<(Type, Span)> {
|
||||
Ok(if let Some(token) = self.eat(Token::BigSelf) {
|
||||
(Type::SelfType, token.span)
|
||||
} else if let Some(ident) = self.eat_identifier() {
|
||||
Ok(if let Some(ident) = self.eat_identifier() {
|
||||
let span = ident.span.clone();
|
||||
(Type::Identifier(ident), span)
|
||||
} else if self.peek_is_left_par() {
|
||||
let (types, _, span) = self.parse_paren_comma_list(|p| p.parse_type().map(|t| Some(t.0)))?;
|
||||
(Type::Tuple(types), span)
|
||||
} else if let Some(token) = self.eat(Token::LeftSquare) {
|
||||
let (inner, _) = self.parse_type()?;
|
||||
self.expect(Token::Semicolon)?;
|
||||
let dimensions = self.parse_array_dimensions()?;
|
||||
let end_span = self.expect(Token::RightSquare)?;
|
||||
(Type::Array(Box::new(inner), dimensions), token.span + end_span)
|
||||
} else {
|
||||
let token = self.expect_oneof(TYPE_TOKENS)?;
|
||||
(
|
||||
|
@ -111,27 +111,6 @@ impl Namespace for ParseExpressionNamespace {
|
||||
}
|
||||
}
|
||||
|
||||
struct ParseImportNamespace;
|
||||
|
||||
impl Namespace for ParseImportNamespace {
|
||||
fn parse_type(&self) -> ParseType {
|
||||
ParseType::ContinuousLines
|
||||
}
|
||||
|
||||
fn run_test(&self, test: Test) -> Result<Value, String> {
|
||||
create_session_if_not_set_then(|_| {
|
||||
let tokenizer = tokenize(test)?;
|
||||
if all_are_comments(&tokenizer) {
|
||||
return Ok(yaml_or_fail(Statement::Expression(ExpressionStatement {
|
||||
expression: implicit_value_expr(),
|
||||
span: Span::default(),
|
||||
})));
|
||||
}
|
||||
with_handler(tokenizer, |p| p.parse_import_statement()).map(yaml_or_fail)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct ParseStatementNamespace;
|
||||
|
||||
impl Namespace for ParseStatementNamespace {
|
||||
@ -248,7 +227,6 @@ impl Runner for TestRunner {
|
||||
fn resolve_namespace(&self, name: &str) -> Option<Box<dyn Namespace>> {
|
||||
Some(match name {
|
||||
"Parse" => Box::new(ParseNamespace),
|
||||
"ParseImport" => Box::new(ParseImportNamespace),
|
||||
"ParseExpression" => Box::new(ParseExpressionNamespace),
|
||||
"ParseStatement" => Box::new(ParseStatementNamespace),
|
||||
"Serialize" => Box::new(SerializeNamespace),
|
||||
|
@ -209,7 +209,7 @@ impl Token {
|
||||
return Ok((len + 2, Token::StringLit(string)));
|
||||
}
|
||||
|
||||
return Err(ParserError::lexer_string_not_closed(string).into());
|
||||
return Err(ParserError::lexer_string_not_closed(leo_ast::Chars(string)).into());
|
||||
}
|
||||
Some('\'') => {
|
||||
input.next();
|
||||
@ -244,7 +244,7 @@ impl Token {
|
||||
if input.next_if_eq(&'&').is_some() {
|
||||
return Ok((2, Token::And));
|
||||
}
|
||||
return Ok((1, Token::Ampersand));
|
||||
return Err(ParserError::lexer_empty_input_tendril().into());
|
||||
}
|
||||
Some('(') => {
|
||||
input.next();
|
||||
@ -293,11 +293,7 @@ impl Token {
|
||||
Some('.') => {
|
||||
input.next();
|
||||
if input.next_if_eq(&'.').is_some() {
|
||||
if input.next_if_eq(&'.').is_some() {
|
||||
return Ok((3, Token::DotDotDot));
|
||||
} else {
|
||||
return Ok((2, Token::DotDot));
|
||||
}
|
||||
return Ok((2, Token::DotDot));
|
||||
}
|
||||
return Ok((1, Token::Dot));
|
||||
}
|
||||
@ -344,11 +340,7 @@ impl Token {
|
||||
}
|
||||
Some(':') => {
|
||||
input.next();
|
||||
if input.next_if_eq(&':').is_some() {
|
||||
return Ok((2, Token::DoubleColon));
|
||||
} else {
|
||||
return Ok((1, Token::Colon));
|
||||
}
|
||||
return Ok((1, Token::Colon));
|
||||
}
|
||||
Some(';') => {
|
||||
input.next();
|
||||
@ -375,10 +367,6 @@ impl Token {
|
||||
}
|
||||
return Ok((1, Token::Assign));
|
||||
}
|
||||
Some('@') => {
|
||||
input.next();
|
||||
return Ok((1, Token::At));
|
||||
}
|
||||
Some('[') => {
|
||||
input.next();
|
||||
return Ok((1, Token::LeftSquare));
|
||||
@ -413,10 +401,8 @@ impl Token {
|
||||
match &*ident {
|
||||
x if x.starts_with("aleo1") => Token::AddressLit(ident),
|
||||
"address" => Token::Address,
|
||||
"as" => Token::As,
|
||||
"bool" => Token::Bool,
|
||||
"char" => Token::Char,
|
||||
"circuit" => Token::Circuit,
|
||||
"console" => Token::Console,
|
||||
"const" => Token::Const,
|
||||
"else" => Token::Else,
|
||||
@ -431,15 +417,11 @@ impl Token {
|
||||
"i64" => Token::I64,
|
||||
"i128" => Token::I128,
|
||||
"if" => Token::If,
|
||||
"import" => Token::Import,
|
||||
"in" => Token::In,
|
||||
"input" => Token::Input,
|
||||
"let" => Token::Let,
|
||||
"mut" => Token::Mut,
|
||||
"return" => Token::Return,
|
||||
"Self" => Token::BigSelf,
|
||||
"self" => Token::LittleSelf,
|
||||
"static" => Token::Static,
|
||||
"true" => Token::True,
|
||||
"type" => Token::Type,
|
||||
"u8" => Token::U8,
|
||||
|
@ -124,9 +124,7 @@ mod tests {
|
||||
test_ident
|
||||
12345
|
||||
address
|
||||
as
|
||||
bool
|
||||
circuit
|
||||
const
|
||||
else
|
||||
false
|
||||
@ -140,14 +138,11 @@ mod tests {
|
||||
i16
|
||||
i8
|
||||
if
|
||||
import
|
||||
in
|
||||
input
|
||||
let
|
||||
mut
|
||||
&
|
||||
return
|
||||
static
|
||||
string
|
||||
test
|
||||
true
|
||||
@ -156,8 +151,6 @@ mod tests {
|
||||
u32
|
||||
u16
|
||||
u8
|
||||
self
|
||||
Self
|
||||
console
|
||||
!
|
||||
!=
|
||||
@ -177,11 +170,9 @@ mod tests {
|
||||
_
|
||||
.
|
||||
..
|
||||
...
|
||||
/
|
||||
/=
|
||||
:
|
||||
::
|
||||
;
|
||||
<
|
||||
<=
|
||||
@ -189,7 +180,6 @@ mod tests {
|
||||
==
|
||||
>
|
||||
>=
|
||||
@
|
||||
[
|
||||
]
|
||||
{{
|
||||
@ -209,7 +199,7 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
output,
|
||||
r#"'a' '😭' "test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 test_ident 12345 address as bool circuit const else false field for function group i128 i64 i32 i16 i8 if import in input let mut & return static string test true u128 u64 u32 u16 u8 self Self console ! != && ( ) * ** **= *= + += , - -= -> _ . .. ... / /= : :: ; < <= = == > >= @ [ ] { { } } || ? // test
|
||||
r#"'a' '😭' "test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 test_ident 12345 address bool const else false field for function group i128 i64 i32 i16 i8 if in input let mut return string test true u128 u64 u32 u16 u8 console ! != && ( ) * ** **= *= + += , - -= -> _ . .. / /= : ; < <= = == > >= [ ] { { } } || ? // test
|
||||
/* test */ // "#
|
||||
);
|
||||
});
|
||||
|
@ -61,7 +61,6 @@ pub enum Token {
|
||||
WhiteSpace,
|
||||
|
||||
// Symbols
|
||||
At,
|
||||
Not,
|
||||
And,
|
||||
Or,
|
||||
@ -91,10 +90,8 @@ pub enum Token {
|
||||
Comma,
|
||||
Dot,
|
||||
DotDot,
|
||||
DotDotDot,
|
||||
Semicolon,
|
||||
Colon,
|
||||
DoubleColon,
|
||||
Question,
|
||||
Arrow,
|
||||
Underscore,
|
||||
@ -116,18 +113,11 @@ pub enum Token {
|
||||
Bool,
|
||||
Address,
|
||||
Char,
|
||||
BigSelf,
|
||||
|
||||
// primary expresion
|
||||
Input,
|
||||
LittleSelf,
|
||||
|
||||
// Import
|
||||
Import,
|
||||
|
||||
// Regular Keywords
|
||||
As,
|
||||
Circuit,
|
||||
Console,
|
||||
/// Const variable and a const function.
|
||||
Const,
|
||||
@ -138,11 +128,7 @@ pub enum Token {
|
||||
In,
|
||||
Let,
|
||||
Mut,
|
||||
/// Represents `&`.
|
||||
/// Used for `Reference` and `BitAnd`.
|
||||
Ampersand,
|
||||
Return,
|
||||
Static,
|
||||
Type,
|
||||
|
||||
// Meta Tokens
|
||||
@ -152,10 +138,8 @@ pub enum Token {
|
||||
/// Represents all valid Leo keyword tokens.
|
||||
pub const KEYWORD_TOKENS: &[Token] = &[
|
||||
Token::Address,
|
||||
Token::As,
|
||||
Token::Bool,
|
||||
Token::Char,
|
||||
Token::Circuit,
|
||||
Token::Console,
|
||||
Token::Const,
|
||||
Token::Else,
|
||||
@ -170,16 +154,11 @@ pub const KEYWORD_TOKENS: &[Token] = &[
|
||||
Token::I64,
|
||||
Token::I128,
|
||||
Token::If,
|
||||
Token::Import,
|
||||
Token::In,
|
||||
Token::Input,
|
||||
Token::Let,
|
||||
Token::Mut,
|
||||
Token::Ampersand,
|
||||
Token::Return,
|
||||
Token::BigSelf,
|
||||
Token::LittleSelf,
|
||||
Token::Static,
|
||||
Token::True,
|
||||
Token::Type,
|
||||
Token::U8,
|
||||
@ -199,11 +178,8 @@ impl Token {
|
||||
pub fn keyword_to_symbol(&self) -> Option<Symbol> {
|
||||
Some(match self {
|
||||
Token::Address => sym::address,
|
||||
Token::As => sym::As,
|
||||
Token::At => sym::At,
|
||||
Token::Bool => sym::bool,
|
||||
Token::Char => sym::char,
|
||||
Token::Circuit => sym::circuit,
|
||||
Token::Console => sym::console,
|
||||
Token::Const => sym::Const,
|
||||
Token::Else => sym::Else,
|
||||
@ -218,16 +194,11 @@ impl Token {
|
||||
Token::I64 => sym::i64,
|
||||
Token::I128 => sym::i128,
|
||||
Token::If => sym::If,
|
||||
Token::Import => sym::import,
|
||||
Token::In => sym::In,
|
||||
Token::Input => sym::input,
|
||||
Token::Let => sym::Let,
|
||||
Token::Mut => sym::Mut,
|
||||
Token::Ampersand => sym::Ampersand,
|
||||
Token::Return => sym::Return,
|
||||
Token::BigSelf => sym::SelfUpper,
|
||||
Token::LittleSelf => sym::SelfLower,
|
||||
Token::Static => sym::Static,
|
||||
Token::True => sym::True,
|
||||
Token::Type => sym::Type,
|
||||
Token::U8 => sym::u8,
|
||||
@ -261,8 +232,6 @@ impl fmt::Display for Token {
|
||||
CharLit(s) => write!(f, "'{}'", s),
|
||||
WhiteSpace => write!(f, "whitespace"),
|
||||
|
||||
At => write!(f, "@"),
|
||||
|
||||
Not => write!(f, "!"),
|
||||
And => write!(f, "&&"),
|
||||
Or => write!(f, "||"),
|
||||
@ -292,10 +261,8 @@ impl fmt::Display for Token {
|
||||
Comma => write!(f, ","),
|
||||
Dot => write!(f, "."),
|
||||
DotDot => write!(f, ".."),
|
||||
DotDotDot => write!(f, "..."),
|
||||
Semicolon => write!(f, ";"),
|
||||
Colon => write!(f, ":"),
|
||||
DoubleColon => write!(f, "::"),
|
||||
Question => write!(f, "?"),
|
||||
Arrow => write!(f, "->"),
|
||||
Underscore => write!(f, "_"),
|
||||
@ -315,15 +282,9 @@ impl fmt::Display for Token {
|
||||
Bool => write!(f, "bool"),
|
||||
Address => write!(f, "address"),
|
||||
Char => write!(f, "char"),
|
||||
BigSelf => write!(f, "Self"),
|
||||
|
||||
Input => write!(f, "input"),
|
||||
LittleSelf => write!(f, "self"),
|
||||
|
||||
Import => write!(f, "import"),
|
||||
|
||||
As => write!(f, "as"),
|
||||
Circuit => write!(f, "circuit"),
|
||||
Console => write!(f, "console"),
|
||||
Const => write!(f, "const"),
|
||||
Else => write!(f, "else"),
|
||||
@ -333,9 +294,7 @@ impl fmt::Display for Token {
|
||||
In => write!(f, "in"),
|
||||
Let => write!(f, "let"),
|
||||
Mut => write!(f, "mut"),
|
||||
Ampersand => write!(f, "&"), // Used for `Reference` and `BitAnd`
|
||||
Return => write!(f, "return"),
|
||||
Static => write!(f, "static"),
|
||||
Type => write!(f, "type"),
|
||||
Eof => write!(f, ""),
|
||||
}
|
||||
|
Binary file not shown.
@ -235,8 +235,8 @@ create_errors!(
|
||||
/// When a string is not properly closed.
|
||||
@backtraced
|
||||
lexer_string_not_closed {
|
||||
args: (input: impl Debug),
|
||||
msg: format!("Expected a closed string but found `{:?}`.", input),
|
||||
args: (input: impl Display),
|
||||
msg: format!("Expected a closed string but found `{}`.", input),
|
||||
help: None,
|
||||
}
|
||||
|
||||
|
@ -101,14 +101,10 @@ macro_rules! symbols {
|
||||
symbols! {
|
||||
address,
|
||||
AlwaysConst,
|
||||
Ampersand: "&",
|
||||
array,
|
||||
As: "as",
|
||||
assert,
|
||||
At: "@",
|
||||
bool,
|
||||
char,
|
||||
circuit,
|
||||
Class: "class",
|
||||
context,
|
||||
constants,
|
||||
@ -128,7 +124,6 @@ symbols! {
|
||||
i64,
|
||||
i128,
|
||||
If: "if",
|
||||
import,
|
||||
In: "in",
|
||||
input,
|
||||
Let: "let",
|
||||
@ -137,11 +132,8 @@ symbols! {
|
||||
Mut: "mut",
|
||||
prelude,
|
||||
Return: "return",
|
||||
SelfLower: "self",
|
||||
SelfUpper: "Self",
|
||||
Star: "*",
|
||||
std,
|
||||
Static: "static",
|
||||
Struct: "struct",
|
||||
test,
|
||||
True: "true",
|
||||
|
@ -37,5 +37,129 @@ outputs:
|
||||
col_stop: 28
|
||||
path: ""
|
||||
content: " static const y: u32 = 5;"
|
||||
- CircuitConst:
|
||||
- "{\"name\":\"G\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":18,\\\"col_stop\\\":19,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const G: u8 = G;\\\"}\"}"
|
||||
- IntegerType: U8
|
||||
- Identifier: "{\"name\":\"G\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":26,\\\"col_stop\\\":27,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const G: u8 = G;\\\"}\"}"
|
||||
- CircuitConst:
|
||||
- "{\"name\":\"FOO\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":18,\\\"col_stop\\\":21,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const FOO: Foo = Foo {};\\\"}\"}"
|
||||
- Identifier: "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":23,\\\"col_stop\\\":26,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const FOO: Foo = Foo {};\\\"}\"}"
|
||||
- CircuitInit:
|
||||
name: "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":29,\\\"col_stop\\\":32,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const FOO: Foo = Foo {};\\\"}\"}"
|
||||
members: []
|
||||
span:
|
||||
line_start: 7
|
||||
line_stop: 7
|
||||
col_start: 29
|
||||
col_stop: 35
|
||||
path: ""
|
||||
content: " static const FOO: Foo = Foo {};"
|
||||
- CircuitConst:
|
||||
- "{\"name\":\"INDEXED\",\"span\":\"{\\\"line_start\\\":8,\\\"line_stop\\\":8,\\\"col_start\\\":18,\\\"col_stop\\\":25,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const INDEXED: Foo = A[0];\\\"}\"}"
|
||||
- Identifier: "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":8,\\\"line_stop\\\":8,\\\"col_start\\\":27,\\\"col_stop\\\":30,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const INDEXED: Foo = A[0];\\\"}\"}"
|
||||
- Access:
|
||||
Array:
|
||||
array:
|
||||
Identifier: "{\"name\":\"A\",\"span\":\"{\\\"line_start\\\":8,\\\"line_stop\\\":8,\\\"col_start\\\":33,\\\"col_stop\\\":34,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const INDEXED: Foo = A[0];\\\"}\"}"
|
||||
index:
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- span:
|
||||
line_start: 8
|
||||
line_stop: 8
|
||||
col_start: 35
|
||||
col_stop: 36
|
||||
path: ""
|
||||
content: " static const INDEXED: Foo = A[0];"
|
||||
span:
|
||||
line_start: 8
|
||||
line_stop: 8
|
||||
col_start: 33
|
||||
col_stop: 37
|
||||
path: ""
|
||||
content: " static const INDEXED: Foo = A[0];"
|
||||
- CircuitConst:
|
||||
- "{\"name\":\"TINDEXED\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":18,\\\"col_stop\\\":26,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const TINDEXED: Foo = T.0;\\\"}\"}"
|
||||
- Identifier: "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":28,\\\"col_stop\\\":31,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const TINDEXED: Foo = T.0;\\\"}\"}"
|
||||
- Access:
|
||||
Tuple:
|
||||
tuple:
|
||||
Identifier: "{\"name\":\"T\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":34,\\\"col_stop\\\":35,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const TINDEXED: Foo = T.0;\\\"}\"}"
|
||||
index:
|
||||
value: "0"
|
||||
span:
|
||||
line_start: 9
|
||||
line_stop: 9
|
||||
col_start: 34
|
||||
col_stop: 37
|
||||
path: ""
|
||||
content: " static const TINDEXED: Foo = T.0;"
|
||||
- CircuitConst:
|
||||
- "{\"name\":\"TWO\",\"span\":\"{\\\"line_start\\\":10,\\\"line_stop\\\":10,\\\"col_start\\\":18,\\\"col_stop\\\":21,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const TWO: i8 = 1i8 + 1i8;\\\"}\"}"
|
||||
- IntegerType: I8
|
||||
- Binary:
|
||||
left:
|
||||
Value:
|
||||
Integer:
|
||||
- I8
|
||||
- "1"
|
||||
- span:
|
||||
line_start: 10
|
||||
line_stop: 10
|
||||
col_start: 28
|
||||
col_stop: 31
|
||||
path: ""
|
||||
content: " static const TWO: i8 = 1i8 + 1i8;"
|
||||
right:
|
||||
Value:
|
||||
Integer:
|
||||
- I8
|
||||
- "1"
|
||||
- span:
|
||||
line_start: 10
|
||||
line_stop: 10
|
||||
col_start: 34
|
||||
col_stop: 37
|
||||
path: ""
|
||||
content: " static const TWO: i8 = 1i8 + 1i8;"
|
||||
op: Add
|
||||
span:
|
||||
line_start: 10
|
||||
line_stop: 10
|
||||
col_start: 28
|
||||
col_stop: 37
|
||||
path: ""
|
||||
content: " static const TWO: i8 = 1i8 + 1i8;"
|
||||
- CircuitConst:
|
||||
- "{\"name\":\"mult\",\"span\":\"{\\\"line_start\\\":11,\\\"line_stop\\\":11,\\\"col_start\\\":18,\\\"col_stop\\\":22,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const mult: i8 = x * y;\\\"}\"}"
|
||||
- IntegerType: I8
|
||||
- Binary:
|
||||
left:
|
||||
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":11,\\\"line_stop\\\":11,\\\"col_start\\\":29,\\\"col_stop\\\":30,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const mult: i8 = x * y;\\\"}\"}"
|
||||
right:
|
||||
Identifier: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":11,\\\"line_stop\\\":11,\\\"col_start\\\":33,\\\"col_stop\\\":34,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const mult: i8 = x * y;\\\"}\"}"
|
||||
op: Mul
|
||||
span:
|
||||
line_start: 11
|
||||
line_stop: 11
|
||||
col_start: 29
|
||||
col_stop: 34
|
||||
path: ""
|
||||
content: " static const mult: i8 = x * y;"
|
||||
- CircuitConst:
|
||||
- "{\"name\":\"mult\",\"span\":\"{\\\"line_start\\\":12,\\\"line_stop\\\":12,\\\"col_start\\\":18,\\\"col_stop\\\":22,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const mult: i8 = one();\\\"}\"}"
|
||||
- IntegerType: I8
|
||||
- Call:
|
||||
function:
|
||||
Identifier: "{\"name\":\"one\",\"span\":\"{\\\"line_start\\\":12,\\\"line_stop\\\":12,\\\"col_start\\\":29,\\\"col_stop\\\":32,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" static const mult: i8 = one();\\\"}\"}"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 12
|
||||
line_stop: 12
|
||||
col_start: 29
|
||||
col_stop: 34
|
||||
path: ""
|
||||
content: " static const mult: i8 = one();"
|
||||
global_consts: {}
|
||||
functions: {}
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Parse
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370000]: Function calls not allowed in circuit members.\n --> test:4:27\n |\n 4 | static const x: u32 = foo();\n | ^^^^^"
|
@ -0,0 +1,15 @@
|
||||
---
|
||||
namespace: Parse
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits:
|
||||
"{\"name\":\"u32\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit u32 {}\\\"}\"}":
|
||||
circuit_name: "{\"name\":\"u32\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit u32 {}\\\"}\"}"
|
||||
members: []
|
||||
global_consts: {}
|
||||
functions: {}
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Parse
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got 'address'\n --> test:3:9\n |\n 3 | circuit address {}\n | ^^^^^^^"
|
@ -215,41 +215,6 @@ outputs:
|
||||
col_stop: 7
|
||||
path: ""
|
||||
content: "x()[0]"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Call:
|
||||
function:
|
||||
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":2,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x(y)::y(x)\\\"}\"}"
|
||||
arguments:
|
||||
- Identifier: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x(y)::y(x)\\\"}\"}"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "x(y)::y(x)"
|
||||
name: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x(y)::y(x)\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 8
|
||||
path: ""
|
||||
content: "x(y)::y(x)"
|
||||
arguments:
|
||||
- Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x(y)::y(x)\\\"}\"}"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 11
|
||||
path: ""
|
||||
content: "x(y)::y(x)"
|
||||
- Access:
|
||||
Array:
|
||||
array:
|
||||
|
@ -63,107 +63,3 @@ outputs:
|
||||
col_stop: 11
|
||||
path: ""
|
||||
content: "x(x, y, z)"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":2,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x::y()\\\"}\"}"
|
||||
name: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":4,\\\"col_stop\\\":5,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x::y()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "x::y()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 7
|
||||
path: ""
|
||||
content: "x::y()"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":2,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x::y(x)\\\"}\"}"
|
||||
name: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":4,\\\"col_stop\\\":5,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x::y(x)\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "x::y(x)"
|
||||
arguments:
|
||||
- Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":6,\\\"col_stop\\\":7,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x::y(x)\\\"}\"}"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 8
|
||||
path: ""
|
||||
content: "x::y(x)"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Tuple:
|
||||
tuple:
|
||||
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":2,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x.0(x)\\\"}\"}"
|
||||
index:
|
||||
value: "0"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 4
|
||||
path: ""
|
||||
content: x.0(x)
|
||||
arguments:
|
||||
- Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":5,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x.0(x)\\\"}\"}"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 7
|
||||
path: ""
|
||||
content: x.0(x)
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Array:
|
||||
array:
|
||||
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":2,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x[0](x)\\\"}\"}"
|
||||
index:
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 3
|
||||
col_stop: 4
|
||||
path: ""
|
||||
content: "x[0](x)"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "x[0](x)"
|
||||
arguments:
|
||||
- Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":6,\\\"col_stop\\\":7,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x[0](x)\\\"}\"}"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 8
|
||||
path: ""
|
||||
content: "x[0](x)"
|
||||
|
@ -101,37 +101,3 @@ outputs:
|
||||
col_stop: 6
|
||||
path: ""
|
||||
content: x.y.0
|
||||
- Access:
|
||||
Array:
|
||||
array:
|
||||
Access:
|
||||
Member:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":2,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x.y[1]\\\"}\"}"
|
||||
name: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"x.y[1]\\\"}\"}"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 4
|
||||
path: ""
|
||||
content: "x.y[1]"
|
||||
type_: ~
|
||||
index:
|
||||
Value:
|
||||
Implicit:
|
||||
- "1"
|
||||
- span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 5
|
||||
col_stop: 6
|
||||
path: ""
|
||||
content: "x.y[1]"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 7
|
||||
path: ""
|
||||
content: "x.y[1]"
|
||||
|
@ -2,7 +2,7 @@
|
||||
namespace: ParseExpression
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370010]: illegal spread in array initializer\n --> test:1:1\n |\n 1 | [...0u8; 1]\n | ^^^^^^^"
|
||||
- "Error [EPAR0370010]: illegal spread in array initializer\n --> test:1:1\n |\n 1 | [...0; 1]\n | ^^^^^"
|
||||
- "Error [EPAR0370022]: Array dimensions specified as a tuple cannot be empty.\n --> test:1:5\n |\n 1 | [0; ()]\n | ^^"
|
||||
- "Error [EPAR0370039]: do not put parens around single dimension array size\n --> test:1:5\n |\n 1 | [0; (1)]\n | ^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [...0u8; 1]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [...0; 1]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [0; ()]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [0; (1)]\n | ^"
|
||||
|
@ -2,8 +2,8 @@
|
||||
namespace: ParseExpression
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ','\n --> test:1:2\n |\n 1 | [,]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ','\n --> test:1:2\n |\n 1 | [,,]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ','\n --> test:1:4\n |\n 1 | [0,,]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ','\n --> test:1:2\n |\n 1 | [,0]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ','\n --> test:1:2\n |\n 1 | [,0,]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [,]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [,,]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [0,,]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [,0]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [,0,]\n | ^"
|
||||
|
@ -116,141 +116,3 @@ outputs:
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: 1 ** 2 ** 3
|
||||
- Binary:
|
||||
left:
|
||||
Cast:
|
||||
inner:
|
||||
Value:
|
||||
Implicit:
|
||||
- "1"
|
||||
- span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 2
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8
|
||||
target_type:
|
||||
IntegerType: I8
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 8
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8
|
||||
right:
|
||||
Cast:
|
||||
inner:
|
||||
Value:
|
||||
Implicit:
|
||||
- "3"
|
||||
- span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 12
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8
|
||||
target_type:
|
||||
IntegerType: I8
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 12
|
||||
col_stop: 19
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8
|
||||
op: Pow
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 19
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8
|
||||
- Binary:
|
||||
left:
|
||||
Cast:
|
||||
inner:
|
||||
Value:
|
||||
Implicit:
|
||||
- "1"
|
||||
- span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 2
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8 ** 5 as i8
|
||||
target_type:
|
||||
IntegerType: I8
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 8
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8 ** 5 as i8
|
||||
right:
|
||||
Binary:
|
||||
left:
|
||||
Cast:
|
||||
inner:
|
||||
Value:
|
||||
Implicit:
|
||||
- "3"
|
||||
- span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 12
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8 ** 5 as i8
|
||||
target_type:
|
||||
IntegerType: I8
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 12
|
||||
col_stop: 19
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8 ** 5 as i8
|
||||
right:
|
||||
Cast:
|
||||
inner:
|
||||
Value:
|
||||
Implicit:
|
||||
- "5"
|
||||
- span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 23
|
||||
col_stop: 24
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8 ** 5 as i8
|
||||
target_type:
|
||||
IntegerType: I8
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 23
|
||||
col_stop: 30
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8 ** 5 as i8
|
||||
op: Pow
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 12
|
||||
col_stop: 30
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8 ** 5 as i8
|
||||
op: Pow
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 30
|
||||
path: ""
|
||||
content: 1 as i8 ** 3 as i8 ** 5 as i8
|
||||
|
@ -2,15 +2,15 @@
|
||||
namespace: ParseExpression
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370003]: unexpected EOF\n --> test:1:3\n |\n 1 | x {\n | ^"
|
||||
- "did not consume all input: '{' @ 1:3-4\n"
|
||||
- "did not consume all input: '}' @ 1:3-4\n"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:4\n |\n 1 | x {,}\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:5\n |\n 1 | x { , }\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:4\n |\n 1 | x {,,,}\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:6\n |\n 1 | x {x,,}\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:4\n |\n 1 | x {,,x}\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:4\n |\n 1 | x {,x}\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:8\n |\n 1 | x {x:y,,}\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:4\n |\n 1 | x {,,x:y}\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:4\n |\n 1 | x {,x:y}\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '}'\n --> test:1:6\n |\n 1 | x {x:}\n | ^"
|
||||
- "did not consume all input: '{' @ 1:3-4\n',' @ 1:4-5\n'}' @ 1:5-6\n"
|
||||
- "did not consume all input: '{' @ 1:3-4\n',' @ 1:5-6\n'}' @ 1:7-8\n"
|
||||
- "did not consume all input: '{' @ 1:3-4\n',' @ 1:4-5\n',' @ 1:5-6\n',' @ 1:6-7\n'}' @ 1:7-8\n"
|
||||
- "did not consume all input: '{' @ 1:3-4\n'x' @ 1:4-5\n',' @ 1:5-6\n',' @ 1:6-7\n'}' @ 1:7-8\n"
|
||||
- "did not consume all input: '{' @ 1:3-4\n',' @ 1:4-5\n',' @ 1:5-6\n'x' @ 1:6-7\n'}' @ 1:7-8\n"
|
||||
- "did not consume all input: '{' @ 1:3-4\n',' @ 1:4-5\n'x' @ 1:5-6\n'}' @ 1:6-7\n"
|
||||
- "did not consume all input: '{' @ 1:3-4\n'x' @ 1:4-5\n':' @ 1:5-6\n'y' @ 1:6-7\n',' @ 1:7-8\n',' @ 1:8-9\n'}' @ 1:9-10\n"
|
||||
- "did not consume all input: '{' @ 1:3-4\n',' @ 1:4-5\n',' @ 1:5-6\n'x' @ 1:6-7\n':' @ 1:7-8\n'y' @ 1:8-9\n'}' @ 1:9-10\n"
|
||||
- "did not consume all input: '{' @ 1:3-4\n',' @ 1:4-5\n'x' @ 1:5-6\n':' @ 1:6-7\n'y' @ 1:7-8\n'}' @ 1:8-9\n"
|
||||
- "did not consume all input: '{' @ 1:3-4\n'x' @ 1:4-5\n':' @ 1:5-6\n'}' @ 1:6-7\n"
|
||||
|
@ -44,29 +44,6 @@ outputs:
|
||||
col_stop: 71
|
||||
path: ""
|
||||
content: aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8.call()
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"address\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"address::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"address::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: "address::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 16
|
||||
path: ""
|
||||
content: "address::call()"
|
||||
- Value:
|
||||
Implicit:
|
||||
- ""
|
||||
@ -109,29 +86,6 @@ outputs:
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: true.call()
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"bool\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":5,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"bool::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":7,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"bool::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 11
|
||||
path: ""
|
||||
content: "bool::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: "bool::call()"
|
||||
- Value:
|
||||
Implicit:
|
||||
- ""
|
||||
@ -175,29 +129,6 @@ outputs:
|
||||
col_stop: 11
|
||||
path: ""
|
||||
content: "'a'.call()"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"char\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":5,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"char::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":7,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"char::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 11
|
||||
path: ""
|
||||
content: "char::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: "char::call()"
|
||||
- Value:
|
||||
Implicit:
|
||||
- ""
|
||||
@ -240,29 +171,6 @@ outputs:
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: 1field.call()
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"field\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"field::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":8,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"field::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: "field::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: "field::call()"
|
||||
- Value:
|
||||
Implicit:
|
||||
- ""
|
||||
@ -358,29 +266,6 @@ outputs:
|
||||
col_stop: 19
|
||||
path: ""
|
||||
content: "(0, 1)group.call()"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"group\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"group::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":8,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"group::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: "group::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: "group::call()"
|
||||
- Value:
|
||||
Implicit:
|
||||
- ""
|
||||
@ -556,121 +441,6 @@ outputs:
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: 1i128.call()
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"i8\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"i8::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":5,\\\"col_stop\\\":9,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"i8::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 9
|
||||
path: ""
|
||||
content: "i8::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 11
|
||||
path: ""
|
||||
content: "i8::call()"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"i16\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"i16::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":6,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"i16::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 10
|
||||
path: ""
|
||||
content: "i16::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: "i16::call()"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"i32\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"i32::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":6,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"i32::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 10
|
||||
path: ""
|
||||
content: "i32::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: "i32::call()"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"i64\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"i64::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":6,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"i64::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 10
|
||||
path: ""
|
||||
content: "i64::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: "i64::call()"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"i128\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":5,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"i128::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":7,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"i128::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 11
|
||||
path: ""
|
||||
content: "i128::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: "i128::call()"
|
||||
- Value:
|
||||
Implicit:
|
||||
- ""
|
||||
@ -846,118 +616,3 @@ outputs:
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: 1u128.call()
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"u8\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"u8::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":5,\\\"col_stop\\\":9,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"u8::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 9
|
||||
path: ""
|
||||
content: "u8::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 11
|
||||
path: ""
|
||||
content: "u8::call()"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"u16\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"u16::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":6,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"u16::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 10
|
||||
path: ""
|
||||
content: "u16::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: "u16::call()"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"u32\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"u32::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":6,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"u32::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 10
|
||||
path: ""
|
||||
content: "u32::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: "u32::call()"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"u64\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"u64::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":6,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"u64::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 10
|
||||
path: ""
|
||||
content: "u64::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 12
|
||||
path: ""
|
||||
content: "u64::call()"
|
||||
- Call:
|
||||
function:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"u128\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":5,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"u128::call()\\\"}\"}"
|
||||
name: "{\"name\":\"call\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":7,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"u128::call()\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 11
|
||||
path: ""
|
||||
content: "u128::call()"
|
||||
arguments: []
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: "u128::call()"
|
||||
|
@ -8,6 +8,7 @@ outputs:
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `\\n`."
|
||||
- "Error [EPAR0370023]: Expected more characters to lex but found none."
|
||||
- "Error [EPAR0370023]: Expected more characters to lex but found none."
|
||||
- "Error [EPAR0370023]: Expected more characters to lex but found none."
|
||||
- "Error [EPAR0370031]: Expected a valid hex character but found `'`."
|
||||
- "Error [EPAR0370031]: Expected a valid hex character but found `'`."
|
||||
- "Error [EPAR0370031]: Expected a valid hex character but found `9A`."
|
||||
@ -44,5 +45,6 @@ outputs:
|
||||
- "Error [EPAR0370037]: There was no opening `{` after starting an escaped unicode `0`."
|
||||
- "Error [EPAR0370037]: There was no opening `{` after starting an escaped unicode `0`."
|
||||
- "Error [EPAR0370034]: The escaped unicode char `110000` is greater than 0x10FFFF."
|
||||
- "Error [EPAR0370033]: The escaped unicode char `1234567890` is not within valid length of [1, 6]."
|
||||
- "Error [EPAR0370026]: Expected a closed char but found ``."
|
||||
- "Error [EPAR0370026]: Expected a closed char but found `😭`."
|
||||
|
@ -4,9 +4,4 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions: {}
|
||||
|
@ -2,15 +2,15 @@
|
||||
namespace: ParseExpression
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "did not consume all input: 'group' @ 1:3-8\n"
|
||||
- "Error [EPAR0370005]: expected A valid expression. -- got 'A tuple expression.'\n --> test:1:1\n |\n 1 | ()group\n | ^^"
|
||||
- "did not consume all input: 'group' @ 1:6-11\n"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ','\n --> test:1:2\n |\n 1 | (,)group\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '+'\n --> test:1:2\n |\n 1 | (+, -,)group\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ','\n --> test:1:2\n |\n 1 | (,+, -)group\n | ^"
|
||||
- "did not consume all input: 'group' @ 1:6-11\n"
|
||||
- "did not consume all input: 'group' @ 1:12-17\n"
|
||||
- "did not consume all input: 'group' @ 1:15-20\n"
|
||||
- "Error [EPAR0370005]: expected A valid expression. -- got 'A tuple expression.'\n --> test:1:1\n |\n 1 | (x,y)group\n | ^^^^^"
|
||||
- "Error [EPAR0370005]: expected A valid expression. -- got 'A tuple expression.'\n --> test:1:1\n |\n 1 | (123,456u8)group\n | ^^^^^^^^^^^"
|
||||
- "Error [EPAR0370005]: expected A valid expression. -- got 'A tuple expression.'\n --> test:1:1\n |\n 1 | (123,456field)group\n | ^^^^^^^^^^^^^^"
|
||||
- "Error [EPAR0370004]: Unexpected white space between terms (123,456) and group\n --> test:1:10\n |\n 1 | (123, 456) group\n | ^"
|
||||
- "did not consume all input: 'group' @ 1:8-13\n"
|
||||
- "did not consume all input: 'group' @ 1:16-21\n"
|
||||
- "did not consume all input: 'bool' @ 1:11-15\n"
|
||||
- "Error [EPAR0370005]: expected A valid expression. -- got 'A tuple expression.'\n --> test:1:1\n |\n 1 | (123, 456, 789)group\n | ^^^^^^^^^^^^^^^"
|
||||
- "Error [EPAR0370005]: expected A valid expression. -- got 'A tuple expression.'\n --> test:1:1\n |\n 1 | (123, 456)bool\n | ^^^^^^^^^^"
|
||||
|
@ -0,0 +1,19 @@
|
||||
---
|
||||
namespace: ParseExpression
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'address'\n --> test:1:1\n |\n 1 | address::call()\n | ^^^^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'bool'\n --> test:1:1\n |\n 1 | bool::call()\n | ^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'char'\n --> test:1:1\n |\n 1 | char::call()\n | ^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'field'\n --> test:1:1\n |\n 1 | field::call()\n | ^^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'group'\n --> test:1:1\n |\n 1 | group::call()\n | ^^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'i8'\n --> test:1:1\n |\n 1 | i8::call()\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'i16'\n --> test:1:1\n |\n 1 | i16::call()\n | ^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'i32'\n --> test:1:1\n |\n 1 | i32::call()\n | ^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'i64'\n --> test:1:1\n |\n 1 | i64::call()\n | ^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'i128'\n --> test:1:1\n |\n 1 | i128::call()\n | ^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'u8'\n --> test:1:1\n |\n 1 | u8::call()\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'u16'\n --> test:1:1\n |\n 1 | u16::call()\n | ^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'u32'\n --> test:1:1\n |\n 1 | u32::call()\n | ^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'u64'\n --> test:1:1\n |\n 1 | u64::call()\n | ^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'u128'\n --> test:1:1\n |\n 1 | u128::call()\n | ^^^^"
|
@ -2,8 +2,8 @@
|
||||
namespace: Token
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370025]: Expected a closed string but found `[Scalar('H'), Scalar('e'), Scalar('l'), Scalar('l'), Scalar('o'), Scalar(' '), Scalar('w'), Scalar('o'), Scalar('r'), Scalar('l'), Scalar('d'), Scalar('!')]`."
|
||||
- "Error [EPAR0370025]: Expected a closed string but found `[Scalar('\"')]`."
|
||||
- "Error [EPAR0370025]: Expected a closed string but found `Hello world!`."
|
||||
- "Error [EPAR0370025]: Expected a closed string but found `\"`."
|
||||
- "Error [EPAR0370023]: Expected more characters to lex but found none."
|
||||
- "Error [EPAR0370024]: Expected a valid escape character but found `l`."
|
||||
- "Error [EPAR0370037]: There was no opening `{` after starting an escaped unicode `a`."
|
||||
@ -13,5 +13,5 @@ outputs:
|
||||
- "Error [EPAR0370037]: There was no opening `{` after starting an escaped unicode `}`."
|
||||
- "Error [EPAR0370037]: There was no opening `{` after starting an escaped unicode `6`."
|
||||
- "Error [EPAR0370032]: There was no closing `}` after a escaped unicode `af🦀\"`."
|
||||
- "Error [EPAR0370025]: Expected a closed string but found `[Scalar('\"')]`."
|
||||
- "Error [EPAR0370025]: Expected a closed string but found `[Scalar('⭇'), Scalar('😍'), Scalar(';')]`."
|
||||
- "Error [EPAR0370025]: Expected a closed string but found `\"`."
|
||||
- "Error [EPAR0370025]: Expected a closed string but found `⭇😍;`."
|
||||
|
@ -0,0 +1,76 @@
|
||||
---
|
||||
namespace: ParseExpression
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `@test`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '&&'\n --> test:1:1\n |\n 1 | &&\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '||'\n --> test:1:1\n |\n 1 | ||\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '=='\n --> test:1:1\n |\n 1 | ==\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '!='\n --> test:1:1\n |\n 1 | !=\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '<'\n --> test:1:1\n |\n 1 | <\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '<='\n --> test:1:1\n |\n 1 | <=\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '>'\n --> test:1:1\n |\n 1 | >\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '>='\n --> test:1:1\n |\n 1 | >=\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '+'\n --> test:1:1\n |\n 1 | +\n | ^"
|
||||
- "Error [EPAR0370003]: unexpected EOF\n --> test:1:1\n |\n 1 | -\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '*'\n --> test:1:1\n |\n 1 | *\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '**'\n --> test:1:1\n |\n 1 | **\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '/'\n --> test:1:1\n |\n 1 | /\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '='\n --> test:1:1\n |\n 1 | =\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '+='\n --> test:1:1\n |\n 1 | +=\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '-='\n --> test:1:1\n |\n 1 | -=\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '*='\n --> test:1:1\n |\n 1 | *=\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '/='\n --> test:1:1\n |\n 1 | /=\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '**='\n --> test:1:1\n |\n 1 | **=\n | ^^^"
|
||||
- "Error [EPAR0370003]: unexpected EOF\n --> test:1:1\n |\n 1 | (\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ')'\n --> test:1:1\n |\n 1 | )\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ']'\n --> test:1:1\n |\n 1 | ]\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '{'\n --> test:1:1\n |\n 1 | {\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '}'\n --> test:1:1\n |\n 1 | }\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ','\n --> test:1:1\n |\n 1 | ,\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '.'\n --> test:1:1\n |\n 1 | .\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '..'\n --> test:1:1\n |\n 1 | ..\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '..'\n --> test:1:1\n |\n 1 | ...\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ';'\n --> test:1:1\n |\n 1 | ;\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ':'\n --> test:1:1\n |\n 1 | :\n | ^"
|
||||
- "did not consume all input: ':' @ 1:2-3\n':' @ 1:3-4\n"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '?'\n --> test:1:1\n |\n 1 | ?\n | ^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '->'\n --> test:1:1\n |\n 1 | ->\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '_'\n --> test:1:1\n |\n 1 | _\n | ^"
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `~`."
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'console'\n --> test:1:1\n |\n 1 | console\n | ^^^^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'const'\n --> test:1:1\n |\n 1 | const\n | ^^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'else'\n --> test:1:1\n |\n 1 | else\n | ^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'for'\n --> test:1:1\n |\n 1 | for\n | ^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'function'\n --> test:1:1\n |\n 1 | function\n | ^^^^^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'if'\n --> test:1:1\n |\n 1 | if\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'in'\n --> test:1:1\n |\n 1 | in\n | ^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'let'\n --> test:1:1\n |\n 1 | let\n | ^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'mut'\n --> test:1:1\n |\n 1 | mut\n | ^^^"
|
||||
- "Error [EPAR0370023]: Expected more characters to lex but found none."
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'return'\n --> test:1:1\n |\n 1 | return\n | ^^^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'type'\n --> test:1:1\n |\n 1 | type\n | ^^^^"
|
@ -13,52 +13,6 @@ outputs:
|
||||
col_stop: 3
|
||||
path: ""
|
||||
content: "-x"
|
||||
- Unary:
|
||||
inner:
|
||||
Access:
|
||||
Member:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":2,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"-x.y\\\"}\"}"
|
||||
name: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":4,\\\"col_stop\\\":5,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"-x.y\\\"}\"}"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "-x.y"
|
||||
type_: ~
|
||||
op: Negate
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "-x.y"
|
||||
- Unary:
|
||||
inner:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":2,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"-x::y\\\"}\"}"
|
||||
name: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":5,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"-x::y\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 6
|
||||
path: ""
|
||||
content: "-x::y"
|
||||
op: Negate
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 6
|
||||
path: ""
|
||||
content: "-x::y"
|
||||
- Unary:
|
||||
inner:
|
||||
Call:
|
||||
@ -122,24 +76,44 @@ outputs:
|
||||
col_stop: 4
|
||||
path: ""
|
||||
content: "-!x"
|
||||
- Value:
|
||||
Implicit:
|
||||
- "-5"
|
||||
- span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 3
|
||||
path: ""
|
||||
content: "-5"
|
||||
- Value:
|
||||
Integer:
|
||||
- I8
|
||||
- "-5"
|
||||
- span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "-5i8"
|
||||
- Unary:
|
||||
inner:
|
||||
Value:
|
||||
Implicit:
|
||||
- "5"
|
||||
- span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 3
|
||||
path: ""
|
||||
content: "-5"
|
||||
op: Negate
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 3
|
||||
path: ""
|
||||
content: "-5"
|
||||
- Unary:
|
||||
inner:
|
||||
Value:
|
||||
Integer:
|
||||
- I8
|
||||
- "5"
|
||||
- span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "-5i8"
|
||||
op: Negate
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "-5i8"
|
||||
|
@ -13,52 +13,6 @@ outputs:
|
||||
col_stop: 3
|
||||
path: ""
|
||||
content: "!x"
|
||||
- Unary:
|
||||
inner:
|
||||
Access:
|
||||
Member:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":2,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"!x.y\\\"}\"}"
|
||||
name: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":4,\\\"col_stop\\\":5,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"!x.y\\\"}\"}"
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "!x.y"
|
||||
type_: ~
|
||||
op: Not
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 5
|
||||
path: ""
|
||||
content: "!x.y"
|
||||
- Unary:
|
||||
inner:
|
||||
Access:
|
||||
Static:
|
||||
inner:
|
||||
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":2,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"!x::y\\\"}\"}"
|
||||
name: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":5,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"!x::y\\\"}\"}"
|
||||
type_: ~
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 2
|
||||
col_stop: 6
|
||||
path: ""
|
||||
content: "!x::y"
|
||||
op: Not
|
||||
span:
|
||||
line_start: 1
|
||||
line_stop: 1
|
||||
col_start: 1
|
||||
col_stop: 6
|
||||
path: ""
|
||||
content: "!x::y"
|
||||
- Unary:
|
||||
inner:
|
||||
Call:
|
||||
|
@ -7,7 +7,6 @@ outputs:
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function a() {\\\"}\"}":
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Parse
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got '?'\n --> test:3:6\n |\n 3 | @foo(?, bar, ?)\n | ^\nError [EPAR0370009]: unexpected string: expected 'ident', got '?'\n --> test:3:14\n |\n 3 | @foo(?, bar, ?)\n | ^\nError [EPAR0370009]: unexpected string: expected 'ident', got '123'\n --> test:8:6\n |\n 8 | @bar(123) // ints not vali\n | ^^^\nError [EPAR0370016]: \"@context(...)\" is deprecated. Did you mean @test annotation?\n --> test:14:2\n |\n 14 | @context // recovery witness\n | ^^^^^^^"
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `@foo(?, bar, ?)\nfunction x() {\n return ();\n}\n\n@bar(123) // ints not vali\nfunction x() {\n return ();\n}\n\n\n@context // recovery witness\nfunction x() {\n return ();\n}\n`."
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Parse
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370016]: \"@context(...)\" is deprecated. Did you mean @test annotation?\n --> test:3:2\n |\n 3 | @context\n | ^^^^^^^\nError [EPAR0370016]: \"@context(...)\" is deprecated. Did you mean @test annotation?\n --> test:8:2\n |\n 8 | @context // recovery witness\n | ^^^^^^^"
|
||||
- "Error [EPAR0370030]: Could not lex the following content: `@context\nfunction f() {\n return ();\n}\n\n@context // recovery witness\nfunction g() {\n return ();\n}\n`."
|
||||
|
@ -7,7 +7,6 @@ outputs:
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {\\\"}\"}":
|
||||
|
@ -7,7 +7,6 @@ outputs:
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {\\\"}\"}":
|
||||
|
@ -4,14 +4,8 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const y: u32) {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const y: u32) {\\\"}\"}"
|
||||
input:
|
||||
- Variable:
|
||||
@ -131,7 +125,6 @@ outputs:
|
||||
path: ""
|
||||
content: "function x(const y: u32) {\n ...\n ...\n ...\n}"
|
||||
"{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(y: bool) -> bool {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(y: bool) -> bool {\\\"}\"}"
|
||||
input:
|
||||
- Variable:
|
||||
|
@ -4,14 +4,8 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":16,\\\"col_stop\\\":17,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"const function x() {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":16,\\\"col_stop\\\":17,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"const function x() {\\\"}\"}"
|
||||
input: []
|
||||
const_: true
|
||||
@ -21,22 +15,23 @@ outputs:
|
||||
statements:
|
||||
- Return:
|
||||
expression:
|
||||
TupleInit:
|
||||
elements: []
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 12
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: " return ();"
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 12
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 5
|
||||
col_stop: 14
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return ();"
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 3
|
||||
line_stop: 5
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Parse
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370003]: unexpected EOF\n --> test:3:1\n |\n 3 | const\n | ^^^^^"
|
||||
- "Error [EPAR0370005]: expected 'function', 'test' -- got 'const'\n --> test:3:1\n |\n 3 | const\n | ^^^^^"
|
||||
|
@ -4,14 +4,8 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, const y: i32) {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, const y: i32) {\\\"}\"}"
|
||||
input:
|
||||
- Variable:
|
||||
@ -47,22 +41,23 @@ outputs:
|
||||
statements:
|
||||
- Return:
|
||||
expression:
|
||||
TupleInit:
|
||||
elements: []
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 12
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: " return ();"
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 12
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 5
|
||||
col_stop: 14
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return ();"
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 3
|
||||
line_stop: 5
|
||||
@ -78,7 +73,6 @@ outputs:
|
||||
path: ""
|
||||
content: "function x(x: u32, const y: i32) {\n ...\n}"
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const x: u32, y: i32) {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const x: u32, y: i32) {\\\"}\"}"
|
||||
input:
|
||||
- Variable:
|
||||
@ -114,22 +108,23 @@ outputs:
|
||||
statements:
|
||||
- Return:
|
||||
expression:
|
||||
TupleInit:
|
||||
elements: []
|
||||
span:
|
||||
line_start: 8
|
||||
line_stop: 8
|
||||
col_start: 12
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: " return ();"
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- span:
|
||||
line_start: 8
|
||||
line_stop: 8
|
||||
col_start: 12
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 8
|
||||
line_stop: 8
|
||||
col_start: 5
|
||||
col_stop: 14
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return ();"
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 7
|
||||
line_stop: 9
|
||||
|
@ -7,7 +7,6 @@ outputs:
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const self) {\\\"}\"}":
|
||||
|
@ -4,14 +4,8 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {\\\"}\"}"
|
||||
input: []
|
||||
const_: false
|
||||
|
@ -4,14 +4,8 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {}\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {}\\\"}\"}"
|
||||
input: []
|
||||
const_: false
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Parse
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370005]: expected 'function', 'test' -- got '1'\n --> test:3:1\n |\n 3 | 1 main() {}\n | ^"
|
@ -4,14 +4,8 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"inf\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":13,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function inf() {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"inf\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":13,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function inf() {\\\"}\"}"
|
||||
input: []
|
||||
const_: false
|
||||
@ -54,7 +48,6 @@ outputs:
|
||||
path: ""
|
||||
content: "function inf() {\n ...\n}"
|
||||
"{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(y: bool) -> bool {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(y: bool) -> bool {\\\"}\"}"
|
||||
input:
|
||||
- Variable:
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Parse
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370013]: function func(mut a: u32) { ... } is deprecated. Passed variables are mutable by default.\n --> test:3:12\n |\n 3 | function f(mut a: u8) {}\n | ^^^^^"
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Parse
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370013]: function func(mut a: u32) { ... } is deprecated. Passed variables are mutable by default.\n --> test:3:12\n |\n 3 | function f(mut a: u8) {}\n | ^^^^^"
|
@ -7,11 +7,9 @@ outputs:
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: [u8; 12]) {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: [u8; 12]) {\\\"}\"}"
|
||||
input:
|
||||
- Variable:
|
||||
|
@ -7,11 +7,9 @@ outputs:
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: MyCircuit) {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: MyCircuit) {\\\"}\"}"
|
||||
input:
|
||||
- Variable:
|
||||
|
@ -4,14 +4,8 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: (u32, i32)) {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: (u32, i32)) {\\\"}\"}"
|
||||
input:
|
||||
- Variable:
|
||||
|
@ -4,14 +4,8 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, y: i32) {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, y: i32) {\\\"}\"}"
|
||||
input:
|
||||
- Variable:
|
||||
@ -47,22 +41,23 @@ outputs:
|
||||
statements:
|
||||
- Return:
|
||||
expression:
|
||||
TupleInit:
|
||||
elements: []
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 12
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: " return ();"
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 12
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 5
|
||||
col_stop: 14
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return ();"
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 3
|
||||
line_stop: 5
|
||||
|
@ -4,14 +4,8 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, y: i32) -> u32 {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, y: i32) -> u32 {\\\"}\"}"
|
||||
input:
|
||||
- Variable:
|
||||
@ -48,22 +42,23 @@ outputs:
|
||||
statements:
|
||||
- Return:
|
||||
expression:
|
||||
TupleInit:
|
||||
elements: []
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 12
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: " return ();"
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 12
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 5
|
||||
col_stop: 14
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return ();"
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 3
|
||||
line_stop: 5
|
||||
|
@ -4,14 +4,8 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() -> u32 {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() -> u32 {\\\"}\"}"
|
||||
input: []
|
||||
const_: false
|
||||
@ -22,22 +16,23 @@ outputs:
|
||||
statements:
|
||||
- Return:
|
||||
expression:
|
||||
TupleInit:
|
||||
elements: []
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 12
|
||||
col_stop: 14
|
||||
path: ""
|
||||
content: " return ();"
|
||||
Value:
|
||||
Implicit:
|
||||
- "0"
|
||||
- span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 12
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 4
|
||||
line_stop: 4
|
||||
col_start: 5
|
||||
col_stop: 14
|
||||
col_stop: 13
|
||||
path: ""
|
||||
content: " return ();"
|
||||
content: " return 0;"
|
||||
span:
|
||||
line_start: 3
|
||||
line_stop: 5
|
||||
|
@ -4,14 +4,8 @@ expectation: Pass
|
||||
outputs:
|
||||
- name: ""
|
||||
expected_input: []
|
||||
import_statements: []
|
||||
imports: {}
|
||||
aliases: {}
|
||||
circuits: {}
|
||||
global_consts: {}
|
||||
functions:
|
||||
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() -> (u32, u32) {\\\"}\"}":
|
||||
annotations: {}
|
||||
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() -> (u32, u32) {\\\"}\"}"
|
||||
input: []
|
||||
const_: false
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Parse
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370015]: \"test function...\" is deprecated. Did you mean @test annotation?\n --> test:3:1\n |\n 3 | test main() {}\n | ^^^^"
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Input
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370000]: main\n --> test:3:1\n |\n 3 | main\n | ^^^^"
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user