abnf_gen

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 13 Imported by: 0

README

abnf_gen

Package abnf_gen implements parser and code generation from ABNF grammar.

Documentation

Overview

Package abnf_gen implements parser and code generation from ABNF grammar.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeGenerator

type CodeGenerator struct {
	External    map[string]ExternalRule
	PackageName string
	AsOperators bool
	// contains filtered or unexported fields
}

CodeGenerator generates ABNF rules as Go sources.

func (*CodeGenerator) ReadFrom

func (g *CodeGenerator) ReadFrom(src io.Reader) (int64, error)

ReadFrom reads and parses ABNF grammar from src.

func (*CodeGenerator) WriteTo

func (g *CodeGenerator) WriteTo(dst io.Writer) (int64, error)

WriteTo generates final Go sources and writes them to the dst.

type ExternalRule

type ExternalRule struct {
	IsOperator bool

	Operator abnf.Operator
	Factory  OperatorFactory

	PackagePath string
	PackageName string
}

ExternalRule defines an external ABNF rule.

ParserGenerator uses Operator and Factory fields. CodeGenerator uses PackagePath and PackageName fields. IsOperator field is used by both generators.

type OperatorFactory

type OperatorFactory func() abnf.Operator

type ParserGenerator

type ParserGenerator struct {
	External map[string]ExternalRule
	// contains filtered or unexported fields
}

ParserGenerator generates ABNF rules as operator functions or operator factories in memory.

func (*ParserGenerator) Factories

func (g *ParserGenerator) Factories() map[string]OperatorFactory

Factories returns a map of ABNF rules as operator factories.

func (*ParserGenerator) Operators

func (g *ParserGenerator) Operators() map[string]abnf.Operator

Operators returns a map of ABNF rules as operator functions.

func (*ParserGenerator) ReadFrom

func (g *ParserGenerator) ReadFrom(src io.Reader) (int64, error)

ReadFrom reads and parses ABNF grammar from src.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL