vyre_spec/
pg_node_kind.rs1#[repr(u32)]
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Deserialize, serde::Serialize)]
7#[non_exhaustive]
8pub enum PgNodeKind {
9 VariableDecl = 1,
11 VariableUse = 2,
13 Assignment = 3,
15 Binary = 4,
17 Comparison = 5,
19 FunctionCall = 6,
21 FunctionDef = 7,
23 IfStmt = 8,
25 ForStmt = 9,
27 WhileStmt = 10,
29 ReturnStmt = 11,
31 Deref = 12,
33 AddrOf = 13,
35 Cast = 14,
37 MemberAccess = 15,
39 ArrayAccess = 16,
41 StructDecl = 17,
43 LiteralInt = 18,
45 LiteralStr = 19,
47 LiteralFloat = 20,
49}
50
51impl PgNodeKind {
52 #[must_use]
54 pub const fn from_u32(value: u32) -> Option<Self> {
55 match value {
56 1 => Some(Self::VariableDecl),
57 2 => Some(Self::VariableUse),
58 3 => Some(Self::Assignment),
59 4 => Some(Self::Binary),
60 5 => Some(Self::Comparison),
61 6 => Some(Self::FunctionCall),
62 7 => Some(Self::FunctionDef),
63 8 => Some(Self::IfStmt),
64 9 => Some(Self::ForStmt),
65 10 => Some(Self::WhileStmt),
66 11 => Some(Self::ReturnStmt),
67 12 => Some(Self::Deref),
68 13 => Some(Self::AddrOf),
69 14 => Some(Self::Cast),
70 15 => Some(Self::MemberAccess),
71 16 => Some(Self::ArrayAccess),
72 17 => Some(Self::StructDecl),
73 18 => Some(Self::LiteralInt),
74 19 => Some(Self::LiteralStr),
75 20 => Some(Self::LiteralFloat),
76 _ => None,
77 }
78 }
79}