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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use crate::{ast::*, xkb::Rule};
use derivative::Derivative;
use pest_ast::FromPest;

#[derive(Derivative, FromPest, Clone, PartialEq)]
#[derivative(Debug)]
#[pest_ast(rule(Rule::xkb_types))]
pub struct XkbTypes<'src> {
    pub name: StringContent<'src>,
    pub values: Vec<XkbTypesItem<'src>>,
}

#[derive(Derivative, FromPest, Clone, PartialEq)]
#[derivative(Debug)]
#[pest_ast(rule(Rule::xkb_types_item))]
pub enum XkbTypesItem<'src> {
    #[derivative(Debug = "transparent")]
    Include(Include<'src>),
    #[derivative(Debug = "transparent")]
    Override(Override<'src>),
    #[derivative(Debug = "transparent")]
    Augment(Augment<'src>),

    #[derivative(Debug = "transparent")]
    VirtualModifiers(VirtualModifiers<'src>),
    #[derivative(Debug = "transparent")]
    TypeItem(TypeItem<'src>),
}

#[derive(Derivative, FromPest, Clone, PartialEq)]
#[derivative(Debug)]
#[pest_ast(rule(Rule::type_item))]
pub struct TypeItem<'src> {
    pub prefix: Option<TypeItemPrefix<'src>>,
    pub name: StringContent<'src>,
    pub values: Vec<TypeComponent<'src>>,
}

#[derive(Derivative, FromPest, Clone, PartialEq)]
#[derivative(Debug)]
#[pest_ast(rule(Rule::type_item_prefix))]
pub struct TypeItemPrefix<'src> {
    #[pest_ast(outer(with(span_into_str)))]
    pub content: &'src str,
}

#[derive(Derivative, FromPest, Clone, PartialEq)]
#[derivative(Debug)]
#[pest_ast(rule(Rule::type_component))]
pub enum TypeComponent<'src> {
    #[derivative(Debug = "transparent")]
    Modifiers(Modifiers<'src>),
    #[derivative(Debug = "transparent")]
    Map(Map<'src>),
    #[derivative(Debug = "transparent")]
    Preserve(Preserve<'src>),
    #[derivative(Debug = "transparent")]
    LevelName(LevelName<'src>),
}

#[derive(Derivative, FromPest, Clone, PartialEq)]
#[derivative(Debug)]
#[pest_ast(rule(Rule::modifiers))]
pub struct Modifiers<'src> {
    pub name: KeyCombo<'src>,
}

#[derive(Derivative, FromPest, Clone, PartialEq)]
#[derivative(Debug)]
#[pest_ast(rule(Rule::map))]
pub struct Map<'src> {
    pub group: KeyCombo<'src>,
    pub name: Ident<'src>,
}

#[derive(Derivative, FromPest, Clone, PartialEq)]
#[derivative(Debug)]
#[pest_ast(rule(Rule::preserve))]
pub struct Preserve<'src> {
    pub left: KeyCombo<'src>,
    pub right: KeyCombo<'src>,
}

#[derive(Derivative, FromPest, Clone, PartialEq)]
#[derivative(Debug)]
#[pest_ast(rule(Rule::level_name))]
pub struct LevelName<'src> {
    pub group: Group<'src>,
    pub content: StringContent<'src>,
}