forked from jasder/antlr
stash
This commit is contained in:
parent
913cda0721
commit
20d8545e3d
|
@ -16,16 +16,10 @@ public class XPathRootRuleElement extends XPathElement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<? extends ParseTree> evaluate(final ParseTree t) {
|
public Collection<? extends ParseTree> evaluate(final ParseTree t) {
|
||||||
// /* means whatever the root is
|
ParserRuleContext ctx = (ParserRuleContext)t.getPayload();
|
||||||
if ( isWildcard() ) {
|
if ( ctx.getRuleIndex() == ruleIndex ) {
|
||||||
return new ArrayList<ParseTree>() {{add(t);}};
|
return new ArrayList<ParseTree>() {{add(t);}};
|
||||||
}
|
}
|
||||||
else { // /x means x must be root
|
|
||||||
ParserRuleContext ctx = (ParserRuleContext)t.getPayload();
|
|
||||||
if ( ctx.getRuleIndex() == ruleIndex ) {
|
|
||||||
return new ArrayList<ParseTree>() {{add(t);}};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new ArrayList<ParseTree>();
|
return new ArrayList<ParseTree>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,18 +13,13 @@ public class XPathTokenElement extends XPathElement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<? extends ParseTree> evaluate(ParseTree t) {
|
public Collection<? extends ParseTree> evaluate(ParseTree t) {
|
||||||
if ( isWildcard() ) {
|
// return all children of t that match nodeName
|
||||||
return t.getChildren();
|
List<ParseTree> nodes = new ArrayList<ParseTree>();
|
||||||
}
|
for (ParseTree c : t.getChildren()) {
|
||||||
else {
|
if ( c.getText().equals(nodeName) ) {
|
||||||
// return all children of t that match nodeName
|
nodes.add(c);
|
||||||
List<ParseTree> nodes = new ArrayList<ParseTree>();
|
|
||||||
for (ParseTree c : t.getChildren()) {
|
|
||||||
if ( c.getText().equals(nodeName) ) {
|
|
||||||
nodes.add(c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nodes;
|
|
||||||
}
|
}
|
||||||
|
return nodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue