Source File
option.go
Belonging Package
github.com/pandatix/go-abnf
package goabnfconst (defaultValidate = truedefaultRedefine = false)func process( ...ABNFOption) *abnfOptions {:= &abnfOptions{validate: defaultValidate,redefineCore: defaultRedefine,}for , := range {.apply()}return}// ABNFOption defines the interface for parsing ABNF functional options.type ABNFOption interface {apply(*abnfOptions)}type abnfOptions struct {validate boolredefineCore bool}// Defines if proceed to semantic validation.type validateOption boolvar _ ABNFOption = (*validateOption)(nil)func ( validateOption) ( *abnfOptions) {.validate = bool()}// WithValidation returns a functional option to proceed to// validation or not.// Default is true.func ( bool) ABNFOption {return validateOption()}// Defines if an ABNF grammar could redefine a core rule.type redefineCoreOption boolvar _ ABNFOption = (*redefineCoreOption)(nil)func ( redefineCoreOption) ( *abnfOptions) {.redefineCore = bool()}// WithRedefineCoreRules returns a functional option to// enable redefining a core rule.// Default is false.//// WARNING: use with caution, as we left to the user the responsibility// to ensure the redefinition keeps the ABNF grammar coherent (i.e.// there is an isomorphism between the core rule and the redefinition,// not especially the same textual representation).func ( bool) ABNFOption {return redefineCoreOption()}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |