Documentation ¶
Overview ¶
dbbr Implements the DBBR format for binary tree creation. It is used to create simple (and even complex) true/false rules from a true/false logic tree.
For more info, look at the README.md file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcIndent ¶
func ParseFile ¶
func ParseFile(path string, parser LogicParser) (map[string]Rule, error)
ParseFile creates rules from a given file, using the given parser.
func SectionLines ¶
SectionLines creates sections of rules from lines.
Types ¶
type BuildTree ¶
type BuildTree struct { Name string True *BuildTree False *BuildTree Logic string Line int // if set to true, use Logic as rule name IsPointer bool }
func NewBuildTree ¶
func (*BuildTree) UpdateNext ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder builds
func NewBuilder ¶
func NewBuilder(parser LogicParser) *Builder
NewBuilder creates a Builder with builtin True and False.
func (*Builder) Build ¶
Build builds Rules from a sections of lines, each slice corresponds to 1 rule.
func (*Builder) BuildRuleTree ¶
BulidRuleTree builds a single BuildTree for a rule, from a section of lines.
type Line ¶
Line repressents a line in DBBR configration file
func ConvertToLines ¶
ConvertToLines converts a slice of strings to Lines.
func ReadLinesFromFile ¶
ReadLinesFromFile converts textual file to lines.
type LogicParser ¶
LogicParser is an interface for parsing the logic of a rule when building.
type Rule ¶
type Rule interface { Name() string // Check runs the input against the full rule tree logic Check(interface{}) bool // CheckLogic runs the input against only the current rule CheckLogic(interface{}) bool // NextTrue returns the next rule node if true NextTrue() Rule // NextFalse returns the next rule node if false NextFalse() Rule // Next returns the next rule by boolean value Next(bool) Rule }
Rule is a binary decision tree with a logic functions.