Documentation ¶
Index ¶
- Variables
- func MatchStream(r Ruler, in *bufio.Reader, ctx *Context) (v interface{}, err error)
- type BaseType
- type Context
- type Globals
- type Member
- type Ruler
- func And(rs ...Ruler) Ruler
- func Array(r Ruler, n int) Ruler
- func Array0(R Ruler) Ruler
- func Array01(R Ruler) Ruler
- func Array1(R Ruler) Ruler
- func Assert(expr func(ctx *Context) bool, msg string) Ruler
- func BaseArray(r BaseType, n int) Ruler
- func BaseDynarray(r BaseType, n func(ctx *Context) int) Ruler
- func ByteArray(n int) Ruler
- func ByteDynarray(n func(ctx *Context) int) Ruler
- func CharArray(n int) Ruler
- func CharDynarray(n func(ctx *Context) int) Ruler
- func Do(fn func(ctx *Context) error) Ruler
- func Dynarray(r Ruler, n func(ctx *Context) int) Ruler
- func Dyntype(r func(ctx *Context) (Ruler, error)) Ruler
- func Eval(expr func(ctx *Context) interface{}, r Ruler) Ruler
- func FileLine(file string, line int, R Ruler) Ruler
- func FixedType(t reflect.Type) Ruler
- func If(cond func(ctx *Context) bool, r Ruler) Ruler
- func Read(n func(ctx *Context) int, r Ruler) Ruler
- func Repeat0(R Ruler) Ruler
- func Repeat01(R Ruler) Ruler
- func Repeat1(R Ruler) Ruler
- func Return(fnRet func(ctx *Context) (v interface{}, err error)) Ruler
- func Seq(rs ...Ruler) Ruler
- func Skip(n func(ctx *Context) int) Ruler
- func Struct(members []Ruler) Ruler
- func TypeFrom(t reflect.Type) (r Ruler, err error)
- func Uintbe(n int) Ruler
- func Uintle(n int) Ruler
- type TypeVar
Constants ¶
This section is empty.
Variables ¶
var ( // Int8 is the matching unit for int8 Int8 = BaseType(reflect.Int8) // Int16 is the matching unit for int16 Int16 = BaseType(reflect.Int16) // Int32 is the matching unit for int32 Int32 = BaseType(reflect.Int32) // Int64 is the matching unit for int64 Int64 = BaseType(reflect.Int64) // Uint8 is the matching unit for uint8 Uint8 = BaseType(reflect.Uint8) // Uint16 is the matching unit for uint16 Uint16 = BaseType(reflect.Uint16) // Uint32 is the matching unit for uint32 Uint32 = BaseType(reflect.Uint32) // Uint64 is the matching unit for uint64 Uint64 = BaseType(reflect.Uint64) // Float32 is the matching unit for float32 Float32 = BaseType(reflect.Float32) // Float64 is the matching unit for float64 Float64 = BaseType(reflect.Float64) )
var ( // ErrVarNotAssigned is returned when TypeVar.Elem is not assigned. ErrVarNotAssigned = errors.New("variable is not assigned") // ErrVarAssigned is returned when TypeVar.Elem is already assigned. ErrVarAssigned = errors.New("variable is already assigned") // ErrNotEOF is returned when current position is not at EOF. ErrNotEOF = errors.New("current position is not at EOF") )
var (
TyInterface = reflect.TypeOf((*interface{})(nil)).Elem()
)
var Uint24 = Uintle(3)
Uint24 is a matching unit that matches a uintle(3) type.
Functions ¶
Types ¶
type BaseType ¶
type BaseType uint
A BaseType represents a matching unit of a builtin fixed size type.
type Context ¶
type Context struct { Stack *exec.Stack Parent *Context Globals Globals // contains filtered or unexported fields }
A Context represents the matching context of bpl.
func (*Context) SetDom ¶
func (p *Context) SetDom(v interface{})
SetDom set matching result of matching result.
type Globals ¶
type Globals struct {
Impl map[string]interface{}
}
A Globals represents global variables.
func (Globals) GetAndSetVar ¶
GetAndSetVar gets old value of a global variable and sets new value to it.
type Member ¶
A Member is typeinfo of a `Struct` member.
type Ruler ¶
type Ruler interface { // Match matches input stream `in`, and returns matching result. Match(in *bufio.Reader, ctx *Context) (v interface{}, err error) // RetType returns matching result type. RetType() reflect.Type // SizeOf returns expected length of result. If length is variadic, it returns -1. SizeOf() int }
A Ruler interface is required to a matching unit.
var ByteArray0 Ruler = byteArray0(0)
ByteArray0 is a matching unit that matches `*byte`.
var ByteArray1 Ruler = byteArray1(0)
ByteArray1 is a matching unit that matches `+byte`.
var CString Ruler = cstring(0)
CString is a matching unit that matches a C style string.
var Char Ruler = charType(0)
Char is a matching unit that matches a character.
var Done Ruler = done(0)
Done is a matching unit that seeks current position to EOF.
var EOF Ruler = eof(0)
EOF is a matching unit that matches EOF.
var Float32be Ruler = float32be(0)
Float32be returns a matching unit that matches a float32be type.
var Float64be Ruler = float64be(0)
Float64be returns a matching unit that matches a float64be type.
var Nil Ruler = nilType(0)
Nil is a matching unit that matches zero bytes.
func BaseDynarray ¶
BaseDynarray returns a matching unit that matches R n(ctx) times.
func ByteDynarray ¶
ByteDynarray returns a matching unit that matches `[n(ctx)]byte`.
func CharDynarray ¶
CharDynarray returns a matching unit that matches `[n(ctx)]char`.