astpatt

package
v0.4.3-0...-af5a74a Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NodeTypeOmit will be omitted including its children.
	NodeTypeOmit astrav.NodeType = "omit"
	// NodeTypeSkip defines a node that is not taken into accound. It's children will be inlined.
	NodeTypeSkip astrav.NodeType = "skip"
)

Special node types

Variables

This section is empty.

Functions

func DiffPatterns

func DiffPatterns(valid []*Pattern, pkg *astrav.Package) (string, float64, bool)

DiffPatterns matches a package against multiple valid patterns. If one of the valid patterns matches true is returned. DiffPatterns additionally returns a diff of the patterns.

func MatchPatterns

func MatchPatterns(valid []*Pattern, pkg *astrav.Package) bool

MatchPatterns matches a package against multiple valid patterns. If one of the valid patterns matches true is returned.

func Perm

func Perm(nodes []Node) [][]Node

Perm calls f with each permutation of a.

Types

type DefaultNode

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

DefaultNode implements the default node definition

func (*DefaultNode) Children

func (s *DefaultNode) Children() []Node

Children returns the child nodes.

func (*DefaultNode) Match

func (s *DefaultNode) Match(node Node) bool

Match checks if given node matches the criteria

func (*DefaultNode) Populate

func (s *DefaultNode) Populate(ast astrav.Node)

Populate populates the pattern node from a given ast node. This is the default Populator implementation. Overwrite for spefic pattern node behavior.

func (*DefaultNode) Walk

func (s *DefaultNode) Walk(f func(node Node) bool)

Walk traverses the tree and its children. return false to skip children of the current element

type FuncDecl

type FuncDecl struct {
	Name string
	// contains filtered or unexported fields
}

FuncDecl node

func (*FuncDecl) Children

func (s *FuncDecl) Children() []Node

Children returns the child nodes.

func (*FuncDecl) Match

func (s *FuncDecl) Match(node Node) bool

Match checks if given node matches the criteria

func (*FuncDecl) Populate

func (s *FuncDecl) Populate(ast astrav.Node)

Populate populates the pattern node from a given ast node.

func (*FuncDecl) Walk

func (s *FuncDecl) Walk(f func(node Node) bool)

Walk traverses the tree and its children. return false to skip children of the current element

type Node

type Node interface {
	Match(Node) bool
	Populate(astrav.Node)
	Children() []Node
	Walk(f func(node Node) bool)
	// contains filtered or unexported methods
}

Node represents a pattern node.

type Omit

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

Omit is a placeholder node that is to be omitted.

func (*Omit) Children

func (s *Omit) Children() []Node

Children returns the child nodes.

func (*Omit) Match

func (s *Omit) Match(node Node) bool

Match checks if given node matches the criteria

func (*Omit) Populate

func (s *Omit) Populate(ast astrav.Node)

Populate populates the pattern node from a given ast node.

func (*Omit) Walk

func (s *Omit) Walk(f func(node Node) bool)

Walk traverses the tree and its children. return false to skip children of the current element

type Pattern

type Pattern struct {
	Name string `json:"-"`
	// contains filtered or unexported fields
}

Pattern implements a solutions pattern

func ExtractPattern

func ExtractPattern(pkg *astrav.Package) *Pattern

ExtractPattern extracts the pattern from a given ast package

func ExtractPatternPermutations

func ExtractPatternPermutations(pkg *astrav.Package) []*Pattern

ExtractPatternPermutations extracts a list of patterns with nodes order exchanged where allowed.

func NewPattern

func NewPattern() *Pattern

NewPattern creates a new pattern

func (*Pattern) Children

func (s *Pattern) Children() []Node

Children returns the child nodes.

func (*Pattern) DiffPattern

func (s *Pattern) DiffPattern(pattern *Pattern) (string, float64, bool)

DiffPattern checks the pattern against another pattern

func (*Pattern) DiffPkg

func (s *Pattern) DiffPkg(pkg *astrav.Package) (string, float64, bool)

DiffPkg checks the pattern against given package

func (*Pattern) Match

func (s *Pattern) Match(node Node) bool

Match checks the pattern against another pattern

func (*Pattern) MatchPkg

func (s *Pattern) MatchPkg(pkg *astrav.Package) bool

MatchPkg checks the pattern against given package

func (*Pattern) Populate

func (s *Pattern) Populate(ast astrav.Node)

Populate populates the pattern node from a given ast node. This is the default Populator implementation. Overwrite for spefic pattern node behavior.

func (*Pattern) String

func (s *Pattern) String() string

func (*Pattern) Walk

func (s *Pattern) Walk(f func(node Node) bool)

Walk traverses the tree and its children. return false to skip children of the current element

type SelectorExpr

type SelectorExpr struct {
	Name string
	// contains filtered or unexported fields
}

SelectorExpr node

func (*SelectorExpr) Children

func (s *SelectorExpr) Children() []Node

Children returns the child nodes.

func (*SelectorExpr) Match

func (s *SelectorExpr) Match(node Node) bool

Match checks if given node matches the criteria

func (*SelectorExpr) Populate

func (s *SelectorExpr) Populate(ast astrav.Node)

Populate populates the pattern node from a given ast node.

func (*SelectorExpr) Walk

func (s *SelectorExpr) Walk(f func(node Node) bool)

Walk traverses the tree and its children. return false to skip children of the current element

type Skip

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

Skip is a placeholder node that is to be omitted.

func (*Skip) Children

func (s *Skip) Children() []Node

Children returns the child nodes.

func (*Skip) Match

func (s *Skip) Match(node Node) bool

Match checks if given node matches the criteria

func (*Skip) Populate

func (s *Skip) Populate(ast astrav.Node)

Populate populates the pattern node from a given ast node.

func (*Skip) Walk

func (s *Skip) Walk(f func(node Node) bool)

Walk traverses the tree and its children. return false to skip children of the current element

Directories

Path Synopsis
cmd
solutions
hamming/10
Package hamming provides the Distance function.
Package hamming provides the Distance function.
hamming/11
Package hamming contains function to calculate amount of character difference between two equal strings.
Package hamming contains function to calculate amount of character difference between two equal strings.
hamming/12
Package hamming provides the Distance function.
Package hamming provides the Distance function.
hamming/4
Package hamming is used for calculating difference between DNA It has a function Distance(string, string) (int,error), that accept 2 DNA strings and return difference in integer value, or -1 and error message
Package hamming is used for calculating difference between DNA It has a function Distance(string, string) (int,error), that accept 2 DNA strings and return difference in integer value, or -1 and error message
hamming/8
Package hamming contains function to calculate amount of character difference between two equal strings.
Package hamming contains function to calculate amount of character difference between two equal strings.
hamming/patterns/2
Package hamming implements hamming distance
Package hamming implements hamming distance
isogram/3
Package isogram implements IsIsogram to check input string is an isogram
Package isogram implements IsIsogram to check input string is an isogram
isogram/4
Package isogram tests for whether or not a word is an isogram
Package isogram tests for whether or not a word is an isogram
permutations/3
Package twofer implements some sharing functionality.
Package twofer implements some sharing functionality.
raindrops/1
Package raindrops converts number to string and outputs info depending on numbers factors
Package raindrops converts number to string and outputs info depending on numbers factors
raindrops/10
Package raindrops convert a number to a string, the contents of which depend on the number's factors.
Package raindrops convert a number to a string, the contents of which depend on the number's factors.
raindrops/11
Package raindrops convert a number to a string, the contents of which depend on the number's factors.
Package raindrops convert a number to a string, the contents of which depend on the number's factors.
raindrops/13
Package raindrops is involved in converting numbers to pattern-based strings
Package raindrops is involved in converting numbers to pattern-based strings
raindrops/14
Package raindrops converts ints into onomatopoeia depending on factors of that int.
Package raindrops converts ints into onomatopoeia depending on factors of that int.
raindrops/17
Package raindrops is used to transform a number into the lovely sound of rain
Package raindrops is used to transform a number into the lovely sound of rain
raindrops/18
Package raindrops is used to transform a number into the lovely sound of rain
Package raindrops is used to transform a number into the lovely sound of rain
raindrops/2
Package raindrops provides a simple int to raindrop-speak conversion function
Package raindrops provides a simple int to raindrop-speak conversion function
raindrops/4
Package raindrops is used to transform a number into the lovely sound of rain
Package raindrops is used to transform a number into the lovely sound of rain
raindrops/6
Package raindrops convert a number to a string, the contents of which depend on the number's factors.
Package raindrops convert a number to a string, the contents of which depend on the number's factors.
raindrops/7
Package raindrops ...
Package raindrops ...
raindrops/8
Package raindrops convert a number to a string, the contents of which depend on the number's factors.
Package raindrops convert a number to a string, the contents of which depend on the number's factors.
raindrops/patterns/1
Package raindrops provides a simple int to raindrop-speak conversion function
Package raindrops provides a simple int to raindrop-speak conversion function
raindrops/patterns/2
Package raindrops is used to transform a number into the lovely sound of rain
Package raindrops is used to transform a number into the lovely sound of rain
raindrops/patterns/3
Package raindrops is used to transform a number into the lovely sound of rain
Package raindrops is used to transform a number into the lovely sound of rain
twofer/1
Package twofer should have a package comment that summarizes what it's about.
Package twofer should have a package comment that summarizes what it's about.
twofer/10
Package twofer or 2-fer is short for two for one.
Package twofer or 2-fer is short for two for one.
twofer/11
Package twofer implements some sharing functionality.
Package twofer implements some sharing functionality.
twofer/12
Package twofer implements some sharing functionality.
Package twofer implements some sharing functionality.
twofer/2
Package twofer should have a package comment that summarizes what it's about.
Package twofer should have a package comment that summarizes what it's about.
twofer/3
Package twofer implements sharing functionality
Package twofer implements sharing functionality
twofer/4
Package twofer should have a package comment that summarizes what it's about.
Package twofer should have a package comment that summarizes what it's about.
twofer/5
Package twofer should have a package comment that summarizes what it's about.
Package twofer should have a package comment that summarizes what it's about.
twofer/6
Package twofer implements a "Two-Fer" statement.
Package twofer implements a "Two-Fer" statement.
twofer/7
Package twofer or 2-fer is short for two for one.
Package twofer or 2-fer is short for two for one.
twofer/9
Package twofer implements some sharing functionality.
Package twofer implements some sharing functionality.
twofer/patterns/1
Package twofer contains sharing algorithms.
Package twofer contains sharing algorithms.
twofer/patterns/2
Package twofer contains sharing algorithms.
Package twofer contains sharing algorithms.

Jump to

Keyboard shortcuts

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