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


Java BitSet.degree方法代码示例

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


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

示例1: lookaheadEquivForApproxAndFullAnalysis

import antlr.collections.impl.BitSet; //导入方法依赖的package包/类
/** If the first k-1 sets are singleton sets, the appoximate
 *  lookahead analysis is equivalent to full lookahead analysis.
 */
public static boolean lookaheadEquivForApproxAndFullAnalysis(Lookahead[] bset, int k) {
    // first k-1 sets degree 1?
    for (int i = 1; i <= k - 1; i++) {
        BitSet look = bset[i].fset;
        if (look.degree() > 1) {
            return false;
        }
    }
    return true;
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:14,代码来源:LLkAnalyzer.java

示例2: getLookaheadTestTerm

import antlr.collections.impl.BitSet; //导入方法依赖的package包/类
/**Generate a depth==1 lookahead test expression given the BitSet.
 * This may be one of:
 * 1) a series of 'x==X||' tests
 * 2) a range test using >= && <= where possible,
 * 3) a bitset membership test for complex comparisons
 * @param k The lookahead level
 * @param p The lookahead set for level k
 */
protected String getLookaheadTestTerm(int k, BitSet p) {
	// Determine the name of the item to be compared
	String ts = lookaheadString(k);

	// Generate a range expression if possible
	int[] elems = p.toArray();
	if (elementsAreRange(elems)) {
		return getRangeExpression(k, elems);
	}

	// Generate a bitset membership test if possible
	StringBuffer e;
	int degree = p.degree();
	if ( degree == 0 ) {
		return "true";
	}

	if (degree >= bitsetTestThreshold) {
		int bitsetIdx = markBitsetForGen(p);
		return getBitsetName(bitsetIdx) + ".member(" + ts + ")";
	}

	// Otherwise, generate the long-winded series of "x==X||" tests
	e = new StringBuffer();
	for (int i = 0; i < elems.length; i++) {
		// Get the compared-to item (token or character value)
		String cs = getValueString(elems[i]);

		// Generate the element comparison
		if( i > 0 ) e.append(" || ");
		e.append(ts);
		e.append(" == ");
		e.append(cs);
	}
	return e.toString();
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:45,代码来源:CppCodeGenerator.java

示例3: lookaheadIsEmpty

import antlr.collections.impl.BitSet; //导入方法依赖的package包/类
/**Is the lookahead for this alt empty? */
protected boolean lookaheadIsEmpty(Alternative alt, int maxDepth) {
	int depth = alt.lookaheadDepth;
	if ( depth == GrammarAnalyzer.NONDETERMINISTIC ) {
		depth = grammar.maxk;
	}
	for (int i=1; i<=depth && i<=maxDepth; i++) {
		BitSet p = alt.cache[i].fset;
		if (p.degree() != 0) {
			return false;
		}
	}
	return true;
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:15,代码来源:CppCodeGenerator.java

示例4: getLookaheadTestTerm

import antlr.collections.impl.BitSet; //导入方法依赖的package包/类
/**Generate a depth==1 lookahead test expression given the BitSet.
 * This may be one of:
 * 1) a series of 'x==X||' tests
 * 2) a range test using >= && <= where possible,
 * 3) a bitset membership test for complex comparisons
 * @param k The lookahead level
 * @param p The lookahead set for level k
 */
protected String getLookaheadTestTerm(int k, BitSet p) {
    // Determine the name of the item to be compared
    String ts = lookaheadString(k);

    // Generate a range expression if possible
    int[] elems = p.toArray();
    if (elementsAreRange(elems)) {
        return getRangeExpression(k, elems);
    }

    // Generate a bitset membership test if possible
    StringBuffer e;
    int degree = p.degree();
    if (degree == 0) {
        return "true";
    }

    if (degree >= bitsetTestThreshold) {
        int bitsetIdx = markBitsetForGen(p);
        return getBitsetName(bitsetIdx) + ".member(" + ts + ")";
    }

    // Otherwise, generate the long-winded series of "x==X||" tests
    e = new StringBuffer();
    for (int i = 0; i < elems.length; i++) {
        // Get the compared-to item (token or character value)
        String cs = getValueString(elems[i]);

        // Generate the element comparison
        if (i > 0) e.append("||");
        e.append(ts);
        e.append("==");
        e.append(cs);
    }
    return e.toString();
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:45,代码来源:JavaCodeGenerator.java

示例5: lookaheadIsEmpty

import antlr.collections.impl.BitSet; //导入方法依赖的package包/类
/**Is the lookahead for this alt empty? */
protected boolean lookaheadIsEmpty(Alternative alt, int maxDepth) {
    int depth = alt.lookaheadDepth;
    if (depth == GrammarAnalyzer.NONDETERMINISTIC) {
        depth = grammar.maxk;
    }
    for (int i = 1; i <= depth && i <= maxDepth; i++) {
        BitSet p = alt.cache[i].fset;
        if (p.degree() != 0) {
            return false;
        }
    }
    return true;
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:15,代码来源:JavaCodeGenerator.java

示例6: getLookaheadTestTerm

import antlr.collections.impl.BitSet; //导入方法依赖的package包/类
/**Generate a depth==1 lookahead test expression given the BitSet.
 * This may be one of:
 * 1) a series of 'x==X||' tests
 * 2) a range test using >= && <= where possible,
 * 3) a bitset membership test for complex comparisons
 * @param k The lookahead level
 * @param p The lookahead set for level k
 */
protected String getLookaheadTestTerm(int k, BitSet p) {
	// Determine the name of the item to be compared
	String ts = lookaheadString(k);

	// Generate a range expression if possible
	int[] elems = p.toArray();
	if (elementsAreRange(elems)) {
		return getRangeExpression(k, elems);
	}

	// Generate a bitset membership test if possible
	StringBuffer e;
	int degree = p.degree();
	if ( degree == 0 ) {
		return "true";
	}

	if (degree >= bitsetTestThreshold) {
		int bitsetIdx = markBitsetForGen(p);
		return getBitsetName(bitsetIdx) + ".member(" + ts + ")";
	}

	// Otherwise, generate the long-winded series of "x==X||" tests
	e = new StringBuffer();
	for (int i = 0; i < elems.length; i++) {
		// Get the compared-to item (token or character value)
		String cs = getValueString(elems[i]);

		// Generate the element comparison
		if ( i>0 ) e.append("||");
		e.append(ts);
		e.append("==");
		e.append(cs);
	}
	return e.toString();
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:45,代码来源:CSharpCodeGenerator.java


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