make trim parse trees singular

This commit is contained in:
Terence Parr 2012-03-12 15:40:22 -07:00
parent dc627158e6
commit aca3e0ddb2
1 changed files with 4 additions and 11 deletions

View File

@ -38,7 +38,6 @@ import org.antlr.v4.runtime.misc.IntervalSet;
import org.antlr.v4.runtime.misc.Nullable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/** This is all the parsing support code essentially; most of it is error recovery stuff. */
@ -181,12 +180,9 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator<Token>
* @param trimParseTrees {@code true} to trim the capacity of the {@link ParserRuleContext#children}
* list to its size after a rule is parsed.
*/
public void setTrimParseTrees(boolean trimParseTrees) {
public void setTrimParseTree(boolean trimParseTrees) {
if (trimParseTrees) {
if (getTrimParseTrees()) {
return;
}
if (getTrimParseTree()) return;
addParseListener(TrimToSizeListener.INSTANCE);
}
else {
@ -199,11 +195,8 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator<Token>
* @return {@code true} if the {@link ParserRuleContext#children} list is trimmed
* using the default {@link Parser.TrimToSizeListener} during the parse process.
*/
public boolean getTrimParseTrees() {
if (_parseListeners == null) {
return false;
}
public boolean getTrimParseTree() {
if (_parseListeners == null) return false;
return _parseListeners.contains(TrimToSizeListener.INSTANCE);
}