Documentation ¶
Overview ¶
The debug package is great for testing and debugging of parser.Interface implementations.
Code generated by debug-gen. DO NOT EDIT.
Index ¶
- Variables
- func DebugDescription() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet)
- func NewBoolValue(v bool) parser.Value
- func NewBytesValue(v []byte) parser.Value
- func NewDoubleValue(v float64) parser.Value
- func NewIntValue(v int64) parser.Value
- func NewLogger(s parser.Interface, logger Logger) parser.Interface
- func NewStringValue(v string) parser.Value
- func NewUintValue(v uint64) parser.Value
- type Debug
- func (this *Debug) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet)
- func (*Debug) Descriptor() ([]byte, []int)
- func (m *Debug) GetA() int64
- func (m *Debug) GetB() []string
- func (m *Debug) GetC() *Debug
- func (m *Debug) GetD() int32
- func (m *Debug) GetE() []*Debug
- func (m *Debug) GetF() []uint32
- func (m *Debug) GetG() float64
- func (this *Debug) GoString() string
- func (*Debug) ProtoMessage()
- func (m *Debug) Reset()
- func (m *Debug) String() string
- func (m *Debug) XXX_DiscardUnknown()
- func (m *Debug) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Debug) XXX_Merge(src proto.Message)
- func (m *Debug) XXX_Size() int
- func (m *Debug) XXX_Unmarshal(b []byte) error
- type Logger
- type Node
- type Nodes
- type Rand
Constants ¶
This section is empty.
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.
Functions ¶
func DebugDescription ¶
func DebugDescription() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet)
func NewBoolValue ¶
NewBoolValue wraps a native go type into a parser.Value.
func NewBytesValue ¶
NewBytesValue wraps a native go type into a parser.Value.
func NewDoubleValue ¶
NewDoubleValue wraps a native go type into a parser.Value.
func NewIntValue ¶
NewIntValue wraps a native go type into a parser.Value.
func NewLogger ¶
NewLogger returns a parser that when called returns and logs the value returned by the argument parser to the argument logger.
func NewStringValue ¶
NewStringValue wraps a native go type into a parser.Value.
func NewUintValue ¶
NewUintValue wraps a native go type into a parser.Value.
Types ¶
type Debug ¶
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 ¶
func (this *Debug) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet)
func (*Debug) Descriptor ¶
func (*Debug) ProtoMessage ¶
func (*Debug) ProtoMessage()
func (*Debug) XXX_DiscardUnknown ¶
func (m *Debug) XXX_DiscardUnknown()
func (*Debug) XXX_Marshal ¶
func (*Debug) XXX_Unmarshal ¶
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
}
Logger is an interface for a type that is made to log debug info.
func NewDelayLogger ¶
NewDelayLogger returns a logger that sleeps after every log. This is useful for debugging infinite loops.
func NewLineLogger ¶
func NewLineLogger() Logger
NewLineLogger returns a logger that logs the line at which the Printf method was called to stderr.
type Node ¶
Node is a type that represents a node in a tree. It has a label an children nodes.
func Field ¶
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.
type Nodes ¶
type Nodes []Node
Nodes is a list of Node.
func RandomWalk ¶
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 ¶
Walk walks through the whole parser in a top down manner and records the values into a Nodes structute.