Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghettovoice/abnf
Package abnf generates parsers from ABNF grammar (RFC 5234, RFC 7405).
https://github.com/ghettovoice/abnf
abnf
Last synced: 3 months ago
JSON representation
Package abnf generates parsers from ABNF grammar (RFC 5234, RFC 7405).
- Host: GitHub
- URL: https://github.com/ghettovoice/abnf
- Owner: ghettovoice
- License: mit
- Created: 2022-11-11T12:32:38.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-09T06:27:57.000Z (4 months ago)
- Last Synced: 2024-10-12T09:06:28.769Z (3 months ago)
- Topics: abnf
- Language: Go
- Homepage:
- Size: 72.3 KB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# abnf
[![Go Reference](https://pkg.go.dev/badge/github.com/ghettovoice/abnf.svg)](https://pkg.go.dev/github.com/ghettovoice/abnf)
[![Go Report Card](https://goreportcard.com/badge/github.com/ghettovoice/abnf)](https://goreportcard.com/report/github.com/ghettovoice/abnf)
[![Tests](https://github.com/ghettovoice/abnf/actions/workflows/test.yml/badge.svg)](https://github.com/ghettovoice/abnf/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/ghettovoice/abnf/badge.svg?branch=master)](https://coveralls.io/github/ghettovoice/abnf?branch=master)
[![CodeQL](https://github.com/ghettovoice/abnf/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/ghettovoice/abnf/actions/workflows/github-code-scanning/codeql)Package `abnf` implements ABNF grammar as described in [RFC 5234](https://www.rfc-editor.org/rfc/rfc5234)
and [RFC 7405](https://www.rfc-editor.org/rfc/rfc7405).Inspired by:
- https://github.com/declaresub/abnf
- https://github.com/elimity-com/abnf## Installation
Add `abnf` package and all subpackages to your project:
```bash
go get github.com/ghettovoice/abnf@latest
```## Usage
Build a rule from basic operators:
```go
package mainimport (
"fmt""github.com/ghettovoice/abnf"
)var abc = abnf.Concat(
`"a" "b" *"cd"`,
abnf.Literal(`"a"`, []byte("a")),
abnf.Literal(`"b"`, []byte("b")),
abnf.Repeat0Inf(`*"cd"`, abnf.Literal(`"cd"`, []byte("cd"))),
)func main() {
var ns abnf.Nodesfmt.Println(abc([]byte("ab"), ns[:0]))
fmt.Println(abc([]byte("abcd"), ns[:0]))
fmt.Println(abc([]byte("abcdcd"), ns[:0]))
}
```## CLI
Checkout `abnf` CLI [README](./cmd/abnf/README.md).
## License
MIT License - see [LICENSE](./LICENSE) file for a full text.