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?
52 X pass the current parsed state when parsing/completing
54 - new node "condition"
64 X register nodes by name
65 X interface to add attributes: all nodes must be configurable through a
73 X yaml interface to create nodes
79 - example which parses arguments (argc/argv)
80 - example that acts as bash completion (ip link ?)
81 - calculator example (var assignation, expression evaluation)
82 - example with libedit
83 - mini script language
85 - mini shell: cd, ls, cat, stat
86 - mini network console based on ip
87 - dialog-like for use in shell
94 - generate automatic api doc
96 - coding rules, process
99 - say that it stops at first match (no ambigous support)
100 - say that completion must be exhaustive
106 - split libs, tests and examples
115 - complete automatic tests with "make test"
121 X node which always matches
122 X file + partial completion
124 - fusion node: need to match several children, same for completion?
127 - reparse: parse a tree with received strvec, then another tree
128 with strvec generated from first tree
133 - support utf-8 and other encodings
140 / demonstration example that parses yang file and generate cli
144 -----------------------
148 [tab] list possible completions (matches/partial only)
149 [?] list what is expected, example:
151 "command [foo] toto|titi|<int>"
167 - ec_node: a node that can be parsed/completed
168 - ec_parse: a tree describing the result of parse(node, input)
169 - ec_comp: a list describing the result of complete(node, input)
189 parse() returns a tree
192 - each node of the tree refers to a ec_node
193 - each node points to the strvec that matches
194 - parse returns the first matching solution
195 - usually try to match as many str in the vecs (seq node)
203 The parse cb of the node is:
205 parse_cb(node, current_parse_state, strvec, *nmatch)
208 - 0: success, child->strvec is set by node (NULL = no_match)
209 - -1: error (errno is set)
210 maybe complex to use:
211 - the node must set the match (ex: "return ec_parsed_node_match()")
212 - the caller must use accessor to check if it matches or not
214 alternative idea for return values:
215 - >= 0: match, ret == nb_tk
216 - -1: error (errno is set)
217 - -2 or MAX_INT: success, but no match
218 This is strange to have a specific value for no match
219 With MAX_INT, this is the best (less bad) alternative
221 alternative idea for return values:
222 - ec_parse_result_match(n_tokens >= 0)
223 - ec_parse_result_nomatch()
224 - ec_parse_result_error(errno)
226 A node always try to consume the maximum number of tokens.
234 [foo, foo, bar] matches
235 [foo, bar] does *not* match
237 complete() returns a list of possible completions
241 - partial completion: in a path dir/file, completion stops once
243 - displayed value is not the completion token: when completing a
244 file in several subdirectories, the full path is not displayed
245 - any parent node can modify the completions, ex: add missing quotes
246 in ec_node_sh_lex(), filter completions in case of a ec_node_filter()
247 - a command line may want to display the help from the most specific
249 - some specific nodes can complete several tokens
253 type: full, partial, unknown
256 full: the completion item matches token
257 partial: beginning of a completion, does not match the token
258 (good example is a directory in a path)
259 unknown: could complete, but the node does not know how
261 struct completion_item {
266 struct completed_elt {
267 ec_parsed *parse_tree; // current tree state
268 ec_node *last; // last node of the tree
269 list of items; // list of items for this parse tree
278 complete_cb(node, current_complete_state, current_parse_state, strvec)
280 - 0 = success, the current complete state is updated
281 - -1 = error (set errno?)
284 a node can filter the completions
321 - a completion item should contain a strvec for the value
322 (the display string remains a string)
323 - there is maybe no good reason to split in:
324 - ec_completed_item()
325 - ec_completed_item_set()
326 - ec_completed_item_set_display()
327 - ec_completed_item_add()
337 complete(sh_lex, ["'fo"])
338 complete(sh_lex, ["fo"]) -> ["foo", "foo2"]
351 static inline bool is_success(struct res r)
359 static inline struct res res(int a)
374 printf("success: %d\n", r.a);
380 printf("success: %d\n", r.a);
403 prod = term ( "*" term )*
404 sum = prod ( "+" prod )*
413 # or: b debug_realloc
414 condition <breakoint num> malloc_seq >= <value>
419 condition <watchpoint num> malloc_seq == <value + 1>
427 about split in several libraries
429 There are several options:
431 1/ one library, config options to select libyaml, libedit
432 - need to manage dependencies in build system
434 2/ one library for ecoli-core, one for ecoli-yaml, one for
438 3/ one library with core + yaml + edit
439 dependency is managed at runtime
444 current naming: ec_node_parse* and ec_comp_complete* are not
449 free ec_complete_free()
450 action ec_comp_complete()
451 action ec_comp_complete_strvec()
452 action ec_comp_dump()
453 action ec_comp_merge()
454 accessors ec_comp_get()
459 action ec_node_parse()
460 action ec_node_parse_strvec()
471 free ec_strvec_free()
478 - struct name must not be a verb (ex: not ec_parse)
479 - allocator is the name of struct
480 - actions are <structname>_<verb>() except for basic/common actions
481 - basic actions are ec_<verb>()
482 - accessors (get) are <structname>_<field>()
483 - accessors (set) are <structname>_set_<field>()
486 XXX list all functions to be sure
487 XXX this could go in documentation (coding rules)
493 action ec_complete_strvec()
494 action ec_comp_dump()
495 action ec_comp_merge()
496 accessors ec_comp_id()
497 accessors ec_comp_attrs()
499 (pnode means parsed node)
504 action ec_parse_strvec()
507 (node means grammar node)
512 accessors ec_node_get*()
516 free ec_strvec_free()