-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
94 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ nbactions*.xml | |
*.hprof | ||
|
||
# Playground | ||
/tool/playground/ | ||
#/tool/playground/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathAnywhereElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.antlr.v4.runtime.tree.xpath; | ||
|
||
/** Either ID at start of path or ...//ID in middle of path */ | ||
public class XPathAnywhereElement extends XPathElement { | ||
public XPathAnywhereElement(String nodeName) { | ||
super(nodeName); | ||
} | ||
} |
8 changes: 3 additions & 5 deletions
8
runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
package org.antlr.v4.runtime.tree.xpath; | ||
|
||
public class XPathElement { | ||
public XPathOperator op; | ||
public abstract class XPathElement { | ||
public String nodeName; | ||
|
||
/** Construct element like /ID or //ID or ID or "/*" etc... | ||
/** Construct element like /ID or or ID or "/*" etc... | ||
* op is null if just node | ||
*/ | ||
public XPathElement(XPathOperator op, String nodeName) { | ||
public XPathElement(String nodeName) { | ||
this.nodeName = nodeName; | ||
this.op = op; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathNodeElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.antlr.v4.runtime.tree.xpath; | ||
|
||
public class XPathNodeElement extends XPathElement { | ||
public XPathNodeElement(String nodeName) { | ||
super(nodeName); | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathOperator.java
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPathRootedElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.antlr.v4.runtime.tree.xpath; | ||
|
||
public class XPathRootedElement extends XPathElement { | ||
public XPathRootedElement(String nodeName) { | ||
super(nodeName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import org.antlr.v4.runtime.ANTLRFileStream; | ||
import org.antlr.v4.runtime.CharStream; | ||
import org.antlr.v4.runtime.CommonTokenStream; | ||
import org.antlr.v4.runtime.ParserRuleContext; | ||
import org.antlr.v4.runtime.tree.xpath.XPath; | ||
|
||
import java.io.IOException; | ||
|
||
public class TestXPath { | ||
public static void main(String[] args) throws IOException { | ||
CharStream input = new ANTLRFileStream("TestXPath.java"); | ||
JavaLexer lex = new JavaLexer(input); | ||
CommonTokenStream tokens = new CommonTokenStream(lex); | ||
JavaParser parser = new JavaParser(tokens); | ||
|
||
parser.setBuildParseTree(true); | ||
ParserRuleContext tree = parser.compilationUnit(); | ||
System.out.println(tree.toStringTree(parser)); | ||
|
||
XPath p = new XPath("ID"); | ||
p.evaluate(tree); | ||
new XPath("A/B"); | ||
new XPath("/A/B"); | ||
new XPath("A//B"); | ||
new XPath("A/*"); | ||
new XPath("*"); | ||
new XPath("*/A"); | ||
new XPath("A/*/B"); | ||
} | ||
} | ||
|