当前位置: 首页>>代码示例>>Java>>正文


Java ANTLRParser.CLOSURE属性代码示例

本文整理汇总了Java中org.antlr.v4.parse.ANTLRParser.CLOSURE属性的典型用法代码示例。如果您正苦于以下问题:Java ANTLRParser.CLOSURE属性的具体用法?Java ANTLRParser.CLOSURE怎么用?Java ANTLRParser.CLOSURE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.antlr.v4.parse.ANTLRParser的用法示例。


在下文中一共展示了ANTLRParser.CLOSURE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEBNFBlock

@Override
public Choice getEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) {
	if (!g.tool.force_atn) {
		int decision;
		if ( ebnfRoot.getType()==ANTLRParser.POSITIVE_CLOSURE ) {
			decision = ((PlusLoopbackState)ebnfRoot.atnState).decision;
		}
		else if ( ebnfRoot.getType()==ANTLRParser.CLOSURE ) {
			decision = ((StarLoopEntryState)ebnfRoot.atnState).decision;
		}
		else {
			decision = ((DecisionState)ebnfRoot.atnState).decision;
		}

		if ( AnalysisPipeline.disjoint(g.decisionLOOK.get(decision)) ) {
			return getLL1EBNFBlock(ebnfRoot, alts);
		}
	}

	return getComplexEBNFBlock(ebnfRoot, alts);
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:21,代码来源:ParserFactory.java

示例2: getLL1EBNFBlock

@Override
public Choice getLL1EBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) {
	int ebnf = 0;
	if ( ebnfRoot!=null ) ebnf = ebnfRoot.getType();
	Choice c = null;
	switch ( ebnf ) {
		case ANTLRParser.OPTIONAL :
			if ( alts.size()==1 ) c = new LL1OptionalBlockSingleAlt(this, ebnfRoot, alts);
			else c = new LL1OptionalBlock(this, ebnfRoot, alts);
			break;
		case ANTLRParser.CLOSURE :
			if ( alts.size()==1 ) c = new LL1StarBlockSingleAlt(this, ebnfRoot, alts);
			else c = getComplexEBNFBlock(ebnfRoot, alts);
			break;
		case ANTLRParser.POSITIVE_CLOSURE :
			if ( alts.size()==1 ) c = new LL1PlusBlockSingleAlt(this, ebnfRoot, alts);
			else c = getComplexEBNFBlock(ebnfRoot, alts);
			break;
	}
	return c;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:21,代码来源:ParserFactory.java

示例3: getComplexEBNFBlock

@Override
public Choice getComplexEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) {
	int ebnf = 0;
	if ( ebnfRoot!=null ) ebnf = ebnfRoot.getType();
	Choice c = null;
	switch ( ebnf ) {
		case ANTLRParser.OPTIONAL :
			c = new OptionalBlock(this, ebnfRoot, alts);
			break;
		case ANTLRParser.CLOSURE :
			c = new StarBlock(this, ebnfRoot, alts);
			break;
		case ANTLRParser.POSITIVE_CLOSURE :
			c = new PlusBlock(this, ebnfRoot, alts);
			break;
	}
	return c;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:18,代码来源:ParserFactory.java

示例4: getStateToGrammarRegionMap

public static Map<Integer, Interval> getStateToGrammarRegionMap(GrammarRootAST ast, IntervalSet grammarTokenTypes) {
	Map<Integer, Interval> stateToGrammarRegionMap = new HashMap<Integer, Interval>();
	if ( ast==null ) return stateToGrammarRegionMap;

	List<GrammarAST> nodes = ast.getNodesWithType(grammarTokenTypes);
	for (GrammarAST n : nodes) {
		if (n.atnState != null) {
			Interval tokenRegion = Interval.of(n.getTokenStartIndex(), n.getTokenStopIndex());
			org.antlr.runtime.tree.Tree ruleNode = null;
			// RULEs, BLOCKs of transformed recursive rules point to original token interval
			switch ( n.getType() ) {
				case ANTLRParser.RULE :
					ruleNode = n;
					break;
				case ANTLRParser.BLOCK :
				case ANTLRParser.CLOSURE :
					ruleNode = n.getAncestor(ANTLRParser.RULE);
					break;
			}
			if ( ruleNode instanceof RuleAST ) {
				String ruleName = ((RuleAST) ruleNode).getRuleName();
				Rule r = ast.g.getRule(ruleName);
				if ( r instanceof LeftRecursiveRule ) {
					RuleAST originalAST = ((LeftRecursiveRule) r).getOriginalAST();
					tokenRegion = Interval.of(originalAST.getTokenStartIndex(), originalAST.getTokenStopIndex());
				}
			}
			stateToGrammarRegionMap.put(n.atnState.stateNumber, tokenRegion);
		}
	}
	return stateToGrammarRegionMap;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:32,代码来源:Grammar.java


注:本文中的org.antlr.v4.parse.ANTLRParser.CLOSURE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。