reorganize sources
[protos/libecoli.git] / todo.txt
1 tk_cmd
2 ======
3
4 X evaluate expression tree in ec_tk_expr
5 X cmd token
6 - example
7 X tk_re
8
9 cleanup / rework
10 ================
11
12 X ec_completed_item_update()
13 X ec_completed_item_set_display_value()
14 X add_no_match
15 X add_partial_match
16 - check XXX in code
17 X properly manage quotes in shlex
18 X remove the _new() functions
19 X iterate children nodes without chaining them
20 - add a node vector type: will be used in several nodes (ex: or, seq, ...)
21 - check allocation model everywhere
22 - checkpatch?
23 - use linux style (update .emacs)
24 - better logs
25 - check return values (-1 or NULL) + use errno
26 - check missing static / const
27 - license: SPDX
28 - check all completion nodes
29 X split ecoli_tk.h
30 - size_t or unsigned int?
31 X rename:
32   X ec_tk -> ec_node
33   X ec_parsed_tk -> ec_parsed
34   X ec_completed_tk -> ec_completed
35   X tk, gen_tk, token, ... -> node
36   X tokens -> input_str / input_strvec ?
37 X save node path in completion to fix help string
38 - code coverage
39 - try to hide structures
40 - anything better than weakref?
41 - add ec_node_defaults.[ch] providing usual implementations of node methods
42 X use vec for strvec
43 - ELOOP in case of loop
44 - remove weakref?
45 - sh_lex to provide offsets in attributes
46 - accessors for all structs
47
48 dependencies
49 ============
50
51 X pass the current parsed state when parsing/completing
52 X new node "once"
53 - new node "condition"
54
55 logs
56 ====
57
58 X register log types
59
60 yaml
61 ====
62
63 X register nodes by name
64 - interface to add attributes: all nodes must be configurable through a
65   generic api
66   - attr string
67   - attr string list
68   - attr node
69   - attr node list
70   - attr int
71
72 - yaml interface to create nodes
73 - example
74
75 examples
76 ========
77
78 - example which parses arguments (argc/argv)
79 - example that acts as bash completion (ip link ?)
80 - calculator example (var assignation, expression evaluation)
81 - example with libedit
82 - mini script language
83 - configuration file
84 - mini shell: cd, ls, cat, stat
85 - mini network console based on ip
86
87 doc
88 ===
89
90 - overview
91 - add api doc in .h
92 - generate automatic api doc
93 - architecture
94 - coding rules, process
95 - each node
96 - allocation model
97 - say that it stops at first match (no ambigous support)
98 - say that completion must be exhaustive
99
100 build framework
101 ===============
102
103 - .map files for API
104 - split libs, tests and examples
105 - add make help
106 - add make config
107 - -fvisibility=
108
109 tests
110 =====
111
112 - complete automatic tests with "make test"
113
114 new nodes
115 =========
116
117 - regexp
118 - node which always matches
119 - file + partial completion
120 - ether, ip, network
121 - fusion node: need to match several children, same for completion
122 - float
123 - not
124
125 encoding
126 ========
127
128 - support utf-8 and other encodings
129 - example
130 - documentation
131
132 netconf example
133 ===============
134
135 - demonstration example that parses yang file and generate cli
136
137
138
139 -----------------------
140
141 readline:
142
143 [tab]  list possible completions (matches/partial only)
144 [?]    list what is expected, example:
145
146 "command [foo] toto|titi|<int>"
147
148 help("command f") ->
149   foo     (help of foo)
150   toto    (help of toto)
151   titi    (help of titi)
152   <int>   (help of int)
153
154
155 ----------------
156
157 struct names
158 ============
159
160 ideas:
161
162 - ec_node: a node that can be parsed/completed
163 - ec_parse: a tree describing the result of parse(node, input)
164 - ec_comp: a list describing the result of complete(node, input)
165
166 ec_comp_item
167
168
169 ---------------
170
171 node tree
172 =========
173
174 Example:
175
176 1  seq
177 2    option
178 3      str(foo)
179 4    or
180 5      int(1,10)
181 6      str(bar)
182 7      str(foo)
183
184 parse() returns a tree
185 =======
186
187 - each node of the tree refers to a ec_node
188 - each node points to the strvec that matches
189 - parse returns the first matching solution
190 - usually try to match as many str in the vecs (seq node)
191
192 [foo] ->
193 1 seq
194 2   option
195 4   or
196 7     str(foo)
197
198 The parse cb of the node is:
199
200 parse_cb(node, current_parse_state, strvec, *nmatch)
201
202 return values:
203 - 0: success, child->strvec is set by node (NULL = no_match)
204 - -1: error (errno is set)
205 maybe complex to use:
206 - the node must set the match (ex: "return ec_parsed_node_match()")
207 - the caller must use accessor to check if it matches or not
208
209 alternative idea for return values:
210 - >= 0: match, ret == nb_tk
211 - -1: error (errno is set)
212 - -2 or MAX_INT: success, but no match
213 This is strange to have a specific value for no match
214 With MAX_INT, this is the best (less bad) alternative
215
216 alternative idea for return values:
217 - ec_parse_result_match(n_tokens >= 0)
218 - ec_parse_result_nomatch()
219 - ec_parse_result_error(errno)
220
221 A node always try to consume the maximum number of tokens.
222 Example:
223 1  seq
224 2    option
225 3      str(foo)
226 4    str(foo)
227 5    str(bar)
228
229 [foo, foo, bar] matches
230 [foo, bar] does *not* match
231
232 complete() returns a list of possible completions
233 ==========
234
235 problems:
236 - partial completion: in a path dir/file, completion stops once
237   after the directory
238 - displayed value is not the completion token: when completing a
239   file in several subdirectories, the full path is not displayed
240 - any parent node can modify the completions, ex: add missing quotes
241   in ec_node_sh_lex(), filter completions in case of a ec_node_filter()
242 - a command line may want to display the help from the most specific
243   token, or not.
244 - some specific nodes can complete several tokens
245
246 struct item {
247   const char *str;
248   type: full, partial, unknown
249 }
250
251 full: the completion item matches token
252 partial: beginning of a completion, does not match the token
253          (good example is a directory in a path)
254 unknown: could complete, but the node does not know how
255
256 struct completion_item {
257   const char *value;
258   const char *disp;
259 }
260
261 struct completed_elt {
262   ec_parsed *parse_tree; // current tree state
263   ec_node *last;         // last node of the tree
264   list of items;         // list of items for this parse tree
265 }
266
267 struct completed {
268   list(elt)
269 }
270
271 The callback is:
272
273 complete_cb(node, current_complete_state, current_parse_state, strvec)
274 return:
275 - 0 = success, the current complete state is updated
276 - -1 = error (set errno?)
277
278
279 a node can filter the completions
280
281
282 [] ->
283   foo   3 str(foo)
284     seq
285       option
286         str(foo) <-
287
288   ""    5 int(1,10)
289     seq
290       option
291       or
292         int <-
293
294   bar   6 str(bar)
295   foo   7 str(bar)
296 ...
297
298
299 [foo, ] ->
300
301   ?       5 int(1,10)
302   seq
303     option
304       str(foo)
305     or
306       int <-
307
308   bar   6 str(bar)
309   foo   7 str(bar)
310
311
312
313 -----
314
315 changes:
316 - a completion item should contain a strvec for the value
317   (the display string remains a string)
318 - there is maybe no good reason to split in:
319   - ec_completed_item()
320   - ec_completed_item_set()
321   - ec_completed_item_set_display()
322   - ec_completed_item_add()
323
324 -----
325
326 sh_lex
327   or
328     str(foo)
329     str(foo2)
330     str(bar)
331
332 complete(sh_lex, ["'fo"])
333   complete(sh_lex, ["fo"]) -> ["foo", "foo2"]
334   
335
336 -----
337
338 #include <stdio.h>
339 #include <stdbool.h>
340
341
342 struct res {
343         int a;
344 };
345
346 static inline bool is_success(struct res r)
347 {
348         if (r.a == 0)
349                 return true;
350         return false;
351 }
352
353
354 static inline struct res res(int a)
355 {
356         struct res r;
357         r.a = a;
358         return r;
359 }
360
361 int main(void)
362 {
363         struct res r;
364
365         r = res(0);
366
367         printf("%d\n", r.a);
368         if (is_success(r))
369                 printf("success: %d\n", r.a);
370
371         r = res(1);
372
373         printf("%d\n", r.a);
374         if (is_success(r))
375                 printf("success: %d\n", r.a);
376
377         return 0;
378 }
379
380
381 ----
382
383
384 expr expr expr
385
386 [toto] | tutu
387
388 [toto [titi]]
389
390
391
392 pre_op = "!"
393 post_op = "^"
394 post = val |
395        pre_op expr |
396        "(" expr ")"
397 term = post post_op*
398 prod = term ( "*" term )*
399 sum = prod ( "+" prod )*
400 expr = sum
401
402
403 -----
404
405 break on malloc:
406
407 b debug_malloc
408 # or: b debug_realloc
409 condition <breakoint num> malloc_seq >= <value>
410
411 alternative
412
413 watch malloc_seq
414 condition <watchpoint num> malloc_seq == <value + 1>
415 run <args...>
416 c
417
418
419 ---------------
420
421