galvan_ast/item/
collection.rs1use crate::{AstNode, PrintAst, Span};
2use galvan_ast_macro::AstNode;
3use typeunion::type_union;
4
5use super::Expression;
6
7#[type_union]
8#[derive(Clone, Debug, PartialEq, Eq, AstNode)]
9pub type CollectionLiteral = ArrayLiteral + DictLiteral + SetLiteral + OrderedDictLiteral;
10
11#[derive(Clone, Debug, PartialEq, Eq, AstNode)]
12pub struct ArrayLiteral {
13 pub elements: Vec<Expression>,
14 pub span: Span,
15}
16
17#[derive(Clone, Debug, PartialEq, Eq, AstNode)]
18pub struct DictLiteral {
19 pub elements: Vec<DictLiteralElement>,
20 pub span: Span,
21}
22
23#[derive(Clone, Debug, PartialEq, Eq, AstNode)]
24pub struct DictLiteralElement {
25 pub key: Expression,
26 pub value: Expression,
27 pub span: Span,
28}
29
30#[derive(Clone, Debug, PartialEq, Eq, AstNode)]
31pub struct SetLiteral {
32 pub elements: Vec<Expression>,
33 pub span: Span,
34}
35
36#[derive(Clone, Debug, PartialEq, Eq, AstNode)]
37pub struct OrderedDictLiteral {
38 pub elements: Vec<DictLiteralElement>,
39 pub span: Span,
40}