本文整理汇总了Java中org.antlr.runtime.BitSet类的典型用法代码示例。如果您正苦于以下问题:Java BitSet类的具体用法?Java BitSet怎么用?Java BitSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BitSet类属于org.antlr.runtime包,在下文中一共展示了BitSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import org.antlr.runtime.BitSet; //导入依赖的package包/类
boolean matches(BitSet bitSet) {
long[] array = bitSet.toPackedArray();
int len = array.length;
if (len < 3 || array[0] != 0L) {
return false;
}
long leftBits = array[1];
long rightBits = array[2];
if (rightBits == semicolonRecoverySetRight
&& (leftBits == semicolonRecoverySetLeft || leftBits == semicolonRecoverySetWithComma)) {
for (int i = 3; i < len; i++) {
if (array[i] != 0L) {
return false;
}
}
return true;
}
return false;
}
示例2: followedBySemicolon
import org.antlr.runtime.BitSet; //导入依赖的package包/类
/**
* Returns {@code true} if the set of expected follow-states includes an implicit or explicit semicolon.
*/
private static boolean followedBySemicolon(RecognizerSharedState state, Callback.RecoverySets recoverySets,
int currentIndex) {
int top = state._fsp;
if (currentIndex != state.lastErrorIndex) {
long[] array = state.following[top].toPackedArray();
if (array.length == 1 && array[0] == (1L << Token.EOR_TOKEN_TYPE)) {
return false;
}
}
for (int i = top; i >= 0; i--) {
BitSet localFollowSet = state.following[i];
if (recoverySets.matches(localFollowSet)) {
return true;
}
}
return false;
}
示例3: consumeUntil
import org.antlr.runtime.BitSet; //导入依赖的package包/类
/** Consume tokens until one matches the given token set */
@Override
public void consumeUntil(IntStream i, BitSet set) {
// System.out.println("consumeUntil(" + set.toString(getTokenNames()) + ")");
Token ttype;
List<Token> skipped = new ArrayList<>();
beginResync();
try {
while ((ttype = input.LT(1)) != null && ttype.getType() != Token.EOF && !set.member(ttype.getType())) {
// System.out.println("consume during recover LA(1)=" + getTokenNames()[input.LA(1)]);
input.consume();
skipped.add(ttype);
}
} finally {
endResync();
}
((NbParseTreeBuilder) dbg).consumeSkippedTokens(skipped);
}
示例4: bitsetName
import org.antlr.runtime.BitSet; //导入依赖的package包/类
/** Added for debugging purposes only. */
@SuppressWarnings("unused")
private String bitsetName(BitSet bitset) {
Optional<Field> findField = Stream.of(InternalN4JSParser.class.getDeclaredFields())
.filter(f -> Modifier.isStatic(f.getModifiers())).filter(f -> {
try {
return bitset == f.get(null);
} catch (Exception ex) {
//
}
return false;
}).findFirst();
return findField.map(Field::getName).orElse("NN");
}
示例5: computeRecoverySets
import org.antlr.runtime.BitSet; //导入依赖的package包/类
/**
* Computes the ASI recovery sets.
*/
default RecoverySets computeRecoverySets() {
BitSet followSet = getSemicolonFollowSet();
long[] array = followSet.toPackedArray();
if (array.length != 3 || array[0] != 0L) {
throw new RuntimeException("Internal token types changed. Need to rework ASI.");
}
int commaBit = getCommaBit() - Long.SIZE;
if (commaBit < 0 || commaBit > Long.SIZE) {
throw new RuntimeException("Internal token types changed. Need to rework ASI.");
}
RecoverySets result = new RecoverySets(array, commaBit);
return result;
}
示例6: testBug326509
import org.antlr.runtime.BitSet; //导入依赖的package包/类
@Test public void testBug326509() {
for(int i = 0; i <= 200; i++) {
testMe.pushFollow(new BitSet());
}
BitSet[] following = testMe.getFollowing();
for(int i = 0; i < following.length && i <= 200; i++) {
assertNotNull(Integer.toString(i), following[i]);
}
}
示例7: recoverFromMismatchedToken
import org.antlr.runtime.BitSet; //导入依赖的package包/类
@Override
protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException {
try {
mismatch = true;
return super.recoverFromMismatchedToken(input, ttype, follow);
} finally {
mismatch = false;
}
}
示例8: recoverFromMismatchedToken
import org.antlr.runtime.BitSet; //导入依赖的package包/类
@Override
protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException {
try {
mismatch = true;
return super.recoverFromMismatchedToken(input, ttype, follow);
}
finally {
mismatch = false;
}
}
示例9: recoverFromMismatchedToken
import org.antlr.runtime.BitSet; //导入依赖的package包/类
@Override
protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException
{
throw new MismatchedTokenException(ttype, input);
}
示例10: recoverFromMismatchedToken
import org.antlr.runtime.BitSet; //导入依赖的package包/类
@Override
protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException
{
throw new MismatchedTokenException(ttype, input);
}
示例11: getSemicolonFollowSet
import org.antlr.runtime.BitSet; //导入依赖的package包/类
@Override
public BitSet getSemicolonFollowSet() {
return FOLLOW_ruleExpression_in_ruleExpressionStatement;
}
示例12: recoverFromMismatchedToken
import org.antlr.runtime.BitSet; //导入依赖的package包/类
@Override
protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException {
//disable the default token auto-insertion/deletion recovery
throw new MismatchedTokenException(ttype, input);
}
示例13: getFollowing
import org.antlr.runtime.BitSet; //导入依赖的package包/类
public BitSet[] getFollowing() {
return state.following;
}
示例14: pushFollow
import org.antlr.runtime.BitSet; //导入依赖的package包/类
@Override
public void pushFollow(BitSet bitSet) {
super.pushFollow(bitSet);
}
示例15: mismatchIsMissingToken
import org.antlr.runtime.BitSet; //导入依赖的package包/类
@Override
public boolean mismatchIsMissingToken(IntStream input, BitSet follow) {
return false;
}