katydid: github.com/katydid/katydid/parser/debug Index | Files | Directories

package debug

import "github.com/katydid/katydid/parser/debug"

The debug package is great for testing and debugging of parser.Interface implementations.

Code generated by debug-gen. DO NOT EDIT.

Index

Package Files

debug.pb.go doc.go err.go log.go value.gen.go value.go walk.go

Variables

var Input = &Debug{
    A:  int64(1),
    B:  []string{"b2", "b3"},
    C: &Debug{
        A:  int64(2),
        D:  proto.Int32(3),
        E: []*Debug{
            {
                B: []string{"b4"},
            },
            {
                B: []string{"b5"},
            },
        },
    },
    D:  proto.Int32(4),
    F:  []uint32{5},
}

Input is a sample instance of the Debug struct.

var Output = Nodes{
    Field(`A`, `1`),
    Nested(`B`,
        Field(`0`, `b2`),
        Field(`1`, `b3`),
    ),
    Nested(`C`,
        Field(`A`, `2`),
        Field(`D`, `3`),
        Nested(`E`,
            Nested(`0`,
                Field(`A`, `0`),
                Nested(`B`,
                    Field(`0`, `b4`),
                ),
            ),
            Nested(`1`,
                Field(`A`, `0`),
                Nested(`B`,
                    Field(`0`, `b5`),
                ),
            ),
        ),
    ),
    Field(`D`, `4`),
    Nested(`F`,
        Field(`0`, `5`),
    ),
}

Output is a sample instance of Nodes that repesents the Input variable after it has been parsed by Walk.

func DebugDescription Uses

func DebugDescription() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet)

func NewBoolValue Uses

func NewBoolValue(v bool) parser.Value

NewBoolValue wraps a native go type into a parser.Value.

func NewBytesValue Uses

func NewBytesValue(v []byte) parser.Value

NewBytesValue wraps a native go type into a parser.Value.

func NewDoubleValue Uses

func NewDoubleValue(v float64) parser.Value

NewDoubleValue wraps a native go type into a parser.Value.

func NewIntValue Uses

func NewIntValue(v int64) parser.Value

NewIntValue wraps a native go type into a parser.Value.

func NewLogger Uses

func NewLogger(s parser.Interface, logger Logger) parser.Interface

NewLogger returns a parser that when called returns and logs the value returned by the argument parser to the argument logger.

func NewStringValue Uses

func NewStringValue(v string) parser.Value

NewStringValue wraps a native go type into a parser.Value.

func NewUintValue Uses

func NewUintValue(v uint64) parser.Value

NewUintValue wraps a native go type into a parser.Value.

type Debug Uses

type Debug struct {
    A                int64    `protobuf:"varint,1,opt,name=A" json:"A"`
    B                []string `protobuf:"bytes,2,rep,name=B" json:"B,omitempty"`
    C                *Debug   `protobuf:"bytes,3,opt,name=C" json:"C,omitempty"`
    D                *int32   `protobuf:"varint,4,opt,name=D" json:"D,omitempty"`
    E                []*Debug `protobuf:"bytes,5,rep,name=E" json:"E,omitempty"`
    F                []uint32 `protobuf:"fixed32,6,rep,name=F" json:"F,omitempty"`
    G                *float64 `protobuf:"fixed64,7,opt,name=G" json:"G,omitempty"`
    XXX_unrecognized []byte   `json:"-"`
}

func (*Debug) Description Uses

func (this *Debug) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet)

func (*Debug) Descriptor Uses

func (*Debug) Descriptor() ([]byte, []int)

func (*Debug) GetA Uses

func (m *Debug) GetA() int64

func (*Debug) GetB Uses

func (m *Debug) GetB() []string

func (*Debug) GetC Uses

func (m *Debug) GetC() *Debug

func (*Debug) GetD Uses

func (m *Debug) GetD() int32

func (*Debug) GetE Uses

func (m *Debug) GetE() []*Debug

func (*Debug) GetF Uses

func (m *Debug) GetF() []uint32

func (*Debug) GetG Uses

func (m *Debug) GetG() float64

func (*Debug) GoString Uses

func (this *Debug) GoString() string

func (*Debug) ProtoMessage Uses

func (*Debug) ProtoMessage()

func (*Debug) Reset Uses

func (m *Debug) Reset()

func (*Debug) String Uses

func (m *Debug) String() string

func (*Debug) XXX_DiscardUnknown Uses

func (m *Debug) XXX_DiscardUnknown()

func (*Debug) XXX_Marshal Uses

func (m *Debug) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Debug) XXX_Merge Uses

func (dst *Debug) XXX_Merge(src proto.Message)

func (*Debug) XXX_Size Uses

func (m *Debug) XXX_Size() int

func (*Debug) XXX_Unmarshal Uses

func (m *Debug) XXX_Unmarshal(b []byte) error

type Logger Uses

type Logger interface {
    Printf(format string, v ...interface{})
}

Logger is an interface for a type that is made to log debug info.

func NewDelayLogger Uses

func NewDelayLogger(delay time.Duration) Logger

NewDelayLogger returns a logger that sleeps after every log. This is useful for debugging infinite loops.

func NewLineLogger Uses

func NewLineLogger() Logger

NewLineLogger returns a logger that logs the line at which the Printf method was called to stderr.

type Node Uses

type Node struct {
    Label    string
    Children Nodes
}

Node is a type that represents a node in a tree. It has a label an children nodes.

func Field Uses

func Field(name string, value string) Node

Field is a helper function for creating a Node with a label and one child label. This is how a field with a value is typically represented.

func Nested Uses

func Nested(name string, fs ...Node) Node

Nested is a helper function for creating a Node.

func (Node) Equal Uses

func (this Node) Equal(that Node) bool

Equal returns whether two Nodes are the same.

func (Node) String Uses

func (this Node) String() string

String returns a string representation of Node.

type Nodes Uses

type Nodes []Node

Nodes is a list of Node.

func RandomWalk Uses

func RandomWalk(p parser.Interface, r Rand, next, down int) Nodes

RandomWalk does a random walk of the parser, given two probabilities.

next is passed to r.Intn and when a zero value is returned the Next method on the parser is called.
down is passed to r.Intn and when a non zero value is returned the Down method on the parser is called.

RandomWalk is great for testing that the implemented parser can handle random skipping of parts of the tree.

func Walk Uses

func Walk(p parser.Interface) Nodes

Walk walks through the whole parser in a top down manner and records the values into a Nodes structute.

func (Nodes) Equal Uses

func (this Nodes) Equal(that Nodes) bool

Equal returns whether two Node lists are equal.

func (Nodes) String Uses

func (this Nodes) String() string

String returns a string representation of Nodes.

type Rand Uses

type Rand interface {
    Intn(n int) int
}

Rand is a subset of the interface that is implemented by math/rand representing only the methods used by the RandomWalk function.

func NewRand Uses

func NewRand() Rand

NewRand returns a random integer generator, that can be used with RandomWalk. Its seed is the current time.

Directories

PathSynopsis
debug-genCommand debug-gen generates some of the code in the debug package.

Package debug imports 19 packages (graph) and is imported by 1 packages. Updated 2018-09-12. Refresh now. Tools for package owners.