當前位置: 首頁>>代碼示例>>Java>>正文


Java Parser.setTrace方法代碼示例

本文整理匯總了Java中org.antlr.v4.runtime.Parser.setTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java Parser.setTrace方法的具體用法?Java Parser.setTrace怎麽用?Java Parser.setTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.antlr.v4.runtime.Parser的用法示例。


在下文中一共展示了Parser.setTrace方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: process

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
protected void process(Lexer lexer, Class<? extends Parser> parserClass, Parser parser, InputStream is, Reader r) throws IOException, IllegalAccessException, InvocationTargetException, PrintException {
	try {
		ANTLRInputStream input = new ANTLRInputStream(r);
		lexer.setInputStream(input);
		CommonTokenStream tokens = new CommonTokenStream(lexer);

		tokens.fill();

		if ( showTokens ) {
			for (Object tok : tokens.getTokens()) {
				System.out.println(tok);
			}
		}

		if ( startRuleName.equals(LEXER_START_RULE_NAME) ) return;

		if ( diagnostics ) {
			parser.addErrorListener(new DiagnosticErrorListener());
			parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);
		}

		if ( printTree || gui || psFile!=null ) {
			parser.setBuildParseTree(true);
		}

		if ( SLL ) { // overrides diagnostics
			parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
		}

		parser.setTokenStream(tokens);
		parser.setTrace(trace);

		try {
			Method startRule = parserClass.getMethod(startRuleName);
			ParserRuleContext tree = (ParserRuleContext)startRule.invoke(parser, (Object[])null);

			if ( printTree ) {
				System.out.println(tree.toStringTree(parser));
			}
			if ( gui ) {
				tree.inspect(parser);
			}
			if ( psFile!=null ) {
				tree.save(parser, psFile); // Generate postscript
			}
		}
		catch (NoSuchMethodException nsme) {
			System.err.println("No method for rule "+startRuleName+" or it has arguments");
		}
	}
	finally {
		if ( r!=null ) r.close();
		if ( is!=null ) is.close();
	}
}
 
開發者ID:MegaApuTurkUltra,項目名稱:Scratch-ApuC,代碼行數:56,代碼來源:TestRig.java

示例2: process

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
protected void process(Lexer lexer, Class<? extends Parser> parserClass, Parser parser, InputStream is, Reader r) throws IOException, IllegalAccessException, InvocationTargetException, PrintException {
	try {
		ANTLRInputStream input = new ANTLRInputStream(r);
		lexer.setInputStream(input);
		CommonTokenStream tokens = new CommonTokenStream(lexer);

		tokens.fill();

		if ( showTokens ) {
			for (Object tok : tokens.getTokens()) {
				System.out.println(tok);
			}
		}

		if ( startRuleName.equals(LEXER_START_RULE_NAME) ) return;

		if ( diagnostics ) {
			parser.addErrorListener(new DiagnosticErrorListener());
			parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);
		}

		if ( printTree || gui || psFile!=null ) {
			parser.setBuildParseTree(true);
		}

		if ( SLL ) { // overrides diagnostics
			parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
		}

		parser.setTokenStream(tokens);
		parser.setTrace(trace);

		try {
			Method startRule = parserClass.getMethod(startRuleName);
			ParserRuleContext tree = (ParserRuleContext)startRule.invoke(parser, (Object[])null);

			if ( printTree ) {
				System.out.println(tree.toStringTree(parser));
			}
			if ( gui ) {
				Trees.inspect(tree, parser);
			}
			if ( psFile!=null ) {
				Trees.save(tree, parser, psFile); // Generate postscript
			}
		}
		catch (NoSuchMethodException nsme) {
			System.err.println("No method for rule "+startRuleName+" or it has arguments");
		}
	}
	finally {
		if ( r!=null ) r.close();
		if ( is!=null ) is.close();
	}
}
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:56,代碼來源:TestRig.java

示例3: parse

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
protected SpecificationContext parse(Lexer lexer, Parser parser, InputStream is, Reader r) throws IOException, IllegalAccessException, PrintException {
  ANTLRInputStream input = new ANTLRInputStream(r);
  lexer.setInputStream(input);
  CommonTokenStream tokens = new CommonTokenStream(lexer);

  tokens.fill();

  if (options.showTokens) {
    for (Object tok : tokens.getTokens()) {
      System.out.println(tok);
    }
  }

  if (options.diagnostics) {
    parser.addErrorListener(new DiagnosticErrorListener());
    parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);
  }

  parser.setBuildParseTree(true);

  // SLL overrides diagnostics
  // %%% Not sure what it really is though.
  if (options.sll) {
    parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
  }

  parser.setTokenStream(tokens);
  parser.setTrace(options.trace);

  SpecificationContext tree = ((WebkitIDLParser)parser).specification();

  if (options.printTree) {
    System.out.println(tree.toStringTree(parser));
  }
  if (options.gui) {
    tree.inspect(parser);
  }
  if (options.psFile != null) {
    tree.save(parser, options.psFile); // Generate postscript
  }

  return tree;
}
 
開發者ID:blackoutjack,項目名稱:jamweaver,代碼行數:44,代碼來源:WebkitGenerator.java

示例4: parse

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
protected SpecificationContext parse(Lexer lexer, Parser parser, InputStream is, Reader r) throws IOException, IllegalAccessException, PrintException {
  ANTLRInputStream input = new ANTLRInputStream(r);
  lexer.setInputStream(input);
  CommonTokenStream tokens = new CommonTokenStream(lexer);

  tokens.fill();

  if (options.showTokens) {
    for (Object tok : tokens.getTokens()) {
      System.out.println(tok);
    }
  }

  if (options.diagnostics) {
    parser.addErrorListener(new DiagnosticErrorListener());
    parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);
  }

  parser.setBuildParseTree(true);

  // SLL overrides diagnostics
  // %%% Not sure what it really is though.
  if (options.sll) {
    parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
  }

  parser.setTokenStream(tokens);
  parser.setTrace(options.trace);

  SpecificationContext tree = ((GeckoIDLParser)parser).specification();

  if (options.printTree) {
    System.out.println(tree.toStringTree(parser));
  }
  if (options.gui) {
    tree.inspect(parser);
  }
  if (options.psFile != null) {
    tree.save(parser, options.psFile); // Generate postscript
  }

  return tree;
}
 
開發者ID:blackoutjack,項目名稱:jamweaver,代碼行數:44,代碼來源:GeckoGenerator.java


注:本文中的org.antlr.v4.runtime.Parser.setTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。