4 X evaluate expression tree in ec_tk_expr
12 X ec_completed_item_update()
13 X ec_completed_item_set_display_value()
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
23 - use linux style (update .emacs)
25 - check return values (-1 or NULL) + use errno
26 - check missing static / const
28 - check all completion nodes
30 - size_t or unsigned int?
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
39 - try to hide structures
40 X anything better than weakref?
41 - add ec_node_defaults.[ch] providing usual implementations of node methods
43 / ELOOP in case of loop
45 - sh_lex to provide offsets in attributes
46 - accessors for all structs
47 - private vs user attributes?
49 - limit max completions
54 X pass the current parsed state when parsing/completing
56 - new node "condition"
66 X register nodes by name
67 X interface to add attributes: all nodes must be configurable through a
75 X yaml interface to create nodes
81 - example which parses arguments (argc/argv)
82 - example that acts as bash completion (ip link ?)
83 - calculator example (var assignation, expression evaluation)
84 - example with libedit
85 - mini script language
87 - mini shell: cd, ls, cat, stat
88 - mini network console based on ip
89 - dialog-like for use in shell
90 - pcap https://github.com/the-tcpdump-group/libpcap/blob/master/grammar.y
97 - generate automatic api doc
99 - coding rules, process
102 - say that it stops at first match (no ambigous support)
103 - say that completion must be exhaustive
109 - split libs, tests and examples
118 - complete automatic tests with "make test"
124 X node which always matches
125 X file + partial completion
127 - fusion node: need to match several children, same for completion?
130 - reparse: parse a tree with received strvec, then another tree
131 with strvec generated from first tree
136 - support utf-8 and other encodings
143 / demonstration example that parses yang file and generate cli
147 -----------------------
151 [tab] list possible completions (matches/partial only)
152 [?] list what is expected, example:
154 "command [foo] toto|titi|<int>"
170 - ec_node: a node that can be parsed/completed
171 - ec_parse: a tree describing the result of parse(node, input)
172 - ec_comp: a list describing the result of complete(node, input)
192 parse() returns a tree
195 - each node of the tree refers to a ec_node
196 - each node points to the strvec that matches
197 - parse returns the first matching solution
198 - usually try to match as many str in the vecs (seq node)
206 The parse cb of the node is:
208 parse_cb(node, current_parse_state, strvec, *nmatch)
211 - 0: success, child->strvec is set by node (NULL = no_match)
212 - -1: error (errno is set)
213 maybe complex to use:
214 - the node must set the match (ex: "return ec_parsed_node_match()")
215 - the caller must use accessor to check if it matches or not
217 alternative idea for return values:
218 - >= 0: match, ret == nb_tk
219 - -1: error (errno is set)
220 - -2 or MAX_INT: success, but no match
221 This is strange to have a specific value for no match
222 With MAX_INT, this is the best (less bad) alternative
224 alternative idea for return values:
225 - ec_parse_result_match(n_tokens >= 0)
226 - ec_parse_result_nomatch()
227 - ec_parse_result_error(errno)
229 A node always try to consume the maximum number of tokens.
237 [foo, foo, bar] matches
238 [foo, bar] does *not* match
240 complete() returns a list of possible completions
244 - partial completion: in a path dir/file, completion stops once
246 - displayed value is not the completion token: when completing a
247 file in several subdirectories, the full path is not displayed
248 - any parent node can modify the completions, ex: add missing quotes
249 in ec_node_sh_lex(), filter completions in case of a ec_node_filter()
250 - a command line may want to display the help from the most specific
252 - some specific nodes can complete several tokens
256 type: full, partial, unknown
259 full: the completion item matches token
260 partial: beginning of a completion, does not match the token
261 (good example is a directory in a path)
262 unknown: could complete, but the node does not know how
264 struct completion_item {
269 struct completed_elt {
270 ec_parsed *parse_tree; // current tree state
271 ec_node *last; // last node of the tree
272 list of items; // list of items for this parse tree
281 complete_cb(node, current_complete_state, current_parse_state, strvec)
283 - 0 = success, the current complete state is updated
284 - -1 = error (set errno?)
287 a node can filter the completions
324 - a completion item should contain a strvec for the value
325 (the display string remains a string)
326 - there is maybe no good reason to split in:
327 - ec_completed_item()
328 - ec_completed_item_set()
329 - ec_completed_item_set_display()
330 - ec_completed_item_add()
340 complete(sh_lex, ["'fo"])
341 complete(sh_lex, ["fo"]) -> ["foo", "foo2"]
354 static inline bool is_success(struct res r)
362 static inline struct res res(int a)
377 printf("success: %d\n", r.a);
383 printf("success: %d\n", r.a);
406 prod = term ( "*" term )*
407 sum = prod ( "+" prod )*
416 # or: b debug_realloc
417 condition <breakoint num> malloc_seq >= <value>
422 condition <watchpoint num> malloc_seq == <value + 1>
430 about split in several libraries
432 There are several options:
434 1/ one library, config options to select libyaml, libedit
435 - need to manage dependencies in build system
437 2/ one library for ecoli-core, one for ecoli-yaml, one for
441 3/ one library with core + yaml + edit
442 dependency is managed at runtime
447 current naming: ec_node_parse* and ec_comp_complete* are not
452 free ec_complete_free()
453 action ec_comp_complete()
454 action ec_comp_complete_strvec()
455 action ec_comp_dump()
456 action ec_comp_merge()
457 accessors ec_comp_get()
462 action ec_node_parse()
463 action ec_node_parse_strvec()
474 free ec_strvec_free()
481 - struct name must not be a verb (ex: not ec_parse)
482 - allocator is the name of struct
483 - actions are <structname>_<verb>() except for basic/common actions
484 - basic actions are ec_<verb>()
485 - accessors (get) are <structname>_<field>()
486 - accessors (set) are <structname>_set_<field>()
489 XXX list all functions to be sure
490 XXX this could go in documentation (coding rules)
496 action ec_complete_strvec()
497 action ec_comp_dump()
498 action ec_comp_merge()
499 accessors ec_comp_id()
500 accessors ec_comp_attrs()
502 (pnode means parsed node)
507 action ec_parse_strvec()
510 (node means grammar node)
515 accessors ec_node_get*()
519 free ec_strvec_free()