add ecoli_editline and enhance yaml parser
[protos/libecoli.git] / todo.txt
1 tk_cmd
2 ======
3
4 X evaluate expression tree in ec_tk_expr
5 X cmd token
6 X 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 X 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 X 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 X 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 X interface to add attributes: all nodes must be configurable through a
65   generic api:
66   X attr string
67   X attr string list
68   X attr node
69   X attr node list
70   X attr int
71
72 X 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 - dialog-like for use in shell
87
88 doc
89 ===
90
91 - overview
92 - add api doc in .h
93 - generate automatic api doc
94 - architecture
95 - coding rules, process
96 - each node
97 - allocation model
98 - say that it stops at first match (no ambigous support)
99 - say that completion must be exhaustive
100
101 build framework
102 ===============
103
104 - .map files for API
105 - split libs, tests and examples
106 - add make help
107 - add make config
108 - -fvisibility=
109 - use meson
110
111 tests
112 =====
113
114 - complete automatic tests with "make test"
115
116 new nodes
117 =========
118
119 - regexp
120 X node which always matches
121 X file + partial completion
122 - ether, ip, network
123 - fusion node: need to match several children, same for completion?
124 - float
125 - not
126
127 encoding
128 ========
129
130 - support utf-8 and other encodings
131 - example
132 - documentation
133
134 netconf example
135 ===============
136
137 / demonstration example that parses yang file and generate cli
138
139
140
141 -----------------------
142
143 readline:
144
145 [tab]  list possible completions (matches/partial only)
146 [?]    list what is expected, example:
147
148 "command [foo] toto|titi|<int>"
149
150 help("command f") ->
151   foo     (help of foo)
152   toto    (help of toto)
153   titi    (help of titi)
154   <int>   (help of int)
155
156
157 ----------------
158
159 struct names
160 ============
161
162 ideas:
163
164 - ec_node: a node that can be parsed/completed
165 - ec_parse: a tree describing the result of parse(node, input)
166 - ec_comp: a list describing the result of complete(node, input)
167
168 ec_comp_item
169
170
171 ---------------
172
173 node tree
174 =========
175
176 Example:
177
178 1  seq
179 2    option
180 3      str(foo)
181 4    or
182 5      int(1,10)
183 6      str(bar)
184 7      str(foo)
185
186 parse() returns a tree
187 =======
188
189 - each node of the tree refers to a ec_node
190 - each node points to the strvec that matches
191 - parse returns the first matching solution
192 - usually try to match as many str in the vecs (seq node)
193
194 [foo] ->
195 1 seq
196 2   option
197 4   or
198 7     str(foo)
199
200 The parse cb of the node is:
201
202 parse_cb(node, current_parse_state, strvec, *nmatch)
203
204 return values:
205 - 0: success, child->strvec is set by node (NULL = no_match)
206 - -1: error (errno is set)
207 maybe complex to use:
208 - the node must set the match (ex: "return ec_parsed_node_match()")
209 - the caller must use accessor to check if it matches or not
210
211 alternative idea for return values:
212 - >= 0: match, ret == nb_tk
213 - -1: error (errno is set)
214 - -2 or MAX_INT: success, but no match
215 This is strange to have a specific value for no match
216 With MAX_INT, this is the best (less bad) alternative
217
218 alternative idea for return values:
219 - ec_parse_result_match(n_tokens >= 0)
220 - ec_parse_result_nomatch()
221 - ec_parse_result_error(errno)
222
223 A node always try to consume the maximum number of tokens.
224 Example:
225 1  seq
226 2    option
227 3      str(foo)
228 4    str(foo)
229 5    str(bar)
230
231 [foo, foo, bar] matches
232 [foo, bar] does *not* match
233
234 complete() returns a list of possible completions
235 ==========
236
237 problems:
238 - partial completion: in a path dir/file, completion stops once
239   after the directory
240 - displayed value is not the completion token: when completing a
241   file in several subdirectories, the full path is not displayed
242 - any parent node can modify the completions, ex: add missing quotes
243   in ec_node_sh_lex(), filter completions in case of a ec_node_filter()
244 - a command line may want to display the help from the most specific
245   token, or not.
246 - some specific nodes can complete several tokens
247
248 struct item {
249   const char *str;
250   type: full, partial, unknown
251 }
252
253 full: the completion item matches token
254 partial: beginning of a completion, does not match the token
255          (good example is a directory in a path)
256 unknown: could complete, but the node does not know how
257
258 struct completion_item {
259   const char *value;
260   const char *disp;
261 }
262
263 struct completed_elt {
264   ec_parsed *parse_tree; // current tree state
265   ec_node *last;         // last node of the tree
266   list of items;         // list of items for this parse tree
267 }
268
269 struct completed {
270   list(elt)
271 }
272
273 The callback is:
274
275 complete_cb(node, current_complete_state, current_parse_state, strvec)
276 return:
277 - 0 = success, the current complete state is updated
278 - -1 = error (set errno?)
279
280
281 a node can filter the completions
282
283
284 [] ->
285   foo   3 str(foo)
286     seq
287       option
288         str(foo) <-
289
290   ""    5 int(1,10)
291     seq
292       option
293       or
294         int <-
295
296   bar   6 str(bar)
297   foo   7 str(bar)
298 ...
299
300
301 [foo, ] ->
302
303   ?       5 int(1,10)
304   seq
305     option
306       str(foo)
307     or
308       int <-
309
310   bar   6 str(bar)
311   foo   7 str(bar)
312
313
314
315 -----
316
317 changes:
318 - a completion item should contain a strvec for the value
319   (the display string remains a string)
320 - there is maybe no good reason to split in:
321   - ec_completed_item()
322   - ec_completed_item_set()
323   - ec_completed_item_set_display()
324   - ec_completed_item_add()
325
326 -----
327
328 sh_lex
329   or
330     str(foo)
331     str(foo2)
332     str(bar)
333
334 complete(sh_lex, ["'fo"])
335   complete(sh_lex, ["fo"]) -> ["foo", "foo2"]
336   
337
338 -----
339
340 #include <stdio.h>
341 #include <stdbool.h>
342
343
344 struct res {
345         int a;
346 };
347
348 static inline bool is_success(struct res r)
349 {
350         if (r.a == 0)
351                 return true;
352         return false;
353 }
354
355
356 static inline struct res res(int a)
357 {
358         struct res r;
359         r.a = a;
360         return r;
361 }
362
363 int main(void)
364 {
365         struct res r;
366
367         r = res(0);
368
369         printf("%d\n", r.a);
370         if (is_success(r))
371                 printf("success: %d\n", r.a);
372
373         r = res(1);
374
375         printf("%d\n", r.a);
376         if (is_success(r))
377                 printf("success: %d\n", r.a);
378
379         return 0;
380 }
381
382
383 ----
384
385
386 expr expr expr
387
388 [toto] | tutu
389
390 [toto [titi]]
391
392
393
394 pre_op = "!"
395 post_op = "^"
396 post = val |
397        pre_op expr |
398        "(" expr ")"
399 term = post post_op*
400 prod = term ( "*" term )*
401 sum = prod ( "+" prod )*
402 expr = sum
403
404
405 -----
406
407 break on malloc:
408
409 b debug_malloc
410 # or: b debug_realloc
411 condition <breakoint num> malloc_seq >= <value>
412
413 alternative
414
415 watch malloc_seq
416 condition <watchpoint num> malloc_seq == <value + 1>
417 run <args...>
418 c
419
420
421 ---------------
422
423