remove arrays

This commit is contained in:
gluax 2022-03-28 07:31:53 -07:00
parent 401c6a6d4d
commit ef4b3787a9
49 changed files with 122 additions and 4189 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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/>.
mod array_access;
pub use array_access::*;
mod array_range_access;
pub use array_range_access::*;
mod member_access;
pub use member_access::*;

View File

@ -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(", ")
),
}
}
}

View File

@ -14,9 +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 global_consts_json;
pub mod identifier;
@ -28,7 +25,4 @@ pub use imported_modules::*;
pub mod positive_number;
pub use positive_number::*;
pub mod spread_or_expression;
pub use spread_or_expression::*;
pub mod vec_tendril_json;

View File

@ -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),
}
}
}

View File

@ -20,10 +20,6 @@ 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`.
@ -35,8 +31,6 @@ impl fmt::Display for AccessExpression {
use AccessExpression::*;
match self {
Array(access) => access.fmt(f),
ArrayRange(access) => access.fmt(f),
Member(access) => access.fmt(f),
Tuple(access) => access.fmt(f),
}
@ -48,8 +42,6 @@ impl Node for AccessExpression {
use AccessExpression::*;
match &self {
Array(access) => access.span(),
ArrayRange(access) => access.span(),
Member(access) => access.span(),
Tuple(access) => access.span(),
}
@ -59,8 +51,6 @@ impl Node for AccessExpression {
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),
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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, GroupValue, Identifier, IntegerType, Node, SpreadOrExpression};
use crate::{GroupValue, Identifier, IntegerType, Node};
use leo_span::Span;
@ -29,10 +29,6 @@ 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 value;
@ -61,11 +57,6 @@ pub enum Expression {
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),
/// A call expression like `my_fun(args)`.
@ -84,8 +75,6 @@ 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(),
Call(n) => n.span(),
Cast(n) => n.span(),
@ -102,8 +91,6 @@ 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),
Call(n) => n.set_span(span),
Cast(n) => n.set_span(span),
@ -122,8 +109,6 @@ 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),
Call(n) => n.fmt(f),
Cast(n) => n.fmt(f),

View File

@ -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,7 +28,6 @@ pub enum InputValue {
Field(String),
Group(GroupValue),
Integer(IntegerType, String),
Array(Vec<InputValue>),
Tuple(Vec<InputValue>),
}
@ -56,62 +55,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);
@ -126,19 +74,6 @@ impl TryFrom<(Type, Expression)> for InputValue {
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,10 +88,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)

View File

@ -35,7 +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() {
@ -62,9 +61,6 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
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::Call(call) => Expression::Call(self.reduce_call(call)?),
@ -135,30 +131,6 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
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)?;
@ -181,8 +153,6 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
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)?),
};
@ -190,30 +160,6 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
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() {

View File

@ -121,34 +121,6 @@ pub trait ReconstructingReducer {
})
}
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,
@ -172,29 +144,6 @@ pub trait ReconstructingReducer {
})
}
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,

View File

@ -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,10 +36,6 @@ 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>),
@ -73,27 +69,6 @@ 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::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)
@ -113,7 +88,6 @@ 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::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(", ");
@ -123,21 +97,3 @@ impl fmt::Display for Type {
}
}
}
/// 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)
}
}

View File

@ -268,50 +268,8 @@ 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]) {
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 {
@ -357,20 +315,6 @@ impl ParserContext<'_> {
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
/// tuple initialization expression or an affine group literal.
@ -410,63 +354,6 @@ impl ParserContext<'_> {
}
}
///
/// 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,
}))
}
}
///
/// Returns an [`Expression`] AST node if the next token is a primary expression:
/// - Literals: field, group, unsigned integer, signed integer, boolean, address
@ -519,7 +406,6 @@ 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 };
Expression::Identifier(ident)

View File

@ -45,17 +45,6 @@ impl ParserContext<'_> {
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));
}
},
Expression::Identifier(id) => identifier = id,

View File

@ -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,31 +55,6 @@ 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)> {
@ -91,12 +64,6 @@ impl ParserContext<'_> {
} 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)?;
(

View File

@ -293,12 +293,8 @@ 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((1, Token::Dot));
}
Some(c) if c == &'/' => {

View File

@ -173,7 +173,6 @@ mod tests {
_
.
..
...
/
/=
:
@ -203,7 +202,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 string test true u128 u64 u32 u16 u8 console ! != && ( ) * ** **= *= + += , - -= -> _ . .. ... / /= : ; < <= = == > >= [ ] { { } } || ? // test
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 string test true u128 u64 u32 u16 u8 console ! != && ( ) * ** **= *= + += , - -= -> _ . .. / /= : ; < <= = == > >= [ ] { { } } || ? // test
/* test */ // "#
);
});

View File

@ -90,7 +90,6 @@ pub enum Token {
Comma,
Dot,
DotDot,
DotDotDot,
Semicolon,
Colon,
Question,
@ -270,7 +269,6 @@ impl fmt::Display for Token {
Comma => write!(f, ","),
Dot => write!(f, "."),
DotDot => write!(f, ".."),
DotDotDot => write!(f, "..."),
Semicolon => write!(f, ";"),
Colon => write!(f, ":"),
Question => write!(f, "?"),

View File

@ -87,36 +87,3 @@ outputs:
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)"

View File

@ -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]"

View File

@ -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 | ^"

View File

@ -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 | ^"

View File

@ -32,14 +32,14 @@ outputs:
- "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 [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"

View File

@ -126,92 +126,11 @@ outputs:
col_stop: 11
path: ""
content: "e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;"
- type_:
Array:
- IntegerType: U8
- - value: "32"
name: "{\"name\":\"f\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":1,\\\"col_stop\\\":2,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"f: [u8; 32] = [0; 32]; \\\"}\"}"
value:
ArrayInit:
element:
Value:
Implicit:
- "0"
- span:
line_start: 9
line_stop: 9
col_start: 16
col_stop: 17
path: ""
content: "f: [u8; 32] = [0; 32]; "
dimensions:
- value: "32"
span:
line_start: 9
line_stop: 9
col_start: 15
col_stop: 22
path: ""
content: "f: [u8; 32] = [0; 32]; "
span:
line_start: 9
line_stop: 9
col_start: 4
col_stop: 12
path: ""
content: "f: [u8; 32] = [0; 32]; "
- type_:
Array:
- Array:
- IntegerType: U8
- - value: "2"
- - value: "3"
name: "{\"name\":\"g\",\"span\":\"{\\\"line_start\\\":10,\\\"line_stop\\\":10,\\\"col_start\\\":1,\\\"col_stop\\\":2,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"g: [[u8; 2]; 3] = [[0; 2]; 3]; \\\"}\"}"
value:
ArrayInit:
element:
ArrayInit:
element:
Value:
Implicit:
- "0"
- span:
line_start: 10
line_stop: 10
col_start: 21
col_stop: 22
path: ""
content: "g: [[u8; 2]; 3] = [[0; 2]; 3]; "
dimensions:
- value: "2"
span:
line_start: 10
line_stop: 10
col_start: 20
col_stop: 26
path: ""
content: "g: [[u8; 2]; 3] = [[0; 2]; 3]; "
dimensions:
- value: "3"
span:
line_start: 10
line_stop: 10
col_start: 19
col_stop: 30
path: ""
content: "g: [[u8; 2]; 3] = [[0; 2]; 3]; "
span:
line_start: 10
line_stop: 10
col_start: 4
col_stop: 16
path: ""
content: "g: [[u8; 2]; 3] = [[0; 2]; 3]; "
- type_:
Tuple:
- Boolean
- Boolean
name: "{\"name\":\"h\",\"span\":\"{\\\"line_start\\\":11,\\\"line_stop\\\":11,\\\"col_start\\\":1,\\\"col_stop\\\":2,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"h: (bool, bool) = (true, false); \\\"}\"}"
name: "{\"name\":\"h\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":1,\\\"col_stop\\\":2,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"h: (bool, bool) = (true, false); \\\"}\"}"
value:
TupleInit:
elements:
@ -219,8 +138,8 @@ outputs:
Boolean:
- "true"
- span:
line_start: 11
line_stop: 11
line_start: 9
line_stop: 9
col_start: 20
col_stop: 24
path: ""
@ -229,22 +148,22 @@ outputs:
Boolean:
- "false"
- span:
line_start: 11
line_stop: 11
line_start: 9
line_stop: 9
col_start: 26
col_stop: 31
path: ""
content: "h: (bool, bool) = (true, false); "
span:
line_start: 11
line_stop: 11
line_start: 9
line_stop: 9
col_start: 19
col_stop: 32
path: ""
content: "h: (bool, bool) = (true, false); "
span:
line_start: 11
line_stop: 11
line_start: 9
line_stop: 9
col_start: 4
col_stop: 16
path: ""
@ -259,68 +178,68 @@ outputs:
- name: registers
definitions:
- type_: Boolean
name: "{\"name\":\"r0\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r0: bool = true; \\\"}\"}"
name: "{\"name\":\"r0\",\"span\":\"{\\\"line_start\\\":12,\\\"line_stop\\\":12,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r0: bool = true; \\\"}\"}"
value:
Value:
Boolean:
- "true"
- span:
line_start: 14
line_stop: 14
line_start: 12
line_stop: 12
col_start: 13
col_stop: 17
path: ""
content: "r0: bool = true; "
span:
line_start: 14
line_stop: 14
line_start: 12
line_stop: 12
col_start: 5
col_stop: 9
path: ""
content: "r0: bool = true; "
- type_:
IntegerType: U8
name: "{\"name\":\"r1\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r1: u8 = 2; \\\"}\"}"
name: "{\"name\":\"r1\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r1: u8 = 2; \\\"}\"}"
value:
Value:
Implicit:
- "2"
- span:
line_start: 15
line_stop: 15
line_start: 13
line_stop: 13
col_start: 13
col_stop: 14
path: ""
content: "r1: u8 = 2; "
span:
line_start: 15
line_stop: 15
line_start: 13
line_stop: 13
col_start: 5
col_stop: 7
path: ""
content: "r1: u8 = 2; "
- type_: Field
name: "{\"name\":\"r2\",\"span\":\"{\\\"line_start\\\":16,\\\"line_stop\\\":16,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r2: field = 0; \\\"}\"}"
name: "{\"name\":\"r2\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r2: field = 0; \\\"}\"}"
value:
Value:
Implicit:
- "0"
- span:
line_start: 16
line_stop: 16
line_start: 14
line_stop: 14
col_start: 13
col_stop: 14
path: ""
content: "r2: field = 0; "
span:
line_start: 16
line_stop: 16
line_start: 14
line_stop: 14
col_start: 5
col_stop: 10
path: ""
content: "r2: field = 0; "
- type_: Group
name: "{\"name\":\"r3\",\"span\":\"{\\\"line_start\\\":17,\\\"line_stop\\\":17,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r3: group = (0, 1)group; \\\"}\"}"
name: "{\"name\":\"r3\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r3: group = (0, 1)group; \\\"}\"}"
value:
Value:
Group:
@ -329,8 +248,8 @@ outputs:
Number:
- "0"
- span:
line_start: 17
line_stop: 17
line_start: 15
line_stop: 15
col_start: 14
col_stop: 15
path: ""
@ -339,132 +258,51 @@ outputs:
Number:
- "1"
- span:
line_start: 17
line_stop: 17
line_start: 15
line_stop: 15
col_start: 17
col_stop: 18
path: ""
content: "r3: group = (0, 1)group; "
span:
line_start: 17
line_stop: 17
line_start: 15
line_stop: 15
col_start: 14
col_stop: 24
path: ""
content: "r3: group = (0, 1)group; "
span:
line_start: 17
line_stop: 17
line_start: 15
line_stop: 15
col_start: 5
col_stop: 10
path: ""
content: "r3: group = (0, 1)group; "
- type_: Address
name: "{\"name\":\"r4\",\"span\":\"{\\\"line_start\\\":18,\\\"line_stop\\\":18,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;\\\"}\"}"
name: "{\"name\":\"r4\",\"span\":\"{\\\"line_start\\\":16,\\\"line_stop\\\":16,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;\\\"}\"}"
value:
Value:
Address:
- aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8
- span:
line_start: 18
line_stop: 18
line_start: 16
line_stop: 16
col_start: 15
col_stop: 78
path: ""
content: "r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;"
span:
line_start: 18
line_stop: 18
line_start: 16
line_stop: 16
col_start: 5
col_stop: 12
path: ""
content: "r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;"
- type_:
Array:
- IntegerType: U8
- - value: "32"
name: "{\"name\":\"r5\",\"span\":\"{\\\"line_start\\\":19,\\\"line_stop\\\":19,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r5: [u8; 32] = [0; 32]; \\\"}\"}"
value:
ArrayInit:
element:
Value:
Implicit:
- "0"
- span:
line_start: 19
line_stop: 19
col_start: 17
col_stop: 18
path: ""
content: "r5: [u8; 32] = [0; 32]; "
dimensions:
- value: "32"
span:
line_start: 19
line_stop: 19
col_start: 16
col_stop: 23
path: ""
content: "r5: [u8; 32] = [0; 32]; "
span:
line_start: 19
line_stop: 19
col_start: 5
col_stop: 13
path: ""
content: "r5: [u8; 32] = [0; 32]; "
- type_:
Array:
- Array:
- IntegerType: U8
- - value: "2"
- - value: "3"
name: "{\"name\":\"r6\",\"span\":\"{\\\"line_start\\\":20,\\\"line_stop\\\":20,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r6: [[u8; 2]; 3] = [[0; 2]; 3]; \\\"}\"}"
value:
ArrayInit:
element:
ArrayInit:
element:
Value:
Implicit:
- "0"
- span:
line_start: 20
line_stop: 20
col_start: 22
col_stop: 23
path: ""
content: "r6: [[u8; 2]; 3] = [[0; 2]; 3]; "
dimensions:
- value: "2"
span:
line_start: 20
line_stop: 20
col_start: 21
col_stop: 27
path: ""
content: "r6: [[u8; 2]; 3] = [[0; 2]; 3]; "
dimensions:
- value: "3"
span:
line_start: 20
line_stop: 20
col_start: 20
col_stop: 31
path: ""
content: "r6: [[u8; 2]; 3] = [[0; 2]; 3]; "
span:
line_start: 20
line_stop: 20
col_start: 5
col_stop: 17
path: ""
content: "r6: [[u8; 2]; 3] = [[0; 2]; 3]; "
- type_:
Tuple:
- Boolean
- Boolean
name: "{\"name\":\"r7\",\"span\":\"{\\\"line_start\\\":21,\\\"line_stop\\\":21,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r7: (bool, bool) = (true, false); \\\"}\"}"
name: "{\"name\":\"r7\",\"span\":\"{\\\"line_start\\\":17,\\\"line_stop\\\":17,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r7: (bool, bool) = (true, false); \\\"}\"}"
value:
TupleInit:
elements:
@ -472,8 +310,8 @@ outputs:
Boolean:
- "true"
- span:
line_start: 21
line_stop: 21
line_start: 17
line_stop: 17
col_start: 21
col_stop: 25
path: ""
@ -482,29 +320,29 @@ outputs:
Boolean:
- "false"
- span:
line_start: 21
line_stop: 21
line_start: 17
line_stop: 17
col_start: 27
col_stop: 32
path: ""
content: "r7: (bool, bool) = (true, false); "
span:
line_start: 21
line_stop: 21
line_start: 17
line_stop: 17
col_start: 20
col_stop: 33
path: ""
content: "r7: (bool, bool) = (true, false); "
span:
line_start: 21
line_stop: 21
line_start: 17
line_stop: 17
col_start: 5
col_stop: 17
path: ""
content: "r7: (bool, bool) = (true, false); "
span:
line_start: 13
line_stop: 13
line_start: 11
line_stop: 11
col_start: 2
col_stop: 11
path: ""
@ -512,68 +350,68 @@ outputs:
- name: constants
definitions:
- type_: Boolean
name: "{\"name\":\"c0\",\"span\":\"{\\\"line_start\\\":24,\\\"line_stop\\\":24,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c0: bool = true; \\\"}\"}"
name: "{\"name\":\"c0\",\"span\":\"{\\\"line_start\\\":20,\\\"line_stop\\\":20,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c0: bool = true; \\\"}\"}"
value:
Value:
Boolean:
- "true"
- span:
line_start: 24
line_stop: 24
line_start: 20
line_stop: 20
col_start: 13
col_stop: 17
path: ""
content: "c0: bool = true; "
span:
line_start: 24
line_stop: 24
line_start: 20
line_stop: 20
col_start: 5
col_stop: 9
path: ""
content: "c0: bool = true; "
- type_:
IntegerType: U8
name: "{\"name\":\"c1\",\"span\":\"{\\\"line_start\\\":25,\\\"line_stop\\\":25,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c1: u8 = 2; \\\"}\"}"
name: "{\"name\":\"c1\",\"span\":\"{\\\"line_start\\\":21,\\\"line_stop\\\":21,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c1: u8 = 2; \\\"}\"}"
value:
Value:
Implicit:
- "2"
- span:
line_start: 25
line_stop: 25
line_start: 21
line_stop: 21
col_start: 13
col_stop: 14
path: ""
content: "c1: u8 = 2; "
span:
line_start: 25
line_stop: 25
line_start: 21
line_stop: 21
col_start: 5
col_stop: 7
path: ""
content: "c1: u8 = 2; "
- type_: Field
name: "{\"name\":\"c2\",\"span\":\"{\\\"line_start\\\":26,\\\"line_stop\\\":26,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c2: field = 0; \\\"}\"}"
name: "{\"name\":\"c2\",\"span\":\"{\\\"line_start\\\":22,\\\"line_stop\\\":22,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c2: field = 0; \\\"}\"}"
value:
Value:
Implicit:
- "0"
- span:
line_start: 26
line_stop: 26
line_start: 22
line_stop: 22
col_start: 13
col_stop: 14
path: ""
content: "c2: field = 0; "
span:
line_start: 26
line_stop: 26
line_start: 22
line_stop: 22
col_start: 5
col_stop: 10
path: ""
content: "c2: field = 0; "
- type_: Group
name: "{\"name\":\"c3\",\"span\":\"{\\\"line_start\\\":27,\\\"line_stop\\\":27,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c3: group = (0, 1)group; \\\"}\"}"
name: "{\"name\":\"c3\",\"span\":\"{\\\"line_start\\\":23,\\\"line_stop\\\":23,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c3: group = (0, 1)group; \\\"}\"}"
value:
Value:
Group:
@ -582,8 +420,8 @@ outputs:
Number:
- "0"
- span:
line_start: 27
line_stop: 27
line_start: 23
line_stop: 23
col_start: 14
col_stop: 15
path: ""
@ -592,132 +430,51 @@ outputs:
Number:
- "1"
- span:
line_start: 27
line_stop: 27
line_start: 23
line_stop: 23
col_start: 17
col_stop: 18
path: ""
content: "c3: group = (0, 1)group; "
span:
line_start: 27
line_stop: 27
line_start: 23
line_stop: 23
col_start: 14
col_stop: 24
path: ""
content: "c3: group = (0, 1)group; "
span:
line_start: 27
line_stop: 27
line_start: 23
line_stop: 23
col_start: 5
col_stop: 10
path: ""
content: "c3: group = (0, 1)group; "
- type_: Address
name: "{\"name\":\"c4\",\"span\":\"{\\\"line_start\\\":28,\\\"line_stop\\\":28,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;\\\"}\"}"
name: "{\"name\":\"c4\",\"span\":\"{\\\"line_start\\\":24,\\\"line_stop\\\":24,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;\\\"}\"}"
value:
Value:
Address:
- aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8
- span:
line_start: 28
line_stop: 28
line_start: 24
line_stop: 24
col_start: 15
col_stop: 78
path: ""
content: "c4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;"
span:
line_start: 28
line_stop: 28
line_start: 24
line_stop: 24
col_start: 5
col_stop: 12
path: ""
content: "c4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;"
- type_:
Array:
- IntegerType: U8
- - value: "32"
name: "{\"name\":\"c5\",\"span\":\"{\\\"line_start\\\":29,\\\"line_stop\\\":29,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c5: [u8; 32] = [0; 32]; \\\"}\"}"
value:
ArrayInit:
element:
Value:
Implicit:
- "0"
- span:
line_start: 29
line_stop: 29
col_start: 17
col_stop: 18
path: ""
content: "c5: [u8; 32] = [0; 32]; "
dimensions:
- value: "32"
span:
line_start: 29
line_stop: 29
col_start: 16
col_stop: 23
path: ""
content: "c5: [u8; 32] = [0; 32]; "
span:
line_start: 29
line_stop: 29
col_start: 5
col_stop: 13
path: ""
content: "c5: [u8; 32] = [0; 32]; "
- type_:
Array:
- Array:
- IntegerType: U8
- - value: "2"
- - value: "3"
name: "{\"name\":\"c6\",\"span\":\"{\\\"line_start\\\":30,\\\"line_stop\\\":30,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c6: [[u8; 2]; 3] = [[0; 2]; 3]; \\\"}\"}"
value:
ArrayInit:
element:
ArrayInit:
element:
Value:
Implicit:
- "0"
- span:
line_start: 30
line_stop: 30
col_start: 22
col_stop: 23
path: ""
content: "c6: [[u8; 2]; 3] = [[0; 2]; 3]; "
dimensions:
- value: "2"
span:
line_start: 30
line_stop: 30
col_start: 21
col_stop: 27
path: ""
content: "c6: [[u8; 2]; 3] = [[0; 2]; 3]; "
dimensions:
- value: "3"
span:
line_start: 30
line_stop: 30
col_start: 20
col_stop: 31
path: ""
content: "c6: [[u8; 2]; 3] = [[0; 2]; 3]; "
span:
line_start: 30
line_stop: 30
col_start: 5
col_stop: 17
path: ""
content: "c6: [[u8; 2]; 3] = [[0; 2]; 3]; "
- type_:
Tuple:
- Boolean
- Boolean
name: "{\"name\":\"c7\",\"span\":\"{\\\"line_start\\\":31,\\\"line_stop\\\":31,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c7: (bool, bool) = (true, false); \\\"}\"}"
name: "{\"name\":\"c7\",\"span\":\"{\\\"line_start\\\":25,\\\"line_stop\\\":25,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"c7: (bool, bool) = (true, false); \\\"}\"}"
value:
TupleInit:
elements:
@ -725,8 +482,8 @@ outputs:
Boolean:
- "true"
- span:
line_start: 31
line_stop: 31
line_start: 25
line_stop: 25
col_start: 21
col_stop: 25
path: ""
@ -735,29 +492,29 @@ outputs:
Boolean:
- "false"
- span:
line_start: 31
line_stop: 31
line_start: 25
line_stop: 25
col_start: 27
col_stop: 32
path: ""
content: "c7: (bool, bool) = (true, false); "
span:
line_start: 31
line_stop: 31
line_start: 25
line_stop: 25
col_start: 20
col_stop: 33
path: ""
content: "c7: (bool, bool) = (true, false); "
span:
line_start: 31
line_stop: 31
line_start: 25
line_stop: 25
col_start: 5
col_stop: 17
path: ""
content: "c7: (bool, bool) = (true, false); "
span:
line_start: 23
line_stop: 23
line_start: 19
line_stop: 19
col_start: 2
col_stop: 11
path: ""

View File

@ -40,18 +40,5 @@ outputs:
content: type c = a;
represents:
Identifier: "{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"type c = a;\\\"}\"}"
"{\"name\":\"b\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":6,\\\"col_stop\\\":7,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"type b = [u8; 5];\\\"}\"}":
name: "{\"name\":\"b\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":6,\\\"col_stop\\\":7,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"type b = [u8; 5];\\\"}\"}"
span:
line_start: 9
line_stop: 9
col_start: 1
col_stop: 18
path: ""
content: "type b = [u8; 5];"
represents:
Array:
- IntegerType: U8
- - value: "5"
global_consts: {}
functions: {}

File diff suppressed because it is too large Load Diff

View File

@ -9,8 +9,8 @@ outputs:
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | !x = y;\n | ^^"
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | a? x : x = y;\n | ^^^^^^^^"
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | x as u32 = y;\n | ^^^^^^^^"
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | [x, x, x] = y;\n | ^^^^^^^^^"
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | [x; 3] = y;\n | ^^^^^^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [x, x, x] = y;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [x; 3] = y;\n | ^"
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | (x, x, x) = y;\n | ^^^^^^^^^"
- "Error [EPAR0370005]: expected ; -- got '{'\n --> test:1:3\n |\n 1 | x {x: y, y: z} = y;\n | ^"
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | x() = y;\n | ^^^"

View File

@ -1441,203 +1441,6 @@ outputs:
col_stop: 16
path: ""
content: "let (x,y,) = ();"
- Definition:
declaration_type: Let
variable_names:
- mutable: true
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":5,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"let x: [[u8; 2]; 2] = [[0,0], [0,0]];\\\"}\"}"
span:
line_start: 1
line_stop: 1
col_start: 5
col_stop: 6
path: ""
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
type_:
Array:
- Array:
- IntegerType: U8
- - value: "2"
- - value: "2"
value:
ArrayInline:
elements:
- Expression:
ArrayInline:
elements:
- Expression:
Value:
Implicit:
- "0"
- span:
line_start: 1
line_stop: 1
col_start: 25
col_stop: 26
path: ""
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
- Expression:
Value:
Implicit:
- "0"
- span:
line_start: 1
line_stop: 1
col_start: 27
col_stop: 28
path: ""
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
span:
line_start: 1
line_stop: 1
col_start: 24
col_stop: 29
path: ""
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
- Expression:
ArrayInline:
elements:
- Expression:
Value:
Implicit:
- "0"
- span:
line_start: 1
line_stop: 1
col_start: 32
col_stop: 33
path: ""
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
- Expression:
Value:
Implicit:
- "0"
- span:
line_start: 1
line_stop: 1
col_start: 34
col_stop: 35
path: ""
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
span:
line_start: 1
line_stop: 1
col_start: 31
col_stop: 36
path: ""
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
span:
line_start: 1
line_stop: 1
col_start: 23
col_stop: 37
path: ""
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 37
path: ""
content: "let x: [[u8; 2]; 2] = [[0,0], [0,0]];"
- Definition:
declaration_type: Let
variable_names:
- mutable: true
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":5,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"let x: [u8; (2, 2)] = [[0,0], [0,0]];\\\"}\"}"
span:
line_start: 1
line_stop: 1
col_start: 5
col_stop: 6
path: ""
content: "let x: [u8; (2, 2)] = [[0,0], [0,0]];"
type_:
Array:
- IntegerType: U8
- - value: "2"
- value: "2"
value:
ArrayInline:
elements:
- Expression:
ArrayInline:
elements:
- Expression:
Value:
Implicit:
- "0"
- span:
line_start: 1
line_stop: 1
col_start: 25
col_stop: 26
path: ""
content: "let x: [u8; (2, 2)] = [[0,0], [0,0]];"
- Expression:
Value:
Implicit:
- "0"
- span:
line_start: 1
line_stop: 1
col_start: 27
col_stop: 28
path: ""
content: "let x: [u8; (2, 2)] = [[0,0], [0,0]];"
span:
line_start: 1
line_stop: 1
col_start: 24
col_stop: 29
path: ""
content: "let x: [u8; (2, 2)] = [[0,0], [0,0]];"
- Expression:
ArrayInline:
elements:
- Expression:
Value:
Implicit:
- "0"
- span:
line_start: 1
line_stop: 1
col_start: 32
col_stop: 33
path: ""
content: "let x: [u8; (2, 2)] = [[0,0], [0,0]];"
- Expression:
Value:
Implicit:
- "0"
- span:
line_start: 1
line_stop: 1
col_start: 34
col_stop: 35
path: ""
content: "let x: [u8; (2, 2)] = [[0,0], [0,0]];"
span:
line_start: 1
line_stop: 1
col_start: 31
col_stop: 36
path: ""
content: "let x: [u8; (2, 2)] = [[0,0], [0,0]];"
span:
line_start: 1
line_stop: 1
col_start: 23
col_stop: 37
path: ""
content: "let x: [u8; (2, 2)] = [[0,0], [0,0]];"
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 37
path: ""
content: "let x: [u8; (2, 2)] = [[0,0], [0,0]];"
- Definition:
declaration_type: Let
variable_names:

View File

@ -25,7 +25,7 @@ outputs:
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:10\n |\n 1 | let (x,y,,) = ();\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:6\n |\n 1 | let (,x,y) = ();\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'ident', got ','\n --> test:1:8\n |\n 1 | let (x,,y) = ();\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'int', got ','\n --> test:1:16\n |\n 1 | let x: [u8; (2,,)] = [[0,0], [0,0]];\n | ^\nError [EPAR0370039]: do not put parens around single dimension array size\n --> test:1:13\n |\n 1 | let x: [u8; (2,,)] = [[0,0], [0,0]];\n | ^^^^^"
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool', 'char' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8; (2,,)] = [[0,0], [0,0]];\n | ^"
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool', 'char' -- got 'const'\n --> test:1:8\n |\n 1 | let x: const = expr;\n | ^^^^^"
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool', 'char' -- got 'let'\n --> test:1:10\n |\n 1 | const x: let = expr;\n | ^^^"
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool', 'char' -- got 'mut'\n --> test:1:8\n |\n 1 | let x: mut = expr;\n | ^^^"
@ -39,10 +39,10 @@ outputs:
- "Error [EPAR0370005]: expected = -- got ';'\n --> test:1:10\n |\n 1 | let x: u8;\n | ^"
- "Error [EPAR0370003]: unexpected EOF\n --> test:1:8\n |\n 1 | let x: u8\n | ^^"
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool', 'char' -- got '='\n --> test:1:8\n |\n 1 | let x: = 1;\n | ^"
- "Error [EPAR0370005]: expected ; -- got ']'\n --> test:1:11\n |\n 1 | let x: [u8] = 1;\n | ^"
- "Error [EPAR0370003]: unexpected EOF\n --> test:1:11\n |\n 1 | let x: [u8;\n | ^"
- "Error [EPAR0370005]: expected ] -- got 'u8'\n --> test:1:14\n |\n 1 | let x: [u8; 1u8] = [1,\n | ^^"
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool', 'char' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8] = 1;\n | ^"
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool', 'char' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8;\n | ^"
- "Error [EPAR0370005]: expected 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'field', 'group', 'address', 'bool', 'char' -- got '['\n --> test:1:8\n |\n 1 | let x: [u8; 1u8] = [1,\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ']'\n --> test:1:15\n |\n 1 | let dbg: u8 = ];\n | ^"
- "Error [EPAR0370030]: Could not lex the following content: `🦀: u8 = 0;`."
- "Error [EPAR0370038]: do not put parens around single variable names\n --> test:1:6\n |\n 1 | let (x) = ...;\n | ^\nError [EPAR0370009]: unexpected string: expected 'expression', got '...'\n --> test:1:11\n |\n 1 | let (x) = ...;\n | ^^^"
- "Error [EPAR0370038]: do not put parens around single variable names\n --> test:1:6\n |\n 1 | let (x,) = ...;\n | ^\nError [EPAR0370009]: unexpected string: expected 'expression', got '...'\n --> test:1:12\n |\n 1 | let (x,) = ...;\n | ^^^"
- "Error [EPAR0370038]: do not put parens around single variable names\n --> test:1:6\n |\n 1 | let (x) = ...;\n | ^\nError [EPAR0370009]: unexpected string: expected 'expression', got '..'\n --> test:1:11\n |\n 1 | let (x) = ...;\n | ^^"
- "Error [EPAR0370038]: do not put parens around single variable names\n --> test:1:6\n |\n 1 | let (x,) = ...;\n | ^\nError [EPAR0370009]: unexpected string: expected 'expression', got '..'\n --> test:1:12\n |\n 1 | let (x,) = ...;\n | ^^"

View File

@ -3,8 +3,8 @@ namespace: ParseStatement
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:1\n |\n 1 | [);\n | ^"
- "Error [EPAR0370030]: Could not lex the following content: `\\y;`."
- "Error [EPAR0370040]: Found the char `;`, but expected `|`"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '}'\n --> test:1:3\n |\n 1 | x[};\n | ^"
- "Error [EPAR0370005]: expected ; -- got '['\n --> test:1:2\n |\n 1 | x[};\n | ^"
- "Error [EPAR0370005]: expected ) -- got ']'\n --> test:1:6\n |\n 1 | (x, y];\n | ^"

View File

@ -6,7 +6,7 @@ outputs:
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '.'\n --> test:1:1\n |\n 1 | . x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'import'\n --> test:1:1\n |\n 1 | import x = 10u8;\n | ^^^^^^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ','\n --> test:1:1\n |\n 1 | , x = 10u8;\n | ^"
- "Error [EPAR0370005]: expected , -- got '='\n --> test:1:5\n |\n 1 | [ x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [ x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ']'\n --> test:1:1\n |\n 1 | ] x = 10u8;\n | ^"
- "Error [EPAR0370003]: unexpected EOF\n --> test:1:11\n |\n 1 | { x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '}'\n --> test:1:1\n |\n 1 | } x = 10u8;\n | ^"

View File

@ -5,7 +5,7 @@ outputs:
- "did not consume all input: 'b' @ 1:13-14\n';' @ 1:14-15\n"
- "Error [EPAR0370005]: expected ; -- got 'import'\n --> test:1:11\n |\n 1 | let x = a import b;\n | ^^^^^^"
- "Error [EPAR0370005]: expected ; -- got ','\n --> test:1:11\n |\n 1 | let x = a , b;\n | ^"
- "Error [EPAR0370005]: expected ] -- got ';'\n --> test:1:14\n |\n 1 | let x = a [ b;\n | ^"
- "Error [EPAR0370005]: expected ; -- got '['\n --> test:1:11\n |\n 1 | let x = a [ b;\n | ^"
- "Error [EPAR0370005]: expected ; -- got ']'\n --> test:1:11\n |\n 1 | let x = a ] b;\n | ^"
- "Error [EPAR0370005]: expected ; -- got '{'\n --> test:1:11\n |\n 1 | let x = a { b;\n | ^"
- "Error [EPAR0370005]: expected ; -- got '}'\n --> test:1:11\n |\n 1 | let x = a } b;\n | ^"
@ -43,7 +43,7 @@ outputs:
- "did not consume all input: '=' @ 1:3-4\n'b' @ 1:4-5\n';' @ 1:5-6\n"
- "Error [EPAR0370009]: unexpected string: expected 'int or ident', got '='\n --> test:1:3\n |\n 1 | x.=b;\n | ^"
- "Error [EPAR0370005]: expected ; -- got ','\n --> test:1:2\n |\n 1 | x,=b; // 43\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '='\n --> test:1:3\n |\n 1 | x[=b;\n | ^"
- "Error [EPAR0370005]: expected ; -- got '['\n --> test:1:2\n |\n 1 | x[=b;\n | ^"
- "Error [EPAR0370005]: expected ; -- got ']'\n --> test:1:2\n |\n 1 | x]=b;\n | ^"
- "Error [EPAR0370005]: expected ; -- got '{'\n --> test:1:2\n |\n 1 | x{=b;\n | ^"
- "Error [EPAR0370005]: expected ; -- got '}'\n --> test:1:2\n |\n 1 | x}=b;\n | ^"

View File

@ -5,7 +5,7 @@ outputs:
- "did not consume all input: ';' @ 1:11-12\n"
- "Error [EPAR0370009]: unexpected string: expected 'int or ident', got ';'\n --> test:1:11\n |\n 1 | let x = a.;\n | ^"
- "Error [EPAR0370005]: expected ; -- got ','\n --> test:1:10\n |\n 1 | let x = a,;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ';'\n --> test:1:11\n |\n 1 | let x = a[;\n | ^"
- "Error [EPAR0370005]: expected ; -- got '['\n --> test:1:10\n |\n 1 | let x = a[;\n | ^"
- "Error [EPAR0370005]: expected ; -- got ']'\n --> test:1:10\n |\n 1 | let x = a];\n | ^"
- "Error [EPAR0370005]: expected ; -- got '{'\n --> test:1:10\n |\n 1 | let x = a{;\n | ^"
- "Error [EPAR0370005]: expected ; -- got '}'\n --> test:1:10\n |\n 1 | let x = a};\n | ^"

View File

@ -1,13 +0,0 @@
/*
namespace: ParseExpression
expectation: Pass
*/
x[0]
X[1]
x[0u8]
x[1u8][2u8]
x[x][y][z]
x[0]()
x()[0]
x[x].0[x]

View File

@ -1,22 +0,0 @@
/*
namespace: ParseExpression
expectation: Pass
*/
x[..]
x[1..]
x[..1]
x[1..1]
x[0..100]
x[323452345.2345234523453453][323452345.2345234523453453]
x[0u8..1u8]
x[0u8..]
x[..0u8]
x[..]
x[x.y..]
x[..y.x]
x[x.y..y.x]
x[x.y.x..y.x.y]

View File

@ -9,4 +9,3 @@ x(y)
x(y, z)
x(x, y, z)
x.0(x)
x[0](x)

View File

@ -8,4 +8,3 @@ X.Y
x.y.z
x.y()
x.y.0
x.y[1]

View File

@ -1,16 +0,0 @@
/*
namespace: ParseExpression
expectation: Pass
*/
[0u8; 1]
[0; 1]
[0; (1, 2)]
[0; (1, 2,)]
[0; (1, 2, 3)]
[[[0; 3]; 2]; 1]

View File

@ -1,24 +0,0 @@
/*
namespace: ParseExpression
expectation: Pass
*/
[0u8, 1, 2, 3]
[1]
[1u8]
[1u8,]
[0, 1,]
[0,1,]
[]
[[1,2,3],[1,2,3]]
[[]]
[[], []]

View File

@ -1,14 +0,0 @@
/*
namespace: ParseExpression
expectation: Pass
*/
[0u8; 1].len()
[0; 1].len()
[0; (1, 2)].len()
[0; (1, 2, 3)].len()
[[[0; 3]; 2]; 1].len()

View File

@ -1,8 +0,0 @@
/*
namespace: Parse
expectation: Pass
*/
function x(x: [u8; 12]) {
return ();
}

View File

@ -1,8 +0,0 @@
/*
namespace: Parse
expectation: Pass
*/
function x(x: MyCircuit) {
return ();
}

View File

@ -9,8 +9,6 @@ b: u8 = 2;
c: field = 0;
d: group = (0, 1)group;
e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
f: [u8; 32] = [0; 32];
g: [[u8; 2]; 3] = [[0; 2]; 3];
h: (bool, bool) = (true, false);
[registers]
@ -19,8 +17,6 @@ r1: u8 = 2;
r2: field = 0;
r3: group = (0, 1)group;
r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
r5: [u8; 32] = [0; 32];
r6: [[u8; 2]; 3] = [[0; 2]; 3];
r7: (bool, bool) = (true, false);
[constants]
@ -29,6 +25,4 @@ c1: u8 = 2;
c2: field = 0;
c3: group = (0, 1)group;
c4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
c5: [u8; 32] = [0; 32];
c6: [[u8; 2]; 3] = [[0; 2]; 3];
c7: (bool, bool) = (true, false);

View File

@ -1,63 +0,0 @@
/*
namespace: Serialize
expectation: Pass
*/
// This Program takes in any 20-byte low register string and tells
// whether a string is a palindrome ignoring any spaces.
function main(str: [char; 20]) -> bool {
return is_palindrome(str);
}
function is_palindrome(str: [char; 20]) -> bool {
const str_len = 20u32; // saving const for convenience
// By default we assume that input is a palindrome.
let result = true;
let processed = 0u8;
for start in 0..(str_len / 2) {
let start_sym = str[start];
if start_sym != ' ' {
let skipped = 0u8;
let end_empty = 0u8;
let end_sym = ' ';
for end in (str_len - 1)..start {
if str[end] != ' ' && skipped == processed && end_sym == ' ' {
end_sym = str[end];
} else {
end_empty = end_empty + 1;
if str[end] != ' ' {
skipped = skipped + 1;
}
}
}
// If there are symbols left to the right from the start.
if end_sym != ' ' {
console.log("Comparing: {} ? {}", start_sym, end_sym);
if result {
result = (start_sym == end_sym);
}
processed = processed + 1;
}
}
}
console.log("Result is: {}", result);
return result;
}
function test_is_palindrome() {
console.assert(is_palindrome("a b a "));
console.assert(is_palindrome("😀😀😀😀😀 😀😀😀😀😀"));
console.assert(is_palindrome("borrow or rob "));
console.assert(is_palindrome("bbbb aaaa aaaa bbbb"));
console.assert(is_palindrome("aaaaaaaaaaaaaaaaaaaa"));
console.assert(is_palindrome("taco cat "));
}

View File

@ -8,5 +8,3 @@ type a = u32;
type b = string;
type c = a;
type b = [u8; 5];

View File

@ -13,29 +13,8 @@ x = (x,y);
x = x();
x[0] = y;
x[0u32] = y;
x.0 = y;
x[1..2] = y;
x[..2] = y;
x[2..] = y;
x[..] = y;
x.0[0][..] = y;
x.y = y;
x.0.y[0].1.y[..][0][1..5][0..3] = y;
x += expr;
x += ();
@ -44,29 +23,10 @@ x += x+y;
x += x();
x[0] += y;
x[0u32] += y;
x.0 += y;
x[1..2][0] += y;
x[..2][0] += y;
x[2..][0] += y;
x[..][0] += y;
x.0[0][..][0] += y;
x.y += y;
x.0.y[0].1.y[..][0][1..5][0..3][0] += y;
x -= expr;
x -= ();
@ -75,29 +35,8 @@ x -= x+y;
x -= x();
x[0] -= y;
x[0u32] -= y;
x.0 -= y;
x[1..2][0] -= y;
x[..2][0] -= y;
x[2..][0] -= y;
x[..][0] -= y;
x.0[0][..][0] -= y;
x.y -= y;
x.0.y[0].1.y[..][0][1..5][0..3][0] -= y;
x *= expr;
x *= ();
@ -106,28 +45,10 @@ x *= x+y;
x *= x();
x[0] *= y;
x[0u32] *= y;
x.0 *= y;
x[1..2][0] *= y;
x[..2][0] *= y;
x[2..][0] *= y;
x[..][0] *= y;
x.0[0][..][0] *= y;
x.y *= y;
x.0.y[0].1.y[..][0][1..5][0..3][0] *= y;
x /= expr;
@ -137,28 +58,10 @@ x /= x+y;
x /= x();
x[0] /= y;
x[0u32] /= y;
x.0 /= y;
x[1..2][0] /= y;
x[..2][0] /= y;
x[2..][0] /= y;
x[..][0] /= y;
x.0[0][..][0] /= y;
x.y /= y;
x.0.y[0].1.y[..][0][1..5][0..3][0] /= y;
x **= expr;
@ -169,22 +72,7 @@ x **= x+y;
x **= x();
x[0] *= y;
x[0u32] *= y;
x.0 **= y;
x[1..2][0] **= y;
x[..2][0] **= y;
x[2..][0] **= y;
x[..][0] **= y;
x.0[0][..][0] **= y;
x.y **= y;
x.0.y[0].1.y[..][0][1..5][0..3][0] **= y;

View File

@ -97,9 +97,4 @@ const (x, y): u32 = x();
let (x,y,) = ();
let x: [[u8; 2]; 2] = [[0,0], [0,0]];
let x: [u8; (2, 2)] = [[0,0], [0,0]];
let x: address = aleo15u4r0gzjtqzepkgurgn7p3u5kkhs9p74rx6aun3uh2s5std6759svgmg53;