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 - anything better than weakref?
41 - add ec_node_defaults.[ch] providing usual implementations of node methods
47 X pass the current parsed state when parsing/completing
49 - new node "condition"
59 X register nodes by name
60 - interface to add attributes: all nodes must be configurable through a
68 - yaml interface to create nodes
74 - example which parses arguments (argc/argv)
75 - example that acts as bash completion (ip link ?)
76 - calculator example (var assignation, expression evaluation)
77 - example with libedit
78 - mini script language
80 - mini shell: cd, ls, cat, stat
81 - mini network console based on ip
88 - generate automatic api doc
90 - coding rules, process
93 - say that it stops at first match (no ambigous support)
94 - say that completion must be exhaustive
100 - split libs, tests and examples
108 - complete automatic tests with "make test"
114 - node which always matches
115 - file + partial completion
117 - fusion node: need to match several children, same for completion
124 - support utf-8 and other encodings
131 - demonstration example that parses yang file and generate cli
135 -----------------------
139 [tab] list possible completions (matches/partial only)
140 [?] list what is expected, example:
142 "command [foo] toto|titi|<int>"
158 - ec_node: a node that can be parsed/completed
159 - ec_parse: a tree describing the result of parse(node, input)
160 - ec_comp: a list describing the result of complete(node, input)
180 parse() returns a tree
183 - each node of the tree refers to a ec_node
184 - each node points to the strvec that matches
185 - parse returns the first matching solution
186 - usually try to match as many str in the vecs (seq node)
194 The parse cb of the node is:
196 parse_cb(node, current_parse_state, strvec, *nmatch)
199 - 0: success, child->strvec is set by node (NULL = no_match)
200 - -1: error (errno is set)
201 maybe complex to use:
202 - the node must set the match (ex: "return ec_parsed_node_match()")
203 - the caller must use accessor to check if it matches or not
205 alternative idea for return values:
206 - >= 0: match, ret == nb_tk
207 - -1: error (errno is set)
208 - -2 or MAX_INT: success, but no match
209 This is strange to have a specific value for no match
210 With MAX_INT, this is the best (less bad) alternative
212 alternative idea for return values:
213 - ec_parse_result_match(n_tokens >= 0)
214 - ec_parse_result_nomatch()
215 - ec_parse_result_error(errno)
217 A node always try to consume the maximum number of tokens.
225 [foo, foo, bar] matches
226 [foo, bar] does *not* match
228 complete() returns a list of possible completions
232 - partial completion: in a path dir/file, completion stops once
234 - displayed value is not the completion token: when completing a
235 file in several subdirectories, the full path is not displayed
236 - any parent node can modify the completions, ex: add missing quotes
237 in ec_node_sh_lex(), filter completions in case of a ec_node_filter()
238 - a command line may want to display the help from the most specific
240 - some specific nodes can complete several tokens
244 type: full, partial, unknown
247 full: the completion item matches token
248 partial: beginning of a completion, does not match the token
249 (good example is a directory in a path)
250 unknown: could complete, but the node does not know how
252 struct completion_item {
257 struct completed_elt {
258 ec_parsed *parse_tree; // current tree state
259 ec_node *last; // last node of the tree
260 list of items; // list of items for this parse tree
269 complete_cb(node, current_complete_state, current_parse_state, strvec)
271 - 0 = success, the current complete state is updated
272 - -1 = error (set errno?)
275 a node can filter the completions
312 - a completion item should contain a strvec for the value
313 (the display string remains a string)
314 - there is maybe no good reason to split in:
315 - ec_completed_item()
316 - ec_completed_item_set()
317 - ec_completed_item_set_display()
318 - ec_completed_item_add()
328 complete(sh_lex, ["'fo"])
329 complete(sh_lex, ["fo"]) -> ["foo", "foo2"]
342 static inline bool is_success(struct res r)
350 static inline struct res res(int a)
365 printf("success: %d\n", r.a);
371 printf("success: %d\n", r.a);
394 prod = term ( "*" term )*
395 sum = prod ( "+" prod )*
406 condition <breakpoint num> seq == <value>