From a9054b970417f3e75c3d017f1daeb17eef51db20 Mon Sep 17 00:00:00 2001 From: eson Date: Mon, 21 Sep 2020 18:55:32 +0800 Subject: [PATCH] %1.2 --- main_test.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/main_test.go b/main_test.go index eef21e3..bbcf85d 100644 --- a/main_test.go +++ b/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) }