🏷️ Added Delim type
This commit is contained in:
parent
2d20c56224
commit
90f9bd2d5b
25
tree.go
25
tree.go
|
@ -6,25 +6,30 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Node represent a single data structure.
|
type (
|
||||||
type Node struct {
|
// Node represent a single data structure.
|
||||||
Parent *Node
|
Node struct {
|
||||||
Children []*Node
|
Parent *Node
|
||||||
Value string
|
Children []*Node
|
||||||
}
|
Value string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delim is a delimiter between words (cells) in nodes (lines).
|
||||||
|
Delim rune
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// nodeBreakSymbol delimits nodes (lines).
|
// nodeBreakSymbol delimits nodes (lines).
|
||||||
nodeBreakSymbol rune = '\n'
|
nodeBreakSymbol rune = '\n'
|
||||||
|
|
||||||
// wordBreakSymbol delimits words (cells).
|
// wordBreakSymbol delimits words (cells).
|
||||||
wordBreakSymbol rune = ' '
|
wordBreakSymbol Delim = ' '
|
||||||
|
|
||||||
// edgeSymbol is used to indicate the parent/child relationship between
|
// edgeSymbol is used to indicate the parent/child relationship between
|
||||||
// nodes.
|
// nodes.
|
||||||
//
|
//
|
||||||
// TODO(toby3d): allow clients to change this to '\t' for example.
|
// TODO(toby3d): allow clients to change this to '\t' for example.
|
||||||
edgeSymbol rune = wordBreakSymbol
|
edgeSymbol rune = ' '
|
||||||
)
|
)
|
||||||
|
|
||||||
// Parse parses the data into a Tree Notation nodes.
|
// Parse parses the data into a Tree Notation nodes.
|
||||||
|
@ -95,6 +100,10 @@ func (n Node) GoString() (result string) {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d Delim) String() string {
|
||||||
|
return string(d)
|
||||||
|
}
|
||||||
|
|
||||||
// lenIndent count egdeSymbol prefixes in line.
|
// lenIndent count egdeSymbol prefixes in line.
|
||||||
//
|
//
|
||||||
// Returns 0 if line starts from any word character.
|
// Returns 0 if line starts from any word character.
|
||||||
|
|
Loading…
Reference in New Issue