diff --git a/ast/src/leo.pest b/ast/src/leo.pest
index dc350cd0f4..22e20cfb97 100644
--- a/ast/src/leo.pest
+++ b/ast/src/leo.pest
@@ -194,7 +194,29 @@ type_self = { "Self" }
type_circuit = { identifier }
// Declared in types/array_type.rs
-type_array = { type_data ~ ("[" ~ number_positive ~ "]")+ }
+type_array = { "[" ~ array_element ~ ";" ~ array_dimensions ~ "]" }
+
+// Declared in types/array_element.rs
+array_element = {
+ type_self
+ | type_tuple
+ | type_data
+ | type_circuit
+}
+
+// Declared in types/array_dimensions.rs
+array_dimensions = {
+ dimension_single
+ | dimension_multiple
+}
+
+// Declared in types/array_dimensions.rs
+dimension_single = {
+ number_positive
+}
+
+// Declared in types/array_dimensions.rs
+dimension_multiple = { "(" ~ number_positive ~ ("," ~ number_positive)* ~ ")"}
type_tuple = { "(" ~ NEWLINE* ~ type_ ~ ("," ~ NEWLINE* ~ type_)+ ~ ","? ~ NEWLINE* ~ ")" }
diff --git a/ast/src/types/array_dimensions.rs b/ast/src/types/array_dimensions.rs
new file mode 100644
index 0000000000..f75f141a15
--- /dev/null
+++ b/ast/src/types/array_dimensions.rs
@@ -0,0 +1,46 @@
+// Copyright (C) 2019-2020 Aleo Systems Inc.
+// This file is part of the Leo library.
+
+// The Leo library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// The Leo library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with the Leo library. If not, see .
+
+use crate::{ast::Rule, values::PositiveNumber, SpanDef};
+
+use pest::Span;
+use pest_ast::FromPest;
+use serde::Serialize;
+
+#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
+#[pest_ast(rule(Rule::array_dimensions))]
+pub enum ArrayDimensions<'ast> {
+ Single(Single<'ast>),
+ Multiple(Multiple<'ast>),
+}
+
+#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
+#[pest_ast(rule(Rule::dimension_single))]
+pub struct Single<'ast> {
+ pub number: PositiveNumber<'ast>,
+ #[pest_ast(outer())]
+ #[serde(with = "SpanDef")]
+ pub span: Span<'ast>,
+}
+
+#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
+#[pest_ast(rule(Rule::dimension_multiple))]
+pub struct Multiple<'ast> {
+ pub numbers: Vec>,
+ #[pest_ast(outer())]
+ #[serde(with = "SpanDef")]
+ pub span: Span<'ast>,
+}
diff --git a/ast/src/types/array_element.rs b/ast/src/types/array_element.rs
new file mode 100644
index 0000000000..749f8f3c3f
--- /dev/null
+++ b/ast/src/types/array_element.rs
@@ -0,0 +1,29 @@
+// Copyright (C) 2019-2020 Aleo Systems Inc.
+// This file is part of the Leo library.
+
+// The Leo library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// The Leo library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with the Leo library. If not, see .
+
+use crate::{ast::Rule, types::*};
+
+use pest_ast::FromPest;
+use serde::Serialize;
+
+#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
+#[pest_ast(rule(Rule::array_element))]
+pub enum ArrayElement<'ast> {
+ Basic(DataType),
+ Tuple(TupleType<'ast>),
+ Circuit(CircuitType<'ast>),
+ SelfType(SelfType),
+}
diff --git a/ast/src/types/array_type.rs b/ast/src/types/array_type.rs
index fd1176ccfd..017dc5f661 100644
--- a/ast/src/types/array_type.rs
+++ b/ast/src/types/array_type.rs
@@ -14,7 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use crate::{ast::Rule, types::DataType, values::PositiveNumber, SpanDef};
+use crate::{
+ ast::Rule,
+ types::{ArrayDimensions, ArrayElement},
+ SpanDef,
+};
use pest::Span;
use pest_ast::FromPest;
@@ -23,8 +27,8 @@ use serde::Serialize;
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
#[pest_ast(rule(Rule::type_array))]
pub struct ArrayType<'ast> {
- pub _type: DataType,
- pub dimensions: Vec>,
+ pub type_: ArrayElement<'ast>,
+ pub dimensions: ArrayDimensions<'ast>,
#[pest_ast(outer())]
#[serde(with = "SpanDef")]
pub span: Span<'ast>,
diff --git a/ast/src/types/mod.rs b/ast/src/types/mod.rs
index 3011db3449..00f1c46815 100644
--- a/ast/src/types/mod.rs
+++ b/ast/src/types/mod.rs
@@ -17,6 +17,12 @@
pub mod address_type;
pub use address_type::*;
+pub mod array_dimensions;
+pub use array_dimensions::*;
+
+pub mod array_element;
+pub use array_element::*;
+
pub mod array_type;
pub use array_type::*;