1use crate::extractor::FTMLExtractor;
2use crate::open::OpenFTMLElement;
3use crate::rules::FTMLExtractionRule;
4use flams_ontology::ftml::FTMLKey;
5use paste::paste;
6
7macro_rules! do_tags {
8 ($($tag:ident $(@$f:ident)?),*) => {
9 paste! {
10 #[must_use]#[inline]
12 pub const fn all_rules<E:FTMLExtractor>() -> [FTMLExtractionRule<E>;flams_ontology::ftml::NUM_RULES] {[$(
13 rule(FTMLKey::$tag)
14 ),*]}
15 #[must_use]#[inline]
16 pub const fn rule<E:FTMLExtractor>(key:FTMLKey) -> FTMLExtractionRule<E> {
17 match key {$(
18 FTMLKey::$tag =>
19 FTMLExtractionRule::new(key,FTMLKey::$tag.attr_name(),do_tags!(@FUN $tag $($f)?))
20 ),*}
21 }
22 }
24
25 };
26 (@FUN $tag:ident None) => {no_op};
27 (@FUN $tag:ident $i:ident) => {super::rules::rules::$i};
28 (@FUN $tag:ident ) => {|a,b,c| todo(a,b,c,FTMLTag::$tag)}
29}
30
31do_tags! {
32 Module @ module,
33 MathStructure @ mathstructure,
34 Morphism @ morphism,
35 Section @ section,
36 SkipSection @ skipsection,
37
38 Definition @ definition,
39 Paragraph @ paragraph,
40 Assertion @ assertion,
41 Example @ example,
42 Problem @ problem,
43 SubProblem @ subproblem,
44 Slide @ slide,
45 SlideNumber @ slide_number,
46
47 DocTitle @ doctitle,
48 Title @ title,
49 ProofTitle @ prooftitle,
50 SubproofTitle @ subprooftitle,
51
52 Symdecl @ symdecl,
53 Vardef @ vardecl,
54 Varseq @ varseq,
55
56 Notation @ notation,
57 NotationComp @ notationcomp,
58 NotationOpComp @ notationopcomp,
59 Definiendum @ definiendum,
60
61 Type @ r#type,
62 Conclusion @ conclusion,
63 Definiens @ definiens,
64 Rule @ mmtrule,
65
66 ArgSep @ argsep,
67 ArgMap @ argmap,
68 ArgMapSep @ argmapsep,
69
70 Term @ term,
71 Arg @ arg,
72 HeadTerm @ headterm,
73
74 ImportModule @ importmodule,
75 UseModule @ usemodule,
76 InputRef @ inputref,
77
78 SetSectionLevel @ setsectionlevel,
79
80 Style @ style_rule,
81 CounterParent @ counter_parent,
82 Counter @ counter_parent,
83
84
85 Proof @ proof,
86 SubProof @ subproof,
87 ProofMethod @ no_op ,
88 ProofSketch @ no_op ,
89 ProofTerm @ no_op ,
90 ProofBody @ proofbody,
91 ProofAssumption @ no_op ,
92 ProofHide @ no_op,
93 ProofStep @ no_op ,
94 ProofStepName @ no_op ,
95 ProofEqStep @ no_op ,
96 ProofPremise @ no_op ,
97 ProofConclusion @ no_op ,
98
99 PreconditionDimension @ precondition,
100 PreconditionSymbol @ no_op,
101 ObjectiveDimension @ objective,
102 ObjectiveSymbol @ no_op,
103 ProblemMinutes @ no_op ,
104
105 ProblemFillinsol @ fillinsol,
106 ProblemFillinsolWidth @ no_op,
107 ProblemFillinsolCase @ fillinsol_case,
108 ProblemFillinsolCaseValue @ no_op,
109 ProblemFillinsolCaseVerdict @ no_op,
110
111 ProblemNote @ no_op ,
112 ProblemSolution @ solution,
113 ProblemHint @ problem_hint,
114 ProblemGradingNote @ gnote,
115
116 ProblemMultipleChoiceBlock @ multiple_choice_block,
117 ProblemSingleChoiceBlock @ single_choice_block,
118 ProblemChoice @ problem_choice,
119 ProblemChoiceVerdict @ problem_choice_verdict,
120 ProblemChoiceFeedback @ problem_choice_feedback,
121
122 AnswerClass @ answer_class,
123 AnswerclassFeedback @ ac_feedback,
124 AnswerClassPts @ no_op,
125
126 Comp @ comp,
127 VarComp @ comp,
128 MainComp @ maincomp,
129 DefComp @ defcomp,
130
131 Invisible @ invisible,
132
133 IfInputref @ ifinputref,
134 ReturnType @ no_op ,
135 ArgTypes @ no_op ,
136
137 SRef @ no_op ,
138 SRefIn @ no_op ,
139 Slideshow @ no_op ,
140 SlideshowSlide @ no_op ,
141 CurrentSectionLevel @ no_op ,
142 Capitalize @ no_op ,
143
144 Assign @ assign,
145 Rename @ no_op ,
146 RenameTo @ no_op ,
147 AssignMorphismFrom @ no_op ,
148 AssignMorphismTo @ no_op ,
149
150 AssocType @ no_op,
151 ArgumentReordering @ no_op,
152 ArgNum @ no_op,
153 Bind @ no_op,
154 ProblemPoints @ no_op,
155 Autogradable @ no_op,
156 MorphismDomain @ no_op,
157 MorphismTotal @ no_op,
158 ArgMode @ no_op,
159 NotationId @ no_op,
160 Head @ no_op,
161 Language @ no_op,
162 Metatheory @ no_op,
163 Signature @ no_op,
164 Args @ no_op,
165 Macroname @ no_op,
166 Inline @ no_op,
167 Fors @ no_op,
168 Id @ no_op,
169 NotationFragment @ no_op,
170 Precedence @ no_op,
171 Role @ no_op,
172 Styles @ no_op,
173 Argprecs @ no_op
174}
175#[allow(dead_code)]
176pub const fn ignore<E: FTMLExtractor>(key: FTMLKey) -> FTMLExtractionRule<E> {
177 FTMLExtractionRule::new(key, key.attr_name(), super::rules::rules::no_op)
178}
179#[allow(dead_code)]
180pub const fn no_op<E: FTMLExtractor>(
181 _extractor: &mut E,
182 _attrs: &mut E::Attr<'_>,
183 _nexts: &mut super::rules::rules::SV<E>,
184) -> Option<OpenFTMLElement> {
185 None
186}
187
188#[allow(dead_code)]
189pub fn todo<E: FTMLExtractor>(
190 _extractor: &mut E,
191 _attrs: &mut E::Attr<'_>,
192 _nexts: &mut super::rules::rules::SV<E>,
193 tag: FTMLKey,
194) -> Option<OpenFTMLElement> {
195 todo!("Tag {}", tag.as_str())
196}