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
use input::{AttrId, TyId, LexerId, BindId, FragmentId, ExprId, SpanId};
use input::attr_arguments::AttrArguments;

#[derive(Clone, Debug)]
pub struct Stmts {
    pub attr_arguments: AttrArguments,
    pub stmts: Vec<Stmt>,
    pub lexer: Option<LexerId>,
}

#[derive(Clone, Debug)]
pub struct Stmt {
    pub lhs: FragmentId,
    pub body: Vec<Alternative>,
    pub ty: Option<TyId>,
}

pub type Alternative = (Level, Rhs, Action);

type Level = u32;

#[derive(Clone, Debug)]
pub struct Rhs(pub Vec<RhsElement>);

#[derive(Clone, Debug)]
pub struct Action {
    pub expr: Option<ExprId>,
}

#[derive(Clone, Debug)]
pub struct RhsElement {
    pub bind: Bind,
    pub elem: RhsAst,
}

pub type Bind = Option<BindId>;

#[derive(Clone, Debug)]
pub enum RhsAst {
    Fragment(FragmentId),
    String(String),
    Sequence(Sequence),
    Sum(Vec<Rhs>),
    Product(Rhs),
}

#[derive(Clone, Debug)]
pub struct Sequence {
    pub rhs: Rhs,
    pub min: u32,
    pub max: Option<u32>,
}