1use super::parser::Parser;
2use super::ParseError;
3
4#[derive(Debug, PartialEq, Eq, Clone)]
5pub enum Lhs {
6 DollarSign(usize, usize),
7 Amp(usize, usize),
8 At(usize, Box<Rhs>),
9 Square(String),
10 Pipes(Vec<Stars>),
12 Literal(String),
13}
14
15impl Lhs {
16 pub fn parse(input: &str) -> Result<Self, ParseError> {
17 Parser::new(input).parse_lhs()
18 }
19}
20
21#[derive(Debug, PartialEq, Clone, Eq)]
24pub struct Stars(pub Vec<String>);
25
26#[derive(Debug, PartialEq, Clone, Eq)]
27pub struct Rhs(pub Vec<RhsPart>);
28
29#[derive(Debug, PartialEq, Clone, Eq)]
30pub enum RhsPart {
31 Index(IndexOp),
32 CompositeKey(Vec<RhsEntry>),
33 Key(RhsEntry),
34}
35
36#[derive(Debug, PartialEq, Clone, Eq)]
37pub enum RhsEntry {
38 Amp(usize, usize),
39 At(usize, Box<Rhs>),
40 Key(String),
41}
42
43#[derive(Debug, PartialEq, Clone, Eq)]
44pub enum IndexOp {
45 Amp(usize, usize),
46 Literal(usize),
47 At(usize, Box<Rhs>),
48 Empty,
49}
50
51impl Rhs {
52 pub fn parse(input: &str) -> Result<Self, ParseError> {
53 Parser::new(input).parse_rhs()
54 }
55}