Commit graph

36 commits

Author SHA1 Message Date
Quentin Young d0bfb22c22 lib: Initial refactor pass on CLI backend
Shotgun commit:
* Remove shim sources from Makefile.am
* Move new types to command.c / command.h
* Rewrite command.c / command.h
* Refactor shim types to real types in matcher
  and parser
* Initial refactor pass on vty.c

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-19 23:46:51 +00:00
Quentin Young 9286efabb9 lib: Allow nesting options in selectors
Options may now be nested in selectors as long
as they are not the first token in sequence.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-18 20:32:21 +00:00
Quentin Young 535ef5569a lib: Add support for selectors inside options
Selectors may be nested inside options [<like|so>].
Removed the ability to make multipart options [like|so].

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-14 22:04:53 +00:00
Quentin Young ee551f4827 lib: Fix various matching bugs
Missed a copy, disambigs forgot to walkback

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-13 01:16:22 +00:00
Quentin Young fe2e10e8d8 lib: Fix uninitialized pointer segfault
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-08 21:07:55 +00:00
Quentin Young d8074cc04c lib: Add <cr> text for end nodes
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-08 20:27:39 +00:00
Quentin Young 97f13f0865 lib: Fix deduplication bug, reinstate graph print
Comparing the wrong nodes led to duplication during
graph construction, fixed. Also update graph pretty
print to use new graph struct.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-07 23:02:39 +00:00
Quentin Young 1eb5e8dcd1 lib: Continue matching system refactor
Most things back to working, all CLI units refactored
to use improved graph implementation.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-07 04:05:07 +00:00
Quentin Young 7a6ded4096 lib: Refactor command_parse.y for graph ds
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-02 20:19:03 +00:00
Quentin Young 55589d304c lib: Refactor CLI interface function names
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-11 17:50:58 +00:00
Quentin Young ca90e05104 lib: Add completion string convenience functions
And set END_GN default text to <cr>, and scrub
a coupld of extraneous files

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-10 18:31:15 +00:00
Quentin Young 78602b8029 lib: Remove unnecessary node pointer
Selector and option heads had pointers to their
ends, but this turned out to be unnecessary

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-09 21:31:11 +00:00
Quentin Young e52c05cd80 lib: Revert breaking change to cmp_node
Bad conditional refactor broke graph deduplication
and thus disambiguation precedence

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-09 20:28:35 +00:00
Quentin Young 07079d78bc lib: Fix use after free in lexer
Fix occasional bug where deleting flex's input
buffer happens earlier than flex expects

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-09 19:30:40 +00:00
Quentin Young 4427e9b3ee lib: Fix various minor bugs
- cmd_make_strvec returns null pointer if str
  begins with a '#'
- disallow options nested options
- NULL out state variable in parser
- flip backwards comparison
- fix memory leak in lexer

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-09 17:37:01 +00:00
Quentin Young 1ab84bf32f lib: Code cleanup, formatting, & headers
Gnu-style code, add copyright headers, cleanup some
random style issues, shuffle around code into
relevant units, add docs.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-08 21:11:14 +00:00
Quentin Young 51fc9379a9 lib: Major parser refactor
Lots of cleanup, code consolidation, organizational
improvements.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-05 20:50:42 +00:00
Quentin Young 0aa2c2ff01 lib: Add docstring support
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-05 16:41:42 +00:00
Quentin Young b389976966 lib: Unrefactor to signed long long for ranges
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-04 18:16:26 +00:00
Quentin Young ef955a80a6 lib: Allow optional whitespace in ranges
Makes ranges where both endpoints are negative
somewhat more readable. Also validate ranges.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-04 16:39:15 +00:00
Quentin Young 5a8bbed0b1 lib: Add support for negative ranges
And convert range delimiters to signed int

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-04 16:18:31 +00:00
Quentin Young f4b0c72e53 lib: Refactor format parser
Also fix a bug where selector elements beginning
with the same word are only parsed once

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-04 00:58:12 +00:00
Quentin Young 88255c7cfb lib: Add vararg support
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-02 16:40:03 +00:00
Quentin Young e648e61a74 lib: Fix OOB range parses, variable matches
Variables now allow strings beginning with numbers
to match, ranges and numbers are now long long to
fix OOB parses resulting in integer wraparounds.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-01 18:36:30 +00:00
Quentin Young 1a8c390d4a lib: Fixed bad node copy, modified token regex
When building argv for matched command, only the
last node was being copied to argv; the rest were
added by reference. Additionally the regex for
certain tokens was too restrictive and disallowed
characters allowed by the old parser; these have
been reinstated.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-01 17:03:39 +00:00
Quentin Young de9d7e4f3c lib: Cleanup some memory issues in CLI
Various memory leaks have been fixed and the quagga
memory macros are in use. Also consolidated the argv
and matching code into one graph traversal.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-29 15:54:03 +00:00
Quentin Young 5a5d576b34 lib: Cleanup parser memory management
Free as appropriate. Additionally add new type
of node to demark graph head (START_GN).

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-27 04:17:51 +00:00
Quentin Young eceb106640 lib: Add matching and argv support
Queries may be run against DFA's to find matching
cmd_element, and argument lists may be constructed.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-27 01:35:46 +00:00
Quentin Young a53fbbf5f0 lib: Incremental matching improvement
Shotgun changes to matching system

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-26 14:02:36 +00:00
Quentin Young 880e24a1e4 lib: Reorganize some matching stuff
Introduce new node type, END_GN, and remove
is_leaf flags. Reorganize command_match.c & remove
internal functions from command_match.h. Start
rewriting command.h in command_new.h with changes
for new backend.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-22 19:04:16 +00:00
Quentin Young 18be0e599d lib: Mostly complete matcher
Input matching and completions works. Still some
rough edges.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-21 21:38:03 +00:00
Quentin Young 9d0662e009 lib: Break up functions, begin matcher
Moved test hook out of command.c into vtysh.c,
renamed graph modules, added matching code

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-19 21:14:27 +00:00
Quentin Young 340a2b4ac0 lib: Implement node comparison function
Implement comparator for nodes, some miscellaneous cleanup.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-19 17:06:11 +00:00
Quentin Young 4b0abf2434 lib: Fix some DFA construction bugs
Options get null paths, parser state is properly
cleaned up, caller passes start node

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-18 16:16:36 +00:00
Quentin Young 478bdaeb3b lib: Finish implementing grammar, DFA construction
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-17 21:49:16 +00:00
Quentin Young 2a23ca6e52 lib: Change some includes
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-12 15:05:06 +00:00
Renamed from lib/command.y (Browse further)