Java 类org.antlr.runtime.BitSet 实例源码

项目:n4js    文件:SemicolonInjectionHelper.java   
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;
}
项目:n4js    文件:SemicolonInjectionHelper.java   
/**
 * 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;
}
项目:incubator-netbeans    文件:ExtCss3Parser.java   
/** 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);
    }
项目:n4js    文件:InternalSemicolonInjectingParser.java   
/** 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");
}
项目:n4js    文件:SemicolonInjectionHelper.java   
/**
 * 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;
}
项目:xtext-core    文件:Bug326509Test.java   
@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]);
    }
}
项目:xtext-core    文件:BaseInternalContentAssistParser.java   
@Override
protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException {
    try {
        mismatch = true;
        return super.recoverFromMismatchedToken(input, ttype, follow);
    } finally {
        mismatch = false;
    }
}
项目:bts    文件:AbstractInternalContentAssistParser.java   
@Override
protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException {
    try {
        mismatch = true;
        return super.recoverFromMismatchedToken(input, ttype, follow);
    }
    finally {
        mismatch = false;
    }
}
项目:sstable-adaptor    文件:Cql_Parser.java   
@Override
protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException
{
    throw new MismatchedTokenException(ttype, input);
}
项目:sstable-adaptor    文件:CqlParser.java   
@Override
protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException
{
    throw new MismatchedTokenException(ttype, input);
}
项目:n4js    文件:InternalHighlightingParser.java   
@Override
public BitSet getSemicolonFollowSet() {
    return FOLLOW_ruleExpression_in_ruleExpressionStatement;
}
项目:n4js    文件:InternalSemicolonInjectingParser.java   
@Override
public BitSet getSemicolonFollowSet() {
    return FOLLOW_ruleExpression_in_ruleExpressionStatement;
}
项目:incubator-netbeans    文件:ExtCss3Parser.java   
@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);
}
项目:xtext-core    文件:Bug326509Test.java   
public BitSet[] getFollowing() {
    return state.following;
}
项目:xtext-core    文件:Bug326509Test.java   
@Override
public void pushFollow(BitSet bitSet) {
    super.pushFollow(bitSet);
}
项目:xtext-core    文件:BaseInternalContentAssistParser.java   
@Override
public boolean mismatchIsMissingToken(IntStream input, BitSet follow) {
    return false;
}
项目:bts    文件:AbstractInternalContentAssistParser.java   
@Override
public boolean mismatchIsMissingToken(IntStream input, BitSet follow) {
    return false;
}
项目:openbd-core    文件:CFMLTree.java   
protected void mismatch( IntStream input, int ttype, BitSet follow ) throws RecognitionException {
  throw new MismatchedTokenException(ttype, input);
}
项目:openbd-core    文件:CFMLTree.java   
public Object recoverFromMismatchedSet( IntStream input, RecognitionException e, BitSet follow ) throws RecognitionException{
  throw e;
}
项目:openbd-core    文件:CFMLParser.java   
protected void mismatch( IntStream input, int ttype, BitSet follow ) throws RecognitionException {
  throw new MismatchedTokenException(ttype, input);
}
项目:openbd-core    文件:CFMLParser.java   
public Object recoverFromMismatchedSet( IntStream input, RecognitionException e, BitSet follow ) throws RecognitionException{
  throw e;
}
项目:pentaho-kettle    文件:FastSimpleGenericEdifactDirectXMLParser.java   
protected void mismatch( IntStream input, int ttype, BitSet follow ) throws RecognitionException {
  throw new MismatchedTokenException( ttype, input );
}
项目:pentaho-kettle    文件:FastSimpleGenericEdifactDirectXMLParser.java   
public Object recoverFromMismatchedSet( IntStream input, RecognitionException e, BitSet follow ) throws RecognitionException {
  throw e;
}
项目:CFLint    文件:CFLint.java   
@Override
public void reportAmbiguity(final Parser recognizer, final DFA dfa, final int startIndex, final int stopIndex,
        final boolean exact, final java.util.BitSet ambigAlts, final ATNConfigSet configs) {
    // Empty implementation
}
项目:CFLint    文件:CFLint.java   
@Override
public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex,
        final int stopIndex, final java.util.BitSet conflictingAlts, final ATNConfigSet configs) {
    // Empty implementation
}
项目:CFLint    文件:CFLint.java   
@Override
public void reportError(final org.antlr.v4.runtime.IntStream input,
        final org.antlr.v4.runtime.RecognitionException re, final BitSet follow) {
    // Empty implementation
}
项目:n4js    文件:SemicolonInjectionHelper.java   
/**
 * Obtain the follow set that is relevant for the ASI.
 */
BitSet getSemicolonFollowSet();