sv_parser_syntaxtree/
special_node.rs

1use crate::*;
2
3// -----------------------------------------------------------------------------
4
5#[derive(Clone, Debug, PartialEq, Node)]
6pub struct Symbol {
7    pub nodes: (Locate, Vec<WhiteSpace>),
8}
9
10#[derive(Clone, Debug, PartialEq, Node)]
11pub struct Keyword {
12    pub nodes: (Locate, Vec<WhiteSpace>),
13}
14
15#[derive(Clone, Debug, PartialEq, Node)]
16pub enum WhiteSpace {
17    Newline(Box<Locate>),
18    Space(Box<Locate>),
19    Comment(Box<Comment>),
20    CompilerDirective(Box<CompilerDirective>),
21}
22
23#[derive(Clone, Debug, PartialEq)]
24pub struct Paren<T> {
25    pub nodes: (Symbol, T, Symbol),
26}
27
28#[derive(Clone, Debug, PartialEq)]
29pub struct Brace<T> {
30    pub nodes: (Symbol, T, Symbol),
31}
32
33#[derive(Clone, Debug, PartialEq)]
34pub struct Bracket<T> {
35    pub nodes: (Symbol, T, Symbol),
36}
37
38#[derive(Clone, Debug, PartialEq)]
39pub struct ApostropheBrace<T> {
40    pub nodes: (Symbol, T, Symbol),
41}
42
43#[derive(Clone, Debug, PartialEq)]
44pub struct List<T, U> {
45    pub nodes: (U, Vec<(T, U)>),
46}
47
48impl<T, U> List<T, U> {
49    pub fn contents(&self) -> Vec<&U> {
50        let mut ret = vec![];
51        let (ref x, ref y) = self.nodes;
52        ret.push(x);
53        for (_, y) in y {
54            ret.push(y)
55        }
56        ret
57    }
58}