1use crate::language::{IntType, FloatType, InternSymbol};
2use crate::parser::expr::{ExprMeta, Expr};
3use crate::parser::lvalue::AssignType;
4
5
6#[derive(Debug, Clone)]
9pub enum Atom {
10 Nil,
11 EmptyTuple,
12 Identifier(InternSymbol),
16 BooleanLiteral(bool),
17 IntegerLiteral(IntType),
18 FloatLiteral(FloatType),
19 StringLiteral(InternSymbol),
20
21 Group {
22 modifier: Option<AssignType>,
23 inner: Box<Expr>,
24 }
25}
26
27#[derive(Debug, Clone)]
29pub enum AccessItem {
30 Attribute(InternSymbol),
31
32 Index(ExprMeta),
33
34 Invoke(Box<[ExprMeta]>),
35
36 }
38
39#[derive(Debug, Clone)]
40pub struct Primary {
41 atom: Atom,
42 path: Box<[AccessItem]>,
43}
44
45impl Primary {
46 pub fn new(atom: Atom, path: Vec<AccessItem>) -> Self {
47 Primary { atom, path: path.into_boxed_slice() }
48 }
49
50 pub fn take(self) -> (Atom, Vec<AccessItem>) {
51 (self.atom, self.path.into_vec())
52 }
53
54 pub fn atom(&self) -> &Atom { &self.atom }
55
56 pub fn path(&self) -> &[AccessItem] { &self.path }
57 pub fn path_mut(&mut self) -> &mut [AccessItem] { &mut self.path }
58}
59