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 super::*;

/// `⁜label.context.1`
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct GotoStatement {
    /// The goto path
    pub path: Vec<String>,
    /// The range of the node
    pub span: Range<u32>,
}

/// `※label.context.1`
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LabelStatement {
    /// The label path
    pub path: Vec<String>,
    /// The range of the node
    pub span: Range<u32>,
}

impl Display for GotoStatement {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        f.write_char('⁜')?;
        for (i, path) in self.path.iter().enumerate() {
            if i != 0 {
                f.write_char('.')?;
            }
            f.write_str(path)?;
        }
        Ok(())
    }
}

impl Display for LabelStatement {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        f.write_char('※')?;
        for (i, path) in self.path.iter().enumerate() {
            if i != 0 {
                f.write_char('.')?;
            }
            f.write_str(path)?;
        }
        Ok(())
    }
}
#[cfg(feature = "pretty-print")]
impl PrettyPrint for LabelStatement {
    fn pretty(&self, theme: &PrettyProvider) -> PrettyTree {
        theme.annotation(self.to_string())
    }
}
#[cfg(feature = "pretty-print")]
impl PrettyPrint for GotoStatement {
    fn pretty(&self, theme: &PrettyProvider) -> PrettyTree {
        theme.annotation(self.to_string())
    }
}