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
51 X pass the current parsed state when parsing/completing
53 - new node "condition"
63 X register nodes by name
64 X interface to add attributes: all nodes must be configurable through a
72 X yaml interface to create nodes
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
84 - mini shell: cd, ls, cat, stat
85 - mini network console based on ip
86 - dialog-like for use in shell
93 - generate automatic api doc
95 - coding rules, process
98 - say that it stops at first match (no ambigous support)
99 - say that completion must be exhaustive
105 - split libs, tests and examples
114 - complete automatic tests with "make test"
120 X node which always matches
121 X file + partial completion
123 - fusion node: need to match several children, same for completion?
126 - reparse: parse a tree with received strvec, then another tree
127 with strvec generated from first tree
132 - support utf-8 and other encodings
139 / demonstration example that parses yang file and generate cli
143 -----------------------
147 [tab] list possible completions (matches/partial only)
148 [?] list what is expected, example:
150 "command [foo] toto|titi|<int>"
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)
188 parse() returns a tree
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)
202 The parse cb of the node is:
204 parse_cb(node, current_parse_state, strvec, *nmatch)
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
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
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)
225 A node always try to consume the maximum number of tokens.
233 [foo, foo, bar] matches
234 [foo, bar] does *not* match
236 complete() returns a list of possible completions
240 - partial completion: in a path dir/file, completion stops once
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
248 - some specific nodes can complete several tokens
252 type: full, partial, unknown
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
260 struct completion_item {
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
277 complete_cb(node, current_complete_state, current_parse_state, strvec)
279 - 0 = success, the current complete state is updated
280 - -1 = error (set errno?)
283 a node can filter the completions
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()
336 complete(sh_lex, ["'fo"])
337 complete(sh_lex, ["fo"]) -> ["foo", "foo2"]
350 static inline bool is_success(struct res r)
358 static inline struct res res(int a)
373 printf("success: %d\n", r.a);
379 printf("success: %d\n", r.a);
402 prod = term ( "*" term )*
403 sum = prod ( "+" prod )*
412 # or: b debug_realloc
413 condition <breakoint num> malloc_seq >= <value>
418 condition <watchpoint num> malloc_seq == <value + 1>
426 about split in several libraries
428 There are several options:
430 1/ one library, config options to select libyaml, libedit
431 - need to manage dependencies in build system
433 2/ one library for ecoli-core, one for ecoli-yaml, one for
437 3/ one library with core + yaml + edit
438 dependency is managed at runtime