Esempio n. 1
0
 /**
  * During a parse is sometimes useful to listen in on the rule entry and exit events as well as
  * token matches. This is for quick and dirty debugging.
  */
 public void setTrace(boolean trace) {
   if (!trace) {
     removeParseListener(_tracer);
     _tracer = null;
   } else {
     if (_tracer != null) removeParseListener(_tracer);
     else _tracer = new TraceListener();
     addParseListener(_tracer);
   }
 }
Esempio n. 2
0
 /**
  * Trim the internal lists of the parse tree during parsing to conserve memory. This property is
  * set to {@code false} by default for a newly constructed parser.
  *
  * @param trimParseTrees {@code true} to trim the capacity of the {@link
  *     ParserRuleContext#children} list to its size after a rule is parsed.
  */
 public void setTrimParseTree(boolean trimParseTrees) {
   if (trimParseTrees) {
     if (getTrimParseTree()) return;
     addParseListener(TrimToSizeListener.INSTANCE);
   } else {
     removeParseListener(TrimToSizeListener.INSTANCE);
   }
 }