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


Java CommonTreeNodeStream.reset方法代碼示例

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


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

示例1: fromStream

import org.antlr.runtime.tree.CommonTreeNodeStream; //導入方法依賴的package包/類
public static Entity fromStream(EntityManager manager, InputStream is, ChannelModel cm, ErrorGatherer err) {
	try {
		Debug.logger.trace("Loading from stream an entity.");
		ANTLRInputStream input = new ANTLRInputStream(is);
		ASLanPPNewLexer lexer = new ASLanPPNewLexer(input);
		lexer.setErrorGatherer(err);
		CommonTokenStream tokens = new CommonTokenStream(lexer);
		ASLanPPNewParser parser = new ASLanPPNewParser(tokens);
		parser.setErrorGatherer(err);
		ASLanPPSpecification dummy = new ASLanPPSpecification(manager, "dummy", cm);
		ASLanPPNewParser.entityDeclaration_return r = parser.entityDeclaration(dummy);
		Entity ent = r.e;
		if (r.getTree() != null) {
			// By this time the types are registered, so we can run the
			// tree
			// grammar that will register the symbols.
			CommonTree ct = (CommonTree) r.getTree();
			CommonTreeNodeStream nodes = new CommonTreeNodeStream(ct);
			SymbolsNew symb = new SymbolsNew(nodes);
			symb.entity(dummy);
			// Now we can run the tree grammar that will load the
			// expressions and types into the in-memory model.
			nodes.reset();
			ToASLanNew ta = new ToASLanNew(nodes);
			ta.entity(dummy);
		}
		Debug.logger.info("Entity called '" + ent.getName() + "' was successfully loaded from stream.");
		return ent;
	}
	catch (Exception ex) {
		Debug.logger.error("Exception occured while loading entity from stream.", ex);
		err.addException(ErrorMessages.ERROR_AT_IMPORT, ex.getMessage());
		return null;
	}
}
 
開發者ID:siemens,項目名稱:ASLanPPConnector,代碼行數:36,代碼來源:Entity.java

示例2: fromStream

import org.antlr.runtime.tree.CommonTreeNodeStream; //導入方法依賴的package包/類
public static ASLanPPSpecification fromStream(EntityManager manager, String fileName, InputStream aslanppSpec, ErrorGatherer err) throws IOException, RecognitionException {
    if (fileName != null) {
        sourceName = new java.io.File(fileName).getName();
        if (sourceName != null) {
            // remove any file name extension
            int lastindex = sourceName.lastIndexOf('.');
            if (lastindex >= 0)
                sourceName = sourceName.substring(0, lastindex);
        }
    }
    // Run the lexer first.
    ANTLRInputStream antStream = new ANTLRInputStream(aslanppSpec);
    if (err == null)
      err = new ErrorGatherer(ErrorMessages.DEFAULT);
    ASLanPPNewLexer lexer = new ASLanPPNewLexer(antStream);
    lexer.setErrorGatherer(err);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    ASLanPPNewParser parser = new ASLanPPNewParser(tokens);
    parser.setErrorGatherer(err);
    ASLanPPNewParser.program_return r = null;
    r = parser.program(manager);
    Debug.logger.info("Parser reported " + parser.getNumberOfSyntaxErrors() + " errors.");
    ASLanPPSpecification spec = r.spec;
    if (spec != null) try {
        spec.getErrorGatherer().addAll(err); // copy any errors from parsing phase into the new instance.
        if(parser.getNumberOfSyntaxErrors() == 0 && r.getTree() != null) {
            // By this time the types are registered, so we can run the
            // tree grammar that will register the symbols.
            CommonTree ct = (CommonTree) r.getTree();
            CommonTreeNodeStream nodes = new CommonTreeNodeStream(ct);
            SymbolsNew symb = new SymbolsNew(nodes);
            symb.entity(spec);
            // Now we can run the tree grammar that will load the
            // expressions and types into the in-memory model.
            nodes.reset();
            ToASLanNew ta = new ToASLanNew(nodes);
            ta.entity(spec);
        }
    }
    finally {
            err.addAll(spec.getErrorGatherer()); //copy back any errors 
    }
    return spec;
}
 
開發者ID:siemens,項目名稱:ASLanPPConnector,代碼行數:45,代碼來源:ASLanPPSpecification.java


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