trimParseTree property

bool get trimParseTree
inherited

@return true if the {@link ParserRuleContext#children} list is trimmed using the default {@link Parser.TrimToSizeListener} during the parse process.

Implementation

bool get trimParseTree {
  return parseListeners?.contains(TrimToSizeListener.INSTANCE) ?? false;
}
set trimParseTree (bool trimParseTrees)
inherited

Trim the internal lists of the parse tree during parsing to conserve memory. This property is set to false by default for a newly constructed parser.

@param trimParseTrees true to trim the capacity of the {@link ParserRuleContext#children} list to its size after a rule is parsed.

Implementation

set trimParseTree(bool trimParseTrees) {
  if (trimParseTrees) {
    if (trimParseTree) return;
    addParseListener(TrimToSizeListener.INSTANCE);
  } else {
    removeParseListener(TrimToSizeListener.INSTANCE);
  }
}