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