lib_ruby_parser_nodes/
nodes.rs

1use serde::Serialize;
2
3#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
4pub struct Node {
5    pub camelcase_name: &'static str,
6    pub wqp_name: &'static str,
7    pub fields: &'static [&'static NodeField],
8    pub comment: &'static [&'static str],
9}
10
11impl Node {
12    pub fn upper_name(&self) -> String {
13        crate::helpers::camelcase_to_snakecase(self.camelcase_name).to_uppercase()
14    }
15
16    pub fn lower_name(&self) -> String {
17        crate::helpers::camelcase_to_snakecase(self.camelcase_name).to_lowercase()
18    }
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
22pub struct NodeField {
23    pub snakecase_name: &'static str,
24    pub field_type: NodeFieldType,
25    pub always_print: bool,
26    pub comment: &'static [&'static str],
27}
28
29#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
30pub enum NodeFieldType {
31    Node,
32    Nodes,
33    MaybeNode,
34    RegexpOptions,
35    Loc,
36    MaybeLoc,
37    Str,
38    RawStr,
39    MaybeStr,
40    Chars,
41    StringValue,
42    U8,
43}