Package org.antlr.misc

Examples of org.antlr.misc.BitSet


    if ( follow.tokenTypeSet==null ) {
      words = new long[1];
            tokenTypeList = new ArrayList<Integer>();
        }
    else {
      BitSet bits = BitSet.of(follow.tokenTypeSet);
      words = bits.toPackedArray();
            tokenTypeList = follow.tokenTypeSet.toList();
        }
    // use the target to convert to hex strings (typically)
    String[] wordStrings = new String[words.length];
    for (int j = 0; j < words.length; j++) {
View Full Code Here


    List<Integer> unreachableAlts = dfa.getUnreachableAlts();

    // make sure unreachable alts are as expected
    if ( expectingUnreachableAlts!=null ) {
      BitSet s = new BitSet();
      s.addAll(expectingUnreachableAlts);
      BitSet s2 = new BitSet();
      s2.addAll(unreachableAlts);
      assertEquals("unreachable alts mismatch", s, s2);
    }
    else {
      assertEquals("number of unreachable alts", 0,
             unreachableAlts!=null?unreachableAlts.size():0);
    }

    // check conflicting input
    if ( expectingAmbigInput!=null ) {
      // first, find nondet message
      Message msg = equeue.warnings.get(0);
      assertTrue("expecting nondeterminism; found "+msg.getClass().getName(),
              msg instanceof GrammarNonDeterminismMessage);
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List<Label> labels =
        nondetMsg.probe.getSampleNonDeterministicInputSequence(nondetMsg.problemState);
      String input = nondetMsg.probe.getInputSequenceDisplay(labels);
      assertEquals(expectingAmbigInput, input);
    }

    // check nondet alts
    if ( expectingNonDetAlts!=null ) {
      RecursionOverflowMessage recMsg = null;
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List<Integer> nonDetAlts = null;
      if ( nondetMsg!=null ) {
        nonDetAlts =
          nondetMsg.probe.getNonDeterministicAltsForState(nondetMsg.problemState);
      }
      else {
        recMsg = getRecursionOverflowMessage(equeue.warnings);
        if ( recMsg!=null ) {
          //nonDetAlts = new ArrayList(recMsg.alts);
        }
      }
      // compare nonDetAlts with expectingNonDetAlts
      BitSet s = new BitSet();
      s.addAll(expectingNonDetAlts);
      BitSet s2 = new BitSet();
      s2.addAll(nonDetAlts);
      assertEquals("nondet alts mismatch", s, s2);
      assertTrue("found no nondet alts; expecting: "+
              str(expectingNonDetAlts),
              nondetMsg!=null||recMsg!=null);
    }
View Full Code Here

    //System.out.print(result);
    List<Integer> unreachableAlts = dfa.getUnreachableAlts();

    // make sure unreachable alts are as expected
    if ( expectingUnreachableAlts!=null ) {
      BitSet s = new BitSet();
      s.addAll(expectingUnreachableAlts);
      BitSet s2 = new BitSet();
      s2.addAll(unreachableAlts);
      assertEquals("unreachable alts mismatch", s, s2);
    }
    else {
      assertEquals("unreachable alts mismatch", 0,
             unreachableAlts!=null?unreachableAlts.size():0);
    }

    // check conflicting input
    if ( expectingAmbigInput!=null ) {
      // first, find nondet message
      Message msg = getNonDeterminismMessage(equeue.warnings);
      assertNotNull("no nondeterminism warning?", msg);
      assertTrue("expecting nondeterminism; found "+msg.getClass().getName(),
      msg instanceof GrammarNonDeterminismMessage);
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List<Label> labels =
        nondetMsg.probe.getSampleNonDeterministicInputSequence(nondetMsg.problemState);
      String input = nondetMsg.probe.getInputSequenceDisplay(labels);
      assertEquals(expectingAmbigInput, input);
    }

    // check nondet alts
    if ( expectingNonDetAlts!=null ) {
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      assertNotNull("found no nondet alts; expecting: "+
                    str(expectingNonDetAlts), nondetMsg);
      List<Integer> nonDetAlts =
        nondetMsg.probe.getNonDeterministicAltsForState(nondetMsg.problemState);
      // compare nonDetAlts with expectingNonDetAlts
      BitSet s = new BitSet();
      s.addAll(expectingNonDetAlts);
      BitSet s2 = new BitSet();
      s2.addAll(nonDetAlts);
      assertEquals("nondet alts mismatch", s, s2);
      assertEquals("mismatch between expected hasPredHiddenByAction", hasPredHiddenByAction,
             nondetMsg.problemState.dfa.hasPredicateBlockedByAction);
    }
    else {
      // not expecting any nondet alts, make sure there are none
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      assertNull("found nondet alts, but expecting none", nondetMsg);
    }

    if ( expectingInsufficientPredAlts!=null ) {
      GrammarInsufficientPredicatesMessage insuffPredMsg =
        getGrammarInsufficientPredicatesMessage(equeue.warnings);
      assertNotNull("found no GrammarInsufficientPredicatesMessage alts; expecting: "+
                    str(expectingNonDetAlts), insuffPredMsg);
      Map<Integer, Set<Token>> locations = insuffPredMsg.altToLocations;
      Set<Integer> actualAlts = locations.keySet();
      BitSet s = new BitSet();
      s.addAll(expectingInsufficientPredAlts);
      BitSet s2 = new BitSet();
      s2.addAll(actualAlts);
      assertEquals("mismatch between insufficiently covered alts", s, s2);
      assertEquals("mismatch between expected hasPredHiddenByAction", hasPredHiddenByAction,
             insuffPredMsg.problemState.dfa.hasPredicateBlockedByAction);
    }
    else {
View Full Code Here

    //System.out.print(result);
    List unreachableAlts = dfa.getUnreachableAlts();

    // make sure unreachable alts are as expected
    if ( expectingUnreachableAlts!=null ) {
      BitSet s = new BitSet();
      s.addAll(expectingUnreachableAlts);
      BitSet s2 = new BitSet();
      s2.addAll(unreachableAlts);
      assertEquals("unreachable alts mismatch", s, s2);
    }
    else {
      assertEquals("unreachable alts mismatch", 0,
             unreachableAlts!=null?unreachableAlts.size():0);
    }

    // check conflicting input
    if ( expectingAmbigInput!=null ) {
      // first, find nondet message
      Message msg = getNonDeterminismMessage(equeue.warnings);
      assertNotNull("no nondeterminism warning?", msg);
      assertTrue("expecting nondeterminism; found "+msg.getClass().getName(),
      msg instanceof GrammarNonDeterminismMessage);
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List labels =
        nondetMsg.probe.getSampleNonDeterministicInputSequence(nondetMsg.problemState);
      String input = nondetMsg.probe.getInputSequenceDisplay(labels);
      assertEquals(expectingAmbigInput, input);
    }

    // check nondet alts
    if ( expectingNonDetAlts!=null ) {
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      assertNotNull("found no nondet alts; expecting: "+
                    str(expectingNonDetAlts), nondetMsg);
      List nonDetAlts =
        nondetMsg.probe.getNonDeterministicAltsForState(nondetMsg.problemState);
      // compare nonDetAlts with expectingNonDetAlts
      BitSet s = new BitSet();
      s.addAll(expectingNonDetAlts);
      BitSet s2 = new BitSet();
      s2.addAll(nonDetAlts);
      assertEquals("nondet alts mismatch", s, s2);
      assertEquals("mismatch between expected hasPredHiddenByAction", hasPredHiddenByAction,
             nondetMsg.problemState.dfa.hasPredicateBlockedByAction);
    }
    else {
      // not expecting any nondet alts, make sure there are none
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      assertNull("found nondet alts, but expecting none", nondetMsg);
    }

    if ( expectingInsufficientPredAlts!=null ) {
      GrammarInsufficientPredicatesMessage insuffPredMsg =
        getGrammarInsufficientPredicatesMessage(equeue.warnings);
      assertNotNull("found no GrammarInsufficientPredicatesMessage alts; expecting: "+
                    str(expectingNonDetAlts), insuffPredMsg);
      Map<Integer, Set<Token>> locations = insuffPredMsg.altToLocations;
      Set actualAlts = locations.keySet();
      BitSet s = new BitSet();
      s.addAll(expectingInsufficientPredAlts);
      BitSet s2 = new BitSet();
      s2.addAll(actualAlts);
      assertEquals("mismatch between insufficiently covered alts", s, s2);
      assertEquals("mismatch between expected hasPredHiddenByAction", hasPredHiddenByAction,
             insuffPredMsg.problemState.dfa.hasPredicateBlockedByAction);
    }
    else {
View Full Code Here

    List unreachableAlts = dfa.getUnreachableAlts();

    // make sure unreachable alts are as expected
    if ( expectingUnreachableAlts!=null ) {
      BitSet s = new BitSet();
      s.addAll(expectingUnreachableAlts);
      BitSet s2 = new BitSet();
      s2.addAll(unreachableAlts);
      assertEquals("unreachable alts mismatch", s, s2);
    }
    else {
      assertEquals("number of unreachable alts", 0,
             unreachableAlts!=null?unreachableAlts.size():0);
    }

    // check conflicting input
    if ( expectingAmbigInput!=null ) {
      // first, find nondet message
      Message msg = (Message)equeue.warnings.get(0);
      assertTrue("expecting nondeterminism; found "+msg.getClass().getName(),
              msg instanceof GrammarNonDeterminismMessage);
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List labels =
        nondetMsg.probe.getSampleNonDeterministicInputSequence(nondetMsg.problemState);
      String input = nondetMsg.probe.getInputSequenceDisplay(labels);
      assertEquals(expectingAmbigInput, input);
    }

    // check nondet alts
    if ( expectingNonDetAlts!=null ) {
      RecursionOverflowMessage recMsg = null;
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List nonDetAlts = null;
      if ( nondetMsg!=null ) {
        nonDetAlts =
          nondetMsg.probe.getNonDeterministicAltsForState(nondetMsg.problemState);
      }
      else {
        recMsg = getRecursionOverflowMessage(equeue.warnings);
        if ( recMsg!=null ) {
          //nonDetAlts = new ArrayList(recMsg.alts);
        }
      }
      // compare nonDetAlts with expectingNonDetAlts
      BitSet s = new BitSet();
      s.addAll(expectingNonDetAlts);
      BitSet s2 = new BitSet();
      s2.addAll(nonDetAlts);
      assertEquals("nondet alts mismatch", s, s2);
      assertTrue("found no nondet alts; expecting: "+
              str(expectingNonDetAlts),
              nondetMsg!=null||recMsg!=null);
    }
View Full Code Here

    //System.out.print(result);
    List unreachableAlts = dfa.getUnreachableAlts();

    // make sure unreachable alts are as expected
    if ( expectingUnreachableAlts!=null ) {
      BitSet s = new BitSet();
      s.addAll(expectingUnreachableAlts);
      BitSet s2 = new BitSet();
      s2.addAll(unreachableAlts);
      assertEquals("unreachable alts mismatch", s, s2);
    }
    else {
      assertEquals("unreachable alts mismatch", 0,
             unreachableAlts!=null?unreachableAlts.size():0);
    }

    // check conflicting input
    if ( expectingAmbigInput!=null ) {
      // first, find nondet message
      Message msg = getNonDeterminismMessage(equeue.warnings);
      assertNotNull("no nondeterminism warning?", msg);
      assertTrue("expecting nondeterminism; found "+msg.getClass().getName(),
      msg instanceof GrammarNonDeterminismMessage);
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List labels =
        nondetMsg.probe.getSampleNonDeterministicInputSequence(nondetMsg.problemState);
      String input = nondetMsg.probe.getInputSequenceDisplay(labels);
      assertEquals(expectingAmbigInput, input);
    }

    // check nondet alts
    if ( expectingNonDetAlts!=null ) {
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      assertNotNull("found no nondet alts; expecting: "+
                    str(expectingNonDetAlts), nondetMsg);
      List nonDetAlts =
        nondetMsg.probe.getNonDeterministicAltsForState(nondetMsg.problemState);
      // compare nonDetAlts with expectingNonDetAlts
      BitSet s = new BitSet();
      s.addAll(expectingNonDetAlts);
      BitSet s2 = new BitSet();
      s2.addAll(nonDetAlts);
      assertEquals("nondet alts mismatch", s, s2);
      assertEquals("mismatch between expected hasPredHiddenByAction", hasPredHiddenByAction,
             nondetMsg.problemState.dfa.hasPredicateBlockedByAction);
    }
    else {
      // not expecting any nondet alts, make sure there are none
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      assertNull("found nondet alts, but expecting none", nondetMsg);
    }

    if ( expectingInsufficientPredAlts!=null ) {
      GrammarInsufficientPredicatesMessage insuffPredMsg =
        getGrammarInsufficientPredicatesMessage(equeue.warnings);
      assertNotNull("found no GrammarInsufficientPredicatesMessage alts; expecting: "+
                    str(expectingNonDetAlts), insuffPredMsg);
      Map<Integer, Set<Token>> locations = insuffPredMsg.altToLocations;
      Set actualAlts = locations.keySet();
      BitSet s = new BitSet();
      s.addAll(expectingInsufficientPredAlts);
      BitSet s2 = new BitSet();
      s2.addAll(actualAlts);
      assertEquals("mismatch between insufficiently covered alts", s, s2);
      assertEquals("mismatch between expected hasPredHiddenByAction", hasPredHiddenByAction,
             insuffPredMsg.problemState.dfa.hasPredicateBlockedByAction);
    }
    else {
View Full Code Here

    if ( follow.tokenTypeSet==null ) {
      words = new long[1];
            tokenTypeList = new ArrayList();
        }
    else {
      BitSet bits = BitSet.of(follow.tokenTypeSet);
      words = bits.toPackedArray();
            tokenTypeList = follow.tokenTypeSet.toList();
        }
    // use the target to convert to hex strings (typically)
    String[] wordStrings = new String[words.length];
    for (int j = 0; j < words.length; j++) {
View Full Code Here

    List unreachableAlts = dfa.getUnreachableAlts();

    // make sure unreachable alts are as expected
    if ( expectingUnreachableAlts!=null ) {
      BitSet s = new BitSet();
      s.addAll(expectingUnreachableAlts);
      BitSet s2 = new BitSet();
      s2.addAll(unreachableAlts);
      assertEquals("unreachable alts mismatch", s, s2);
    }
    else {
      assertEquals("number of unreachable alts", 0, unreachableAlts.size());
    }

    // check conflicting input
    if ( expectingAmbigInput!=null ) {
      // first, find nondet message
      Message msg = (Message)equeue.warnings.get(0);
      assertTrue("expecting nondeterminism; found "+msg.getClass().getName(),
              msg instanceof GrammarNonDeterminismMessage);
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List labels =
        nondetMsg.probe.getSampleNonDeterministicInputSequence(nondetMsg.problemState);
      String input = nondetMsg.probe.getInputSequenceDisplay(labels);
      assertEquals(expectingAmbigInput, input);
    }

    // check nondet alts
    if ( expectingNonDetAlts!=null ) {
      RecursionOverflowMessage recMsg = null;
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List nonDetAlts = null;
      if ( nondetMsg!=null ) {
        nonDetAlts =
          nondetMsg.probe.getNonDeterministicAltsForState(nondetMsg.problemState);
      }
      else {
        recMsg = getRecursionOverflowMessage(equeue.warnings);
        if ( recMsg!=null ) {
          //nonDetAlts = new ArrayList(recMsg.alts);
        }
      }
      // compare nonDetAlts with expectingNonDetAlts
      BitSet s = new BitSet();
      s.addAll(expectingNonDetAlts);
      BitSet s2 = new BitSet();
      s2.addAll(nonDetAlts);
      assertEquals("nondet alts mismatch", s, s2);
      assertTrue("found no nondet alts; expecting: "+
              str(expectingNonDetAlts),
              nondetMsg!=null||recMsg!=null);
    }
View Full Code Here

    List unreachableAlts = dfa.getUnreachableAlts();

    // make sure unreachable alts are as expected
    if ( expectingUnreachableAlts!=null ) {
      BitSet s = new BitSet();
      s.addAll(expectingUnreachableAlts);
      BitSet s2 = new BitSet();
      s2.addAll(unreachableAlts);
      assertEquals("unreachable alts mismatch", s, s2);
    }
    else {
      assertEquals("number of unreachable alts", 0,
             unreachableAlts!=null?unreachableAlts.size():0);
    }

    // check conflicting input
    if ( expectingAmbigInput!=null ) {
      // first, find nondet message
      Message msg = (Message)equeue.warnings.get(0);
      assertTrue("expecting nondeterminism; found "+msg.getClass().getName(),
              msg instanceof GrammarNonDeterminismMessage);
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List labels =
        nondetMsg.probe.getSampleNonDeterministicInputSequence(nondetMsg.problemState);
      String input = nondetMsg.probe.getInputSequenceDisplay(labels);
      assertEquals(expectingAmbigInput, input);
    }

    // check nondet alts
    if ( expectingNonDetAlts!=null ) {
      RecursionOverflowMessage recMsg = null;
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List nonDetAlts = null;
      if ( nondetMsg!=null ) {
        nonDetAlts =
          nondetMsg.probe.getNonDeterministicAltsForState(nondetMsg.problemState);
      }
      else {
        recMsg = getRecursionOverflowMessage(equeue.warnings);
        if ( recMsg!=null ) {
          //nonDetAlts = new ArrayList(recMsg.alts);
        }
      }
      // compare nonDetAlts with expectingNonDetAlts
      BitSet s = new BitSet();
      s.addAll(expectingNonDetAlts);
      BitSet s2 = new BitSet();
      s2.addAll(nonDetAlts);
      assertEquals("nondet alts mismatch", s, s2);
      assertTrue("found no nondet alts; expecting: "+
              str(expectingNonDetAlts),
              nondetMsg!=null||recMsg!=null);
    }
View Full Code Here

    //System.out.print(result);
    List unreachableAlts = dfa.getUnreachableAlts();

    // make sure unreachable alts are as expected
    if ( expectingUnreachableAlts!=null ) {
      BitSet s = new BitSet();
      s.addAll(expectingUnreachableAlts);
      BitSet s2 = new BitSet();
      s2.addAll(unreachableAlts);
      assertEquals("unreachable alts mismatch", s, s2);
    }
    else {
      assertEquals("unreachable alts mismatch", 0, unreachableAlts.size());
    }

    // check conflicting input
    if ( expectingAmbigInput!=null ) {
      // first, find nondet message
      Message msg = (Message)equeue.warnings.get(0);
      assertTrue("expecting nondeterminism; found "+msg.getClass().getName(),
      msg instanceof GrammarNonDeterminismMessage);
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      List labels =
        nondetMsg.probe.getSampleNonDeterministicInputSequence(nondetMsg.problemState);
      String input = nondetMsg.probe.getInputSequenceDisplay(labels);
      assertEquals(expectingAmbigInput, input);
    }

    // check nondet alts
    if ( expectingNonDetAlts!=null ) {
      GrammarNonDeterminismMessage nondetMsg =
        getNonDeterminismMessage(equeue.warnings);
      assertNotNull("found no nondet alts; expecting: "+
                    str(expectingNonDetAlts), nondetMsg);
      List nonDetAlts =
        nondetMsg.probe.getNonDeterministicAltsForState(nondetMsg.problemState);
      // compare nonDetAlts with expectingNonDetAlts
      BitSet s = new BitSet();
      s.addAll(expectingNonDetAlts);
      BitSet s2 = new BitSet();
      s2.addAll(nonDetAlts);
      assertEquals("nondet alts mismatch", s, s2);
    }
    else {
      // not expecting any nondet alts, make sure there are none
      GrammarNonDeterminismMessage nondetMsg =
View Full Code Here

TOP

Related Classes of org.antlr.misc.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.