After perusing the entire Netfilter syntax tree in preparation for
autocompletion, I've made a preliminary analysis that 'add_cmd'
non-terminal symbol is in need of a reduction into a smaller parser element.
For those needing a diagram, I've posted the XHTML file of Netfilter
railroad diagram in:
https://github.com/egberts/vim-nftables/blob/master/doc/nftables-railroad-chart.xhtml
The railroad chart of Netfilter 'nft' CLI needs to be viewed using a web
browser as GitHub website doesn't render a standalone XHTML file, but
you can view it locally and nicely using a 'file:///' in the URL box.
The current 'add_cmd' symbol in Netfilter Bison (src/parser_bison.c)
comprises of the following required first (1st) token symbols:
table
chain
rule
ip
ip6
inet
arp
bridge
netdev
<table_id>
set
map
flowtable
element
counter
quota
ct
limit
secmark
synproxy
The current 'add_cmd' parser is supporting some keywords that the 'nft'
CLI tool does not support. This also interferes with any planned
autocompletion effort.
An updated 'add_cmd' non-terminal symbol could be updated to match the
current 'nft' CLI tool:
new_add_cmd
table
chain
rule
ip
ip6
inet
arp
bridge
netdev
<table_id>
What remains unchanged is the 'table_block' element (that is inside the
table [ <family_spec_explicit> ] <table_id> <chain_id>
{
table_block
};
which would already covered the basic usage with the following starting
token symbols:
create
chain
rule
ip
ip6
inet
arp
bridge
netdev
<table_id>
set
map
flowtable
element
counter
quota
ct
limit
secmark
synproxy
The 'create_cmd' non-terminal symbol would already cover the remaining
for creation needs of Netfilter:
create
table
chain
set
map
flowtable
element
counter
quota
ct
limit
secmark
synproxy
This would accelerate ANY autocompletion greatly for our ideal
multi-context multi-token manner, as well as a JSON outputter.
If the above proves to be ideal, then the true first/starting token list
would be covered by the 'line' and 'base_cmd' (and otherwise indicated):
chain
rule
ip
ip6
inet
arp
bridge
netdev
<table_identifier>
replace
create
insert
delete
get
list
reset
flush
rename
import
export
monitor
describe
destroy
include (common_block)
define (common_block)
redefine (common_block)
undefine (common_block)
error (common_block)
';' (stmt_separator)
'\n' (stmt_separator)
Always looking for a better way ...
S Egbert