MCPcopy Create free account
hub / github.com/antchfx/xpath / parseStep

Method parseStep

parse.go:406–439  ·  view source on GitHub ↗

Step ::= AxisSpecifier NodeTest Predicate* | AbbreviatedStep

(n node)

Source from the content-addressed store, hash-verified

404
405// Step ::= AxisSpecifier NodeTest Predicate* | AbbreviatedStep
406func (p *parser) parseStep(n node) (opnd node) {
407 if p.r.typ == itemDot || p.r.typ == itemDotDot {
408 if p.r.typ == itemDot {
409 opnd = newAxisNode("self", allNode, "", "", "", n)
410 } else {
411 opnd = newAxisNode("parent", allNode, "", "", "", n)
412 }
413 p.next()
414 if p.r.typ != itemLBracket {
415 return opnd
416 }
417 } else {
418 axisType := "child" // default axes value.
419 switch p.r.typ {
420 case itemAt:
421 axisType = "attribute"
422 p.next()
423 case itemAxe:
424 axisType = p.r.name
425 p.next()
426 case itemLParens:
427 return p.parseSequence(n)
428 }
429 matchType := ElementNode
430 if axisType == "attribute" {
431 matchType = AttributeNode
432 }
433 opnd = p.parseNodeTest(n, axisType, matchType)
434 }
435 for p.r.typ == itemLBracket {
436 opnd = newFilterNode(opnd, p.parsePredicate(opnd))
437 }
438 return opnd
439}
440
441// Expr ::= '(' Step ("," Step)* ')'
442func (p *parser) parseSequence(n node) (opnd node) {

Callers 2

parseSequenceMethod · 0.95

Calls 6

nextMethod · 0.95
parseSequenceMethod · 0.95
parseNodeTestMethod · 0.95
parsePredicateMethod · 0.95
newAxisNodeFunction · 0.85
newFilterNodeFunction · 0.85

Tested by

no test coverage detected