Fix documentation problems

This commit is contained in:
Sam Harwell 2014-02-03 19:35:31 -06:00
parent 51bc2e2def
commit 2730781c98
4 changed files with 52 additions and 28 deletions

View File

@ -30,6 +30,7 @@
package org.antlr.v4.runtime.atn;
import org.antlr.v4.runtime.BailErrorStrategy;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.IntStream;
import org.antlr.v4.runtime.NoViableAltException;
@ -243,7 +244,7 @@ import java.util.Set;
* mode with the {@link BailErrorStrategy}:</p>
*
* <pre>
* parser.{@link Parser#getInterpreter() getInterpreter()}.{@link #setSLL setSLL(true)};
* parser.{@link Parser#getInterpreter() getInterpreter()}.{@link #setPredictionMode setPredictionMode}{@code (}{@link PredictionMode#SLL}{@code )};
* parser.{@link Parser#setErrorHandler setErrorHandler}(new {@link BailErrorStrategy}());
* </pre>
*

View File

@ -16,34 +16,48 @@ import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
/** Represent a subset of XPath XML path syntax for use in identifying nodes in
* parse trees.
/**
* Represent a subset of XPath XML path syntax for use in identifying nodes in
* parse trees.
*
* Split path into words and separators / and // via ANTLR itself then walk
* path elements from left to right. At each separator-word pair, find set
* of nodes. Next stage uses those as work list.
* <p>
* Split path into words and separators {@code /} and {@code //} via ANTLR
* itself then walk path elements from left to right. At each separator-word
* pair, find set of nodes. Next stage uses those as work list.</p>
*
* The basic interface is ParseTree.findAll(parser, pathString). But that is
* just shorthand for:
* <p>
* The basic interface is
* {@link XPath#findAll ParseTree.findAll}{@code (tree, pathString, parser)}.
* But that is just shorthand for:</p>
*
* XPath p = new XPath(parser, xpath);
* return p.evaluate(this);
* <pre>
* {@link XPath} p = new {@link XPath#XPath XPath}(parser, pathString);
* return p.{@link #evaluate evaluate}(tree);
* </pre>
*
* See {@code org.antlr.v4.test.TestXPath} for descriptions. In short, this allows
* operators:
* <p>
* See {@code org.antlr.v4.test.TestXPath} for descriptions. In short, this
* allows operators:</p>
*
* / root
* // anywhere
* ! invert; this must appear directly after root or anywhere operator
* <dl>
* <dt>/</dt> <dd>root</dd>
* <dt>//</dt> <dd>anywhere</dd>
* <dt>!</dt> <dd>invert; this must appear directly after root or anywhere
* operator</dd>
* </dl>
*
* and path elements:
* <p>
* and path elements:</p>
*
* ID token name
* 'string' any string literal token from the grammar
* expr rule name
* * wildcard matching any node
* <dl>
* <dt>ID</dt> <dd>token name</dd>
* <dt>'string'</dt> <dd>any string literal token from the grammar</dd>
* <dt>expr</dt> <dd>rule name</dd>
* <dt>*</dt> <dd>wildcard matching any node</dd>
* </dl>
*
* Whitespace is not allowed.
* <p>
* Whitespace is not allowed.</p>
*/
public class XPath {
public static final String WILDCARD = "*"; // word not operator/separator
@ -128,8 +142,10 @@ loop:
return elements.toArray(new XPathElement[0]);
}
/** Convert word like * or ID or expr to a path element. anywhere is true
* if // precedes the word.
/**
* Convert word like {@code *} or {@code ID} or {@code expr} to a path
* element. {@code anywhere} is {@code true} if {@code //} precedes the
* word.
*/
protected XPathElement getXPathElement(Token wordToken, boolean anywhere) {
if ( wordToken.getType()==Token.EOF ) {
@ -173,8 +189,10 @@ loop:
return p.evaluate(tree);
}
/** Return a list of all nodes starting at t as root that satisfy the path.
* The root / is relative to the node passed to evaluate().
/**
* Return a list of all nodes starting at {@code t} as root that satisfy the
* path. The root {@code /} is relative to the node passed to
* {@link #evaluate}.
*/
public Collection<ParseTree> evaluate(final ParseTree t) {
ParserRuleContext dummyRoot = new ParserRuleContext();

View File

@ -8,14 +8,17 @@ public abstract class XPathElement {
protected String nodeName;
protected boolean invert;
/** Construct element like /ID or or ID or "/*" etc...
/** Construct element like {@code /ID} or {@code ID} or {@code /*} etc...
* op is null if just node
*/
public XPathElement(String nodeName) {
this.nodeName = nodeName;
}
/** Given tree rooted at t return all nodes matched by this path element */
/**
* Given tree rooted at {@code t} return all nodes matched by this path
* element.
*/
public abstract Collection<ParseTree> evaluate(ParseTree t);
@Override

View File

@ -5,7 +5,9 @@ import org.antlr.v4.runtime.tree.Trees;
import java.util.Collection;
/** Either ID at start of path or ...//ID in middle of path */
/**
* Either {@code ID} at start of path or {@code ...//ID} in middle of path.
*/
public class XPathRuleAnywhereElement extends XPathElement {
protected int ruleIndex;
public XPathRuleAnywhereElement(String ruleName, int ruleIndex) {