abnf

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ABNF_ERROR_MAX_SRC_OUTPUT_LEN = 40
)

Variables

This section is empty.

Functions

func EncodeUint

func EncodeUint(buf *ByteBuffer, digit uint64)

EncodeUint encode uint64 to byte buffer

EncodeUint is faster than strconv.FormatUint

func EncodeUintWithWidth

func EncodeUintWithWidth(buf *ByteBuffer, digit uint64, width int)

EncodeUintWithWidth encode uint64 to byte buffer with width,

if length of digit is less than width, spaces are filled before digit.
if length of digit is larger than width, no space is before digit.
EncodeUintWithWidth is faster than fmt.Sprintf

func Errorf

func Errorf(src []byte, pos Pos, format string, args ...interface{}) error

Errorf formats according to a format specifier and returns the string as a value that satisfies error. Errorf also records the stack trace at the point it was called.

func NewError

func NewError(src []byte, pos Pos, message string) error

Types

type ByteBuffer

type ByteBuffer = buffer.ByteBuffer

func NewByteBuffer

func NewByteBuffer(buf []byte) *ByteBuffer

type Context

type Context struct {
	// contains filtered or unexported fields
}

func NewContext

func NewContext(allocator *mem.ArenaAllocator, src []byte) *Context

func (*Context) SetAllocator

func (this *Context) SetAllocator(allocator *mem.ArenaAllocator)

func (*Context) SetParsePos

func (this *Context) SetParsePos(pos Pos)

func (*Context) SetParseSrc

func (this *Context) SetParseSrc(src []byte)

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) String

func (e *Error) String() string

func (*Error) Write

func (e *Error) Write(w io.Writer)

type Pos

type Pos = uint

func ParseInCharset

func ParseInCharset(src []byte, pos Pos, charset *[256]uint32, mask uint32) (newPos Pos)

parse input when char is in charset

func ParseInCharsetAndAlloc

func ParseInCharsetAndAlloc(allocator *mem.ArenaAllocator, src []byte, pos Pos, charset *[256]uint32, mask uint32) (addr mem.MemPtr, newPos Pos)

parse input when char is in charset and not empty, and allocte memory for output

func ParseInCharsetPercentEscapable

func ParseInCharsetPercentEscapable(allocator *mem.ArenaAllocator, src []byte, pos Pos, charset *[256]uint32, mask uint32) (addr mem.MemPtr, newPos Pos, err error)

parse input when char is in charset and char may be percent escaped, such as "%61"

using goto for performance

func ParseUint16

func ParseUint16(src []byte, pos Pos) (digit uint16, newPos Pos, ok bool)

ParseUInt16 parse digit in src which can contain non-digit char,

and convert to int64, return false if overflow
ParseUInt16 is faster than strconv.ParseUint and strconv.Atoi

func ParseUint32

func ParseUint32(src []byte, pos Pos) (digit uint32, newPos Pos, ok bool)

ParseUInt32 parse digit in src which can contain non-digit char,

and convert to int64, return false if overflow
ParseUInt32 is faster than strconv.ParseUint and strconv.Atoi

func ParseUint64

func ParseUint64(src []byte, pos Pos) (digit uint64, newPos Pos, ok bool)

ParseUInt64 parse digit in src which can contain non-digit char,

and convert to int64, return false if overflow
ParseUInt64 is faster than strconv.ParseUint and strconv.Atoi

func ParseUint8

func ParseUint8(src []byte, pos Pos) (digit uint8, newPos Pos, ok bool)

ParseUInt8 parse digit in src which can contain non-digit char,

and convert to int64, return false if overflow
ParseUInt16 is faster than strconv.ParseUint and strconv.Atoi

Jump to

Keyboard shortcuts

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