%1.2
This commit is contained in:
parent
414d979931
commit
a9054b9704
15
main_test.go
15
main_test.go
|
@ -50,13 +50,14 @@ type Predicates struct {
|
|||
}
|
||||
|
||||
type Node struct {
|
||||
Name []rune
|
||||
Value []rune
|
||||
Name []rune // Axis
|
||||
Value []rune // Name(Axis)::Value
|
||||
Next *Node
|
||||
Sel Selection
|
||||
Pred Predicates
|
||||
}
|
||||
|
||||
// compile 编译
|
||||
func compile(spath string) (head *Node, tail *Node) {
|
||||
var path []rune = []rune(strings.TrimSpace(spath))
|
||||
path = append(path, ' ')
|
||||
|
@ -107,6 +108,13 @@ func getAxes(path []rune, limit int, ii *int, cur *Node) {
|
|||
switch c {
|
||||
case '[':
|
||||
case '/':
|
||||
case ':':
|
||||
if path[i+1] == ':' {
|
||||
i++
|
||||
|
||||
return
|
||||
}
|
||||
panic("':' error")
|
||||
case '@': //
|
||||
cur.Sel = SelAttribute
|
||||
cur.Name = getAttributeName(path, limit, ii)
|
||||
|
@ -123,6 +131,9 @@ func getAxes(path []rune, limit int, ii *int, cur *Node) {
|
|||
cur.Value = path[s:e]
|
||||
cur.Sel = SelMethod
|
||||
return
|
||||
case '\\': // 转义
|
||||
i++
|
||||
fallthrough
|
||||
default:
|
||||
cur.Name = append(cur.Name, c)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user