{"id":30288431,"url":"https://github.com/egberts/nft-token-first","last_synced_at":"2025-08-16T22:37:13.794Z","repository":{"id":304414382,"uuid":"1018720569","full_name":"egberts/nft-token-first","owner":"egberts","description":"Show what the next tokens are from anywhere in the Netfilter NFT CLI syntax tree","archived":false,"fork":false,"pushed_at":"2025-07-12T23:23:49.000Z","size":555,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-13T00:26:55.328Z","etag":null,"topics":["bison","dhparse","ebnf","ebnf-syntax","netfilter","nft","nft-app","nftables","nftables-ui"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/egberts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-12T22:15:04.000Z","updated_at":"2025-07-12T23:23:52.000Z","dependencies_parsed_at":"2025-07-13T00:26:58.105Z","dependency_job_id":"014dba55-b551-4134-820a-38ea858a372a","html_url":"https://github.com/egberts/nft-token-first","commit_stats":null,"previous_names":["egberts/nft-token-first"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/egberts/nft-token-first","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egberts%2Fnft-token-first","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egberts%2Fnft-token-first/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egberts%2Fnft-token-first/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egberts%2Fnft-token-first/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egberts","download_url":"https://codeload.github.com/egberts/nft-token-first/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egberts%2Fnft-token-first/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270781209,"owners_count":24643807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bison","dhparse","ebnf","ebnf-syntax","netfilter","nft","nft-app","nftables","nftables-ui"],"created_at":"2025-08-16T22:37:11.759Z","updated_at":"2025-08-16T22:37:13.773Z","avatar_url":"https://github.com/egberts.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nThis is about the Netfilter `nft` CLI terminal app.\n\nGiven a token, list all the next valid tokens at the NFT command prompt, given a certain point in the syntax tree.\n\nFor example, Bison `input` symbol would produce the following token:\n\n\n        'include'\n        'undefine'\n        'error'\n        'define'\n        'redefine'\n        '\\n'\n        ';'\n        'add'\n        'table'\n        'chain'\n        'rule'\n        \u003cidentifier\u003e\n        'last'\n        'ip'\n        'ip6'\n        'inet'\n        'netdev'\n        'bridge'\n        'arp'\n        'accept'\n        'drop'\n        'continue'\n        'jump'\n        'goto'\n        'return'\n        'limit'\n        'secmark'\n        'synproxy'\n        'replace'\n        'create'\n        'insert'\n        'delete'\n        'get'\n        'list'\n        'reset'\n        'flush'\n        'rename'\n        'import'\n        'export'\n        'monitor'\n        'describe'\n        'destroy'\n\ndhcparser\\_nexus/dhparse-working.py is that starting Python point.\n\nChanging the variable 'vim\\_syntax\\_group\\_name\\_target' gets you your different objective.\n\n## WHY ##\n\nI needed to study autocompletion of Netfilter 'nft' CLI tool, which is not much (at the moment).\n\n\n## HOW ##\n\nIn Netfilter NFT CLI parse table, there are over 1,400 edge-state transitions.  It makes zero sense to code that up manually.\n\nI leveraged Bison tool into reading Netfilter nftables' and outputting a rudimentary EBNF (Extended Backus-Naur Form) syntax.\n\nAnd used a two-stage parser.\n\n\n## MORE DEETS ##  \n\nI designed a two-stage parser:\n   1. how to read EBNF (in DHParse-format)\n   2. how to read Netfilter `nft` CLI (in EBNF-format)\n\nFor the first-stage, I leveraged [DHParser](https://dhparser.readthedocs.io/en/latest/), a [PEG parser](https://egbert.net/blog/articles/parsing-in-python-compendium.html) to read a parser file.\n\nI used a [EBNF syntax](https://github.com/egberts/nft-token-first/blob/master/dhcparser_nexus/ebnf-flexible.dhparse) file that enables reading of any EBNF file (a file that describes EBNF, ... in EBNF): That file format is for DHParse-only.  \n\nFor the second-stage, I shoehorned Netfilter NFT CLI EBNF ... AGAIN ... thru the Python DHParser(\"EBNF\") but this time using Netfilter NFT EBNF (supplied by Bison and [bison\\_parse.y](https://git.netfilter.org/nftables/tree/src/parser_bison.y)  source file).\n\nThen I wrote a leaf-tree navigator to look for only the first following token(s) (and not to go down any deeper).\n\n\n## OTHERS ##\n\ndhparser\\_project subdirectory and its development files were made by executing:\n\n    ~/work/github/DHParser/scripts/dhparser.py\n    # and selecting option 1 to create a project and entering in `dhparser_project` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegberts%2Fnft-token-first","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegberts%2Fnft-token-first","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegberts%2Fnft-token-first/lists"}