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


Java BitSet.toArray方法代码示例

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


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

示例1: genCases

import antlr.collections.impl.BitSet; //导入方法依赖的package包/类
/** Generate a series of case statements that implement a BitSet test.
 * @param p The Bitset for which cases are to be generated
 */
protected void genCases(BitSet p) {
	if ( DEBUG_CODE_GENERATOR ) System.out.println("genCases("+p+")");
	int[] elems;

	elems = p.toArray();
	// Wrap cases four-per-line for lexer, one-per-line for parser
	int wrap = 1; //(grammar instanceof LexerGrammar) ? 4 : 1;
	int j=1;
	boolean startOfLine = true;
	for (int i = 0; i < elems.length; i++) {
		if (j==1) {
			print("");
		} else {
			_print("  ");
		}
		_print("case " + getValueString(elems[i]) + ":");

		if (j==wrap) {
			_println("");
			startOfLine = true;
			j=1;
		}
		else {
			j++;
			startOfLine = false;
		}
	}
	if (!startOfLine) {
		_println("");
	}
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:35,代码来源:CppCodeGenerator.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: genCases

import antlr.collections.impl.BitSet; //导入方法依赖的package包/类
/** Generate a series of case statements that implement a BitSet test.
 * @param p The Bitset for which cases are to be generated
 */
protected void genCases(BitSet p) {
    if (DEBUG_CODE_GENERATOR) System.out.println("genCases(" + p + ")");
    int[] elems;

    elems = p.toArray();
    // Wrap cases four-per-line for lexer, one-per-line for parser
    int wrap = (grammar instanceof LexerGrammar) ? 4 : 1;
    int j = 1;
    boolean startOfLine = true;
    for (int i = 0; i < elems.length; i++) {
        if (j == 1) {
            print("");
        }
        else {
            _print("  ");
        }
        _print("case " + getValueString(elems[i]) + ":");

        if (j == wrap) {
            _println("");
            startOfLine = true;
            j = 1;
        }
        else {
            j++;
            startOfLine = false;
        }
    }
    if (!startOfLine) {
        _println("");
    }
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:36,代码来源:JavaCodeGenerator.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: genCases

import antlr.collections.impl.BitSet; //导入方法依赖的package包/类
/** Generate a series of case statements that implement a BitSet test.
 * @param p The Bitset for which cases are to be generated
 */
protected void genCases(BitSet p) {
	if ( DEBUG_CODE_GENERATOR ) System.out.println("genCases("+p+")");
	int[] elems;

	elems = p.toArray();
	// Wrap cases four-per-line for lexer, one-per-line for parser
	int wrap = (grammar instanceof LexerGrammar) ? 4 : 1;
	int j=1;
	boolean startOfLine = true;
	for (int i = 0; i < elems.length; i++) {
		if (j==1) {
			print("");
		} else {
			_print("  ");
		}
		_print("case " + getValueString(elems[i]) + ":");
		if (j==wrap) {
			_println("");
			startOfLine = true;
			j=1;
		}
		else {
			j++;
			startOfLine = false;
		}
	}
	if (!startOfLine) {
		_println("");
	}
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:34,代码来源:CSharpCodeGenerator.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.toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。