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