Package antlr.collections.impl

Examples of antlr.collections.impl.BitSet


    /** The input stream */
    protected TokenStream input;

    public TokenStreamBasicFilter(TokenStream input) {
        this.input = input;
        discardMask = new BitSet();
    }
View Full Code Here


            p.combineWith(q);
        }
        if (k == 1 && blk.not && subruleCanBeInverted(blk, lexicalAnalysis)) {
            // Invert the lookahead set
            if (lexicalAnalysis) {
                BitSet b = (BitSet)((LexerGrammar)grammar).charVocabulary.clone();
                int[] elems = p.fset.toArray();
                for (int j = 0; j < elems.length; j++) {
                    b.remove(elems[j]);
                }
                p.fset = b;
            }
            else {
                p.fset.notInPlace(Token.MIN_USER_TYPE, grammar.tokenManager.maxTokenType());
View Full Code Here

        if (k > 1) {
            return atom.next.look(k - 1);
        }
        if (lexicalAnalysis) {
            if (atom.not) {
                BitSet b = (BitSet)((LexerGrammar)grammar).charVocabulary.clone();
                if (DEBUG_ANALYZER) System.out.println("charVocab is " + b.toString());
                // remove stuff predicted by preceding alts and follow of block
                removeCompetingPredictionSets(b, atom);
                if (DEBUG_ANALYZER) System.out.println("charVocab after removal of prior alt lookahead " + b.toString());
                // now remove element that is stated not to be in the set
                b.clear(atom.getType());
                return new Lookahead(b);
            }
            else {
                return Lookahead.of(atom.getType());
            }
View Full Code Here

        if (DEBUG_ANALYZER) System.out.println("lookCharRange(" + k + "," + r + ")");
        // Skip until analysis hits k==1
        if (k > 1) {
            return r.next.look(k - 1);
        }
        BitSet p = BitSet.of(r.begin);
        for (int i = r.begin + 1; i <= r.end; i++) {
            p.add(i);
        }
        return new Lookahead(p);
    }
View Full Code Here

        if (DEBUG_ANALYZER) System.out.println("lookTokenRange(" + k + "," + r + ")");
        // Skip until analysis hits k==1
        if (k > 1) {
            return r.next.look(k - 1);
        }
        BitSet p = BitSet.of(r.begin);
        for (int i = r.begin + 1; i <= r.end; i++) {
            p.add(i);
        }
        return new Lookahead(p);
    }
View Full Code Here

        // Skip until analysis hits k==1
        if (k > 1) {
            return wc.next.look(k - 1);
        }

        BitSet b;
        if (lexicalAnalysis) {
            // Copy the character vocabulary
            b = (BitSet)((LexerGrammar)grammar).charVocabulary.clone();
        }
        else {
            b = new BitSet(1);
            // Invert the lookahead set against the token vocabulary
            int maxToken = grammar.tokenManager.maxTokenType();
            b.notInPlace(Token.MIN_USER_TYPE, maxToken);
            if (DEBUG_ANALYZER) System.out.println("look(" + k + "," + wc + ") after not: " + b);
        }

        // Remove prediction sets from competing alternatives
        // removeCompetingPredictionSets(b, wc);
View Full Code Here

     *  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;
    }
View Full Code Here

    /** The input stream */
    protected TokenStream input;

    public TokenStreamBasicFilter(TokenStream input) {
        this.input = input;
        discardMask = new BitSet();
    }
View Full Code Here

    protected String filterRule = null;

    LexerGrammar(String className_, Tool tool_, String superClass) {
        super(className_, tool_, superClass);
    // by default, use 0..127 for ASCII char vocabulary
    BitSet cv = new BitSet();
    for (int i = 0; i <= 127; i++) {
      cv.add(i);
    }
    setCharVocabulary(cv);

        // Lexer usually has no default error handling
        defaultErrorHandler = false;
View Full Code Here

     *  conflicts with parsing binary files.
     */
    boolean hasEpsilon = false;

    public Lookahead() {
        fset = new BitSet();
    }
View Full Code Here

TOP

Related Classes of antlr.collections.impl.BitSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.