コード例 #1
0
ファイル: Parser.java プロジェクト: antlr/antlr4
 /**
  * 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);
   }
 }
コード例 #2
0
ファイル: Parser.java プロジェクト: antlr/antlr4
 /**
  * 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);
   }
 }