system/src/sc/parser/IndexedChoice.java
public void removeParselet(Parselet oldParselet) {
      int oldIx;
      boolean removed = false;
      for (oldIx = 0; oldIx < parselets.size(); oldIx++) {
         if (parselets.get(oldIx) == oldParselet) {
            super.remove(oldIx);
            removed = true;
            break;
         }
      }
      if (!removed) {
         System.err.println("*** removeParselet for: " + this + " not found");
         return;
      }
      int defIx;
      for (defIx = 0; defIx < defaultParselets.size(); defIx++) {
         if (defaultParselets.get(defIx) == oldParselet) {
            defaultParselets.remove(defIx);
            break;
         }
      }
      CharSequence removeKey = null;
      for (Map.Entry<CharSequence, OrderedChoice.MatchResult> ent:indexedParselets.entrySet()) {
         OrderedChoice.MatchResult mr = ent.getValue();
         int[] elems = mr.slotIndexes;
         int sz = elems.length;
         for (int i = 0; i < sz; i++) {
            int old = elems[i];
            // If we remove the i'th entry, we need to update any indexes after that guy
            if (old > oldIx)
               elems[i] = old - 1;
            // This is the guy we removed
            else if (old == oldIx) {
               // When we are removing the last non-default parselet, just remove that index entirely
               if (sz == defaultParselets.size() + 1) {
                  removeKey = ent.getKey();
               }
               else {
                  mr.removeSlotIndex(i);
                  break;
               }
            }
         }
      }
      // No more entries for the key this child was registered under so remove it entirely
      if (removeKey != null) {
         indexedParselets.remove(removeKey);
         indexedKeys.removeExpectedValue(PString.toIString(removeKey));
      }
   }
/** When modifying an inherited grammar, you might need to remove a child parselet from the IndexedChoice */
When modifying an inherited grammar, you might need to remove a child parselet from the IndexedChoice
When modifying an inherited grammar you might need to remove a child parselet from the IndexedChoice
public void removeParselet(Parselet oldParselet) {
      int oldIx;
      boolean removed = false;
      for (oldIx = 0; oldIx < parselets.size(); oldIx++) {
         if (parselets.get(oldIx) == oldParselet) {
            super.remove(oldIx);
            removed = true;
            break;
         }
      }
      if (!removed) {
         System.err.println("*** removeParselet for: " + this + " not found");
         return;
      }
      int defIx;
      for (defIx = 0; defIx < defaultParselets.size(); defIx++) {
         if (defaultParselets.get(defIx) == oldParselet) {
            defaultParselets.remove(defIx);
            break;
         }
      }
      CharSequence removeKey = null;
      for (Map.Entry<CharSequence, OrderedChoice.MatchResult> ent:indexedParselets.entrySet()) {
         OrderedChoice.MatchResult mr = ent.getValue();
         int[] elems = mr.slotIndexes;
         int sz = elems.length;
         for (int i = 0; i < sz; i++) {
            int old = elems[i];
            if (old > oldIx)
               elems[i] = old - 1;
            else if (old == oldIx) {
               if (sz == defaultParselets.size() + 1) {
                  removeKey = ent.getKey();
               }
               else {
                  mr.removeSlotIndex(i);
                  break;
               }
            }
         }
      }
      if (removeKey != null) {
         indexedParselets.remove(removeKey);
         indexedKeys.removeExpectedValue(PString.toIString(removeKey));
      }
   }
public void removeParselet ( Parselet oldParselet ) { int oldIx ; boolean removed = false ; for ( oldIx = 0 ; oldIx < parselets . size ( ) ; oldIx ++ ) { if ( parselets . get ( oldIx ) == oldParselet ) { super . remove ( oldIx ) ; removed = true ; break ; } } if ( ! removed ) { System . err . println ( "*** removeParselet for: " + this + " not found" ) ; return ; } int defIx ; for ( defIx = 0 ; defIx < defaultParselets . size ( ) ; defIx ++ ) { if ( defaultParselets . get ( defIx ) == oldParselet ) { defaultParselets . remove ( defIx ) ; break ; } } CharSequence removeKey = null ; for ( Map . Entry < CharSequence , OrderedChoice . MatchResult > ent : indexedParselets . entrySet ( ) ) { OrderedChoice . MatchResult mr = ent . getValue ( ) ; int [ ] elems = mr . slotIndexes ; int sz = elems . length ; for ( int i = 0 ; i < sz ; i ++ ) { int old = elems [ i ] ; if ( old > oldIx ) elems [ i ] = old - 1 ; else if ( old == oldIx ) { if ( sz == defaultParselets . size ( ) + 1 ) { removeKey = ent . getKey ( ) ; } else { mr . removeSlotIndex ( i ) ; break ; } } } } if ( removeKey != null ) { indexedParselets . remove ( removeKey ) ; indexedKeys . removeExpectedValue ( PString . toIString ( removeKey ) ) ; } }
When modifying an inherited grammar, you might need to remove a child parselet from the IndexedChoice
When modifying an inherited grammar you might need to remove a child parselet from the IndexedChoice
// If we remove the i'th entry, we need to update any indexes after that guy // This is the guy we removed // When we are removing the last non-default parselet, just remove that index entirely // No more entries for the key this child was registered under so remove it entirely