Debian Codegraph @

apps/tc/theories/add_commands.v

raw
1 (* license: GNU Lesser General Public License Version 2.1 or later *)
2 (* ------------------------------------------------------------------------- *)
3
4 From elpi.apps.tc Require Import db.
5
6 From elpi.apps.tc.elpi Extra Dependency "tc_aux.elpi" as tc_aux.
7 From elpi.apps.tc.elpi Extra Dependency "ho_precompile.elpi" as ho_precompile.
8 From elpi.apps.tc.elpi Extra Dependency "ho_compile.elpi" as ho_compile.
9 From elpi.apps.tc.elpi Extra Dependency "compiler1.elpi" as compiler1.
10 From elpi.apps.tc.elpi Extra Dependency "unif.elpi" as unif.
11 From elpi.apps.tc.elpi Extra Dependency "modes.elpi" as modes.
12 From elpi.apps.tc.elpi Extra Dependency "ho_link.elpi" as ho_link.
13 From elpi.apps.tc.elpi Extra Dependency "parser_addInstances.elpi" as parser_addInstances.
14 From elpi.apps.tc.elpi Extra Dependency "solver.elpi" as solver.
15 From elpi.apps.tc.elpi Extra Dependency "create_tc_predicate.elpi" as create_tc_predicate.
16
17 (* Set Warnings "+elpi". *)
18
19 Elpi Command TC.AddAllInstances.
20 Elpi Accumulate Db tc.db.
21 Elpi Accumulate Db tc_options.db.
22 Elpi Accumulate File tc_aux.
23 Elpi Accumulate File ho_precompile.
24 Elpi Accumulate File unif.
25 Elpi Accumulate File ho_link.
26 Elpi Accumulate File ho_compile.
27 Elpi Accumulate File compiler1.
28 Elpi Accumulate File modes.
29 Elpi Accumulate lp:{{
30 main L :-
31 args->str-list L L1,
32 tc.time-it _ (std.forall {coq.TC.db-tc} (x\ tc.add-tc-or-inst-gr [] L1 [x])) "TC.AddAllInstances".
33 }}.
34
35
36 Elpi Command TC.AddInstances.
37 Elpi Accumulate Db tc.db.
38 Elpi Accumulate Db tc_options.db.
39 Elpi Accumulate File tc_aux.
40 Elpi Accumulate File ho_precompile.
41 Elpi Accumulate File ho_compile.
42 Elpi Accumulate File unif.
43 Elpi Accumulate File ho_link.
44 Elpi Accumulate File compiler1.
45 Elpi Accumulate File modes.
46 Elpi Accumulate File parser_addInstances.
47 Elpi Accumulate lp:{{
48 main Arguments :-
49 tc.parse Arguments Res, tc.run-command Res.
50 }}.
51
52
53 Elpi Command TC.AddAllClasses.
54 Elpi Accumulate Db tc.db.
55 Elpi Accumulate Db tc_options.db.
56 Elpi Accumulate File tc_aux.
57 Elpi Accumulate File modes.
58 Elpi Accumulate File create_tc_predicate.
59 Elpi Accumulate lp:{{
60 % Ignore is the list of classes we do not want to add
61 main IgnoreStr :-
62 std.map IgnoreStr (x\r\ sigma S\ str S = x, coq.locate S r) IgnoreGR,
63 tc.time-it _ (std.forall {coq.TC.db-tc} (x\ if (std.mem IgnoreGR x) true (tc.add-class-gr tc.classic x []))) "TC.AddAllClasses".
64 }}.
65
66
67 Elpi Command TC.AddClasses.
68 Elpi Accumulate Db tc.db.
69 Elpi Accumulate Db tc_options.db.
70 Elpi Accumulate File tc_aux.
71 Elpi Accumulate File modes.
72 Elpi Accumulate File create_tc_predicate.
73 Elpi Accumulate lp:{{
74 pred tc.add-all-classes i:list argument , i:tc.search-mode.
75 tc.add-all-classes L S :-
76 tc.time-it _ (std.forall {args->str-list L} (tc.add-class-str S)) "TC.AddClasses".
77
78 main L :-
79 std.mem {attributes} (attribute "deterministic" _),
80 tc.add-all-classes L tc.deterministic.
81 main L :- tc.add-all-classes L tc.classic.
82 main _ :- coq.error "This commands accepts: [classic|deterministic]? TC-names*".
83 }}.
84
85
86 Elpi Command TC.AddHook.
87 Elpi Accumulate Db tc.db.
88 Elpi Accumulate Db tc_options.db.
89 Elpi Accumulate File tc_aux.
90 Elpi Accumulate lp:{{
91 pred tc.addHook i:grafting, i:string.
92 tc.addHook Grafting NewName :-
93 @global! => tc.add-tc-db NewName Grafting (tc.hook NewName).
94
95 main [str "before", str OldHook, str NewHook] :-
96 tc.addHook (before OldHook) NewHook.
97
98 main [str "after", str OldHook, str NewHook] :-
99 tc.addHook (after OldHook) NewHook.
100
101 main [Graft, int OldHook, NewHook] :-
102 main [Graft, str {calc (int_to_string OldHook)}, NewHook].
103
104 main [Graft, OldHook, int NewHook] :-
105 main [Graft, OldHook, str {calc (int_to_string NewHook)}].
106
107 main _ :-
108 coq.error "Invalid call to command AddHook. A valid call looks like"
109 "[ElpiAddHook Pos OldName NewName] where:"
110 " - Pos is either after or before"
111 " - OldName is the name of an existing hook"
112 " - NewName is the name of the new hook".
113 }}.
114
115
116 Elpi Command TC.Declare.
117 Elpi Accumulate Db tc.db.
118 Elpi Accumulate Db tc_options.db.
119 Elpi Accumulate File tc_aux.
120 Elpi Accumulate File modes.
121 Elpi Accumulate File create_tc_predicate.
122 Elpi Accumulate lp:{{
123 main _ :- coq.warning "TC.Declare" {tc.warning-name}
124 "This command does not fully mirror the watned behavior if the class has methods
125 with implicit arguments (those implicits will be neglected)", fail.
126 main [indt-decl D] :- !, tc.declare-class D.
127 main _ :- coq.error "Argument should be an inductive type".
128 }}.
129
130
131 Elpi Command TC.Pending_mode.
132 Elpi Accumulate Db tc.db.
133 Elpi Accumulate Db tc_options.db.
134 Elpi Accumulate File tc_aux.
135 Elpi Accumulate File modes.
136 Elpi Accumulate File create_tc_predicate.
137 Elpi Accumulate lp:{{
138 main M :-
139 % the "o" added at the end of M stands for the solution of the goal
140 std.append M [str "o"] M1,
141 tc.add-pending-mode {args->str-list M1}.
142 }}.
143
144
145
146 Elpi Export TC.AddAllClasses.
147 Elpi Export TC.AddAllInstances.
148 Elpi Export TC.AddClasses.
149 Elpi Export TC.AddInstances.
150 Elpi Export TC.AddHook.
151 Elpi Export TC.Declare.
152 Elpi Export TC.Pending_mode.