Documentation
¶
Overview ¶
The debug package is great for testing and debugging of parse.Parser implementations.
Index ¶
- Variables
- func NewBoolValue(v bool) parse.Token
- func NewBytesValue(v []byte) parse.Token
- func NewDoubleValue(v float64) parse.Token
- func NewIntValue(v int64) parse.Token
- func NewLogger(p parse.ParserWithInit, logger Logger) parse.ParserWithInit
- func NewStringValue(v string) parse.Token
- func NewUintValue(v uint64) parse.Token
- func RandomWalk(p parse.Parser, r Rand, next, skip int) error
- func Walk(p parse.Parser) error
- type Debug
- 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: ptr(int32(3)), E: []*Debug{ { B: []string{"b4"}, }, { B: []string{"b5"}, }, }, }, D: ptr(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 NewBoolValue ¶
NewBoolValue wraps a native go type into a parse.Token.
func NewBytesValue ¶
NewBytesValue wraps a native go type into a parse.Token.
func NewDoubleValue ¶
NewDoubleValue wraps a native go type into a parse.Token.
func NewIntValue ¶
NewIntValue wraps a native go type into a parse.Token.
func NewLogger ¶ added in v0.8.3
func NewLogger(p parse.ParserWithInit, logger Logger) parse.ParserWithInit
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 parse.Token.
func NewUintValue ¶
NewUintValue wraps a native go type into a parse.Token.
func RandomWalk ¶ added in v0.8.3
RandomWalk does a random walk of the parser, given two probabilities.
The next parameter is passed to r.Intn and when a zero value is returned the Next method on the parser is called. The skip parameter is passed to r.Intn and when a non zero value is returned the Skip method on the parser is called.
RandomWalk is great for testing that the implemented parser can handle random skipping of parts of the tree.
Types ¶
type Logger ¶ added in v0.8.3
Logger is an interface for a type that is made to log debug info.
func NewDelayLogger ¶ added in v0.8.3
NewDelayLogger returns a logger that sleeps after every log. This is useful for debugging infinite loops.
func NewLineLogger ¶ added in v0.8.3
func NewLineLogger() Logger
NewLineLogger returns a logger that logs the line at which the Printf method was called to stderr.
type Node ¶ added in v0.8.3
Node is a type that represents a node in a tree. It has a label an children nodes.
func Field ¶ added in v0.8.3
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 ¶ added in v0.8.3
type Nodes []Node
Nodes is a list of Node.
func Parse ¶ added in v0.8.3
Parse parses through the whole parser in a top down manner and records the values into a Nodes structute.
func RandomParse ¶ added in v0.8.3
RandomParse does a random parse of the parser, given two probabilities.
next is passed to r.Intn and when a non zero value is returned the Next method on the parser is called. skip is passed to r.Intn and when a zero value is returned the Skip method on the parser is called.
RandomParse is great for testing that the implemented parser can handle random skipping of parts of the tree.