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