1use super::namespace::term;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub struct NodeKindDescriptor {
7 pub local_name: &'static str,
8 pub rust_path: &'static str,
9 pub rdfs_class_local: &'static str,
10}
11
12macro_rules! kinds {
13 ($($local:literal, $rust:literal, $class:literal);+ $(;)?) => {
14 &[
15 $(NodeKindDescriptor {
16 local_name: $local,
17 rust_path: $rust,
18 rdfs_class_local: $class,
19 }),+
20 ]
21 };
22}
23
24pub const ITEM_KINDS: &[NodeKindDescriptor] = kinds!(
25 "Item.Function", "ast::Item::Function", "FunctionDeclaration";
26 "Item.Hook", "ast::Item::Hook", "HookDeclaration";
27 "Item.Const", "ast::Item::Const", "Declaration";
28 "Item.Enum", "ast::Item::Enum", "Declaration";
29 "Item.Field", "ast::Item::Field", "FieldDeclaration";
30 "Item.Material", "ast::Item::Material", "MaterialDeclaration";
31 "Item.Law", "ast::Item::Law", "LawDeclaration";
32 "Item.Cell", "ast::Item::Cell", "CellDeclaration";
33 "Item.Present", "ast::Item::Present", "Declaration";
34 "Item.Bind", "ast::Item::Bind", "Declaration";
35 "Item.Statement", "ast::Item::Statement", "Statement";
36);
37
38pub const STMT_KINDS: &[NodeKindDescriptor] = kinds!(
39 "Stmt.Let", "ast::Stmt::Let", "Statement";
40 "Stmt.LetPat", "ast::Stmt::LetPat", "Statement";
41 "Stmt.Assign", "ast::Stmt::Assign", "Statement";
42 "Stmt.If", "ast::Stmt::If", "Statement";
43 "Stmt.For", "ast::Stmt::For", "Statement";
44 "Stmt.While", "ast::Stmt::While", "Statement";
45 "Stmt.Match", "ast::Stmt::Match", "Statement";
46 "Stmt.Return", "ast::Stmt::Return", "Statement";
47 "Stmt.Yield", "ast::Stmt::Yield", "Statement";
48 "Stmt.Transaction", "ast::Stmt::Transaction", "Statement";
49 "Stmt.Effect", "ast::Stmt::Effect", "Statement";
50 "Stmt.Expr", "ast::Stmt::Expr", "Statement";
51 "Stmt.Block", "ast::Stmt::Block", "Statement";
52);
53
54pub const PATTERN_KINDS: &[NodeKindDescriptor] = kinds!(
55 "Pattern.Wildcard", "ast::Pattern::Wildcard", "Pattern";
56 "Pattern.Ident", "ast::Pattern::Ident", "Pattern";
57 "Pattern.Literal", "ast::Pattern::Literal", "Pattern";
58 "Pattern.Ok", "ast::Pattern::Ok", "Pattern";
59 "Pattern.Err", "ast::Pattern::Err", "Pattern";
60 "Pattern.Some", "ast::Pattern::Some", "Pattern";
61 "Pattern.None", "ast::Pattern::None", "Pattern";
62 "Pattern.Record", "ast::Pattern::Record", "Pattern";
63 "Pattern.List", "ast::Pattern::List", "Pattern";
64 "Pattern.Constructor", "ast::Pattern::Constructor", "Pattern";
65 "Pattern.Variant", "ast::Pattern::Variant", "Pattern";
66);
67
68pub const EXPR_KINDS: &[NodeKindDescriptor] = kinds!(
69 "ExprKind.Literal", "ast::ExprKind::Literal", "Expression";
70 "ExprKind.Ident", "ast::ExprKind::Ident", "Expression";
71 "ExprKind.QueryVar", "ast::ExprKind::QueryVar", "Expression";
72 "ExprKind.Iri", "ast::ExprKind::Iri", "Expression";
73 "ExprKind.Prefixed", "ast::ExprKind::Prefixed", "Expression";
74 "ExprKind.Blank", "ast::ExprKind::Blank", "Expression";
75 "ExprKind.Binary", "ast::ExprKind::Binary", "Expression";
76 "ExprKind.Unary", "ast::ExprKind::Unary", "Expression";
77 "ExprKind.Await", "ast::ExprKind::Await", "Expression";
78 "ExprKind.Member", "ast::ExprKind::Member", "Expression";
79 "ExprKind.Call", "ast::ExprKind::Call", "Expression";
80 "ExprKind.Index", "ast::ExprKind::Index", "Expression";
81 "ExprKind.Try", "ast::ExprKind::Try", "Expression";
82 "ExprKind.List", "ast::ExprKind::List", "Expression";
83 "ExprKind.Record", "ast::ExprKind::Record", "Expression";
84 "ExprKind.Triple", "ast::ExprKind::Triple", "Expression";
85 "ExprKind.Reified", "ast::ExprKind::Reified", "Expression";
86 "ExprKind.Pipe", "ast::ExprKind::Pipe", "Expression";
87 "ExprKind.GraphQuery", "ast::ExprKind::GraphQuery", "Expression";
88 "ExprKind.ModalLogic", "ast::ExprKind::ModalLogic", "Expression";
89 "ExprKind.Interpolate", "ast::ExprKind::Interpolate", "Expression";
90 "ExprKind.Lambda", "ast::ExprKind::Lambda", "Expression";
91 "ExprKind.Tween", "ast::ExprKind::Tween", "Expression";
92 "ExprKind.IfElse", "ast::ExprKind::IfElse", "Expression";
93);
94
95pub const MODAL_KINDS: &[NodeKindDescriptor] = kinds!(
96 "ModalKind.DeonticObligate", "ast::ModalKind::DeonticObligate", "Expression";
97 "ModalKind.DeonticPermit", "ast::ModalKind::DeonticPermit", "Expression";
98 "ModalKind.DeonticForbid", "ast::ModalKind::DeonticForbid", "Expression";
99 "ModalKind.EpistemicKnows", "ast::ModalKind::EpistemicKnows", "Expression";
100 "ModalKind.EpistemicBelieves", "ast::ModalKind::EpistemicBelieves", "Expression";
101 "ModalKind.Paraconsistent", "ast::ModalKind::Paraconsistent", "Expression";
102 "ModalKind.LtlGlobally", "ast::ModalKind::LtlGlobally", "Expression";
103 "ModalKind.LtlFinally", "ast::ModalKind::LtlFinally", "Expression";
104 "ModalKind.LtlUntil", "ast::ModalKind::LtlUntil", "Expression";
105 "ModalKind.DlSubsumes", "ast::ModalKind::DlSubsumes", "Expression";
106 "ModalKind.N3Defeasible", "ast::ModalKind::N3Defeasible", "Expression";
107);
108
109pub const EFFECT_KINDS: &[NodeKindDescriptor] = kinds!(
110 "EffectClass.Pure", "ast::EffectClass::Pure", "EffectClass";
111 "EffectClass.Hot", "ast::EffectClass::Hot", "EffectClass";
112 "EffectClass.Cold", "ast::EffectClass::Cold", "EffectClass";
113 "EffectClass.Async", "ast::EffectClass::Async", "EffectClass";
114 "EffectClass.External", "ast::EffectClass::External", "EffectClass";
115);
116
117pub const TYPE_KINDS: &[NodeKindDescriptor] = kinds!(
118 "Type.I64", "types::Type::I64", "Type";
119 "Type.U64", "types::Type::U64", "Type";
120 "Type.F64", "types::Type::F64", "Type";
121 "Type.Bool", "types::Type::Bool", "Type";
122 "Type.String", "types::Type::String", "Type";
123 "Type.Bytes", "types::Type::Bytes", "Type";
124 "Type.Iri", "types::Type::Iri", "Type";
125 "Type.BlankNode", "types::Type::BlankNode", "Type";
126 "Type.Did", "types::Type::Did", "Type";
127 "Type.Continuant", "types::Type::Continuant", "Type";
128 "Type.Hash", "types::Type::Hash", "Type";
129 "Type.Var", "types::Type::Var", "Type";
130 "Type.Literal", "types::Type::Literal", "Type";
131 "Type.TripleTerm", "types::Type::TripleTerm", "Type";
132 "Type.Reifier", "types::Type::Reifier", "Type";
133 "Type.Quin", "types::Type::Quin", "Type";
134 "Type.QuinRef", "types::Type::QuinRef", "Type";
135 "Type.AssetRef", "types::Type::AssetRef", "Type";
136 "Type.TensorRef", "types::Type::TensorRef", "Type";
137 "Type.GeometryRef", "types::Type::GeometryRef", "Type";
138 "Type.Instant", "types::Type::Instant", "Type";
139 "Type.Duration", "types::Type::Duration", "Type";
140 "Type.Quantity", "types::Type::Quantity", "Type";
141 "Type.Frame", "types::Type::Frame", "Type";
142 "Type.Pose", "types::Type::Pose", "Type";
143 "Type.Transform", "types::Type::Transform", "Type";
144 "Type.FieldRef", "types::Type::FieldRef", "Type";
145 "Type.MaterialRef", "types::Type::MaterialRef", "Type";
146 "Type.WorldLine", "types::Type::WorldLine", "Type";
147 "Type.Enum", "types::Type::Enum", "Type";
148 "Type.SpeciesRef", "types::Type::SpeciesRef", "Type";
149 "Type.Mixture", "types::Type::Mixture", "Type";
150 "Type.Option", "types::Type::Option", "Type";
151 "Type.Result", "types::Type::Result", "Type";
152 "Type.List", "types::Type::List", "Type";
153 "Type.Record", "types::Type::Record", "Type";
154 "Type.Receipt", "types::Type::Receipt", "Type";
155 "Type.Stream", "types::Type::Stream", "Type";
156 "Type.Future", "types::Type::Future", "Type";
157 "Type.Named", "types::Type::Named", "Type";
158 "Type.Unknown", "types::Type::Unknown", "Type";
159);
160
161pub fn all_node_kinds() -> Vec<&'static NodeKindDescriptor> {
163 let mut out = Vec::new();
164 for slice in [
165 ITEM_KINDS,
166 STMT_KINDS,
167 PATTERN_KINDS,
168 EXPR_KINDS,
169 MODAL_KINDS,
170 EFFECT_KINDS,
171 TYPE_KINDS,
172 ] {
173 out.extend(slice.iter());
174 }
175 out
176}
177
178pub fn kind_iri(d: &NodeKindDescriptor) -> String {
180 term(d.rdfs_class_local)
181}