Beispiel #1
0
 public static void loadFamily(TokenFamily family, Object newToken) {
   if (newToken instanceof DeferredToken) {
     family.addDeferredToken((DeferredToken<?>) newToken);
   }
   if (newToken instanceof CDOMPrimaryToken) {
     CDOMPrimaryToken<?> tok = (CDOMPrimaryToken<?>) newToken;
     CDOMToken<?> existingToken = family.putToken(tok);
     if (existingToken != null) {
       Logging.errorPrint(
           "Duplicate "
               + tok.getTokenClass().getSimpleName()
               + " Token found for token "
               + tok.getTokenName()
               + ". Classes were "
               + existingToken.getClass().getName()
               + " and "
               + newToken.getClass().getName());
     }
     if (PCCLASS_CLASS.equals(tok.getTokenClass())) {
       @SuppressWarnings("unchecked")
       CDOMPrimaryToken<PCClass> clTok = (CDOMPrimaryToken<PCClass>) tok;
       addToTokenMap(new ClassWrappedToken(clTok));
     }
   }
   if (newToken instanceof CDOMSecondaryToken) {
     CDOMSecondaryToken<?> tok = (CDOMSecondaryToken<?>) newToken;
     CDOMSubToken<?> existingToken = family.putSubToken(tok);
     if (existingToken != null) {
       Logging.errorPrint(
           "Duplicate "
               + tok.getTokenClass().getSimpleName()
               + " Token found for token "
               + tok.getParentToken()
               + ":"
               + tok.getTokenName()
               + ". Classes were "
               + existingToken.getClass().getName()
               + " and "
               + newToken.getClass().getName());
     }
   }
   if (newToken instanceof PrerequisiteParserInterface) {
     PrerequisiteParserInterface prereqToken = (PrerequisiteParserInterface) newToken;
     family.putPrerequisiteToken(prereqToken);
     for (String s : prereqToken.kindsHandled()) {
       /*
        * TODO Theoretically these belong in REV514, but put into
        * current for unparse testing
        */
       PreCompatibilityToken pos = new PreCompatibilityToken(s, prereqToken, false);
       if (family.putToken(pos) != null) {
         Logging.errorPrint(
             "Duplicate "
                 + pos.getTokenClass().getSimpleName()
                 + " Token found for token "
                 + pos.getTokenName());
       }
       if (family.putSubToken(pos) != null) {
         Logging.errorPrint(
             "Duplicate "
                 + pos.getTokenClass().getSimpleName()
                 + " Token found for token "
                 + pos.getParentToken()
                 + ":"
                 + pos.getTokenName());
       }
       family.putSubToken(pos);
       PreCompatibilityToken neg = new PreCompatibilityToken(s, prereqToken, true);
       if (family.putToken(neg) != null) {
         Logging.errorPrint(
             "Duplicate "
                 + neg.getTokenClass().getSimpleName()
                 + " Token found for token "
                 + neg.getTokenName());
       }
       if (family.putSubToken(neg) != null) {
         Logging.errorPrint(
             "Duplicate "
                 + neg.getTokenClass().getSimpleName()
                 + " Token found for token "
                 + neg.getParentToken()
                 + ":"
                 + neg.getTokenName());
       }
     }
   }
   if (newToken instanceof GroupDefinition) {
     family.addGroupDefinition((GroupDefinition<?>) newToken);
   }
 }
Beispiel #2
0
 public static void addToTokenMap(Object newToken) {
   if (newToken instanceof DeferredToken) {
     deferredTokens.add((DeferredToken<?>) newToken);
   }
   if (newToken instanceof PostDeferredToken) {
     PostDeferredToken<?> pdt = (PostDeferredToken<?>) newToken;
     postDeferredTokens.addToListFor(pdt.getPriority(), pdt);
   }
   if (newToken instanceof CDOMPrimaryToken) {
     CDOMPrimaryToken<?> tok = (CDOMPrimaryToken<?>) newToken;
     CDOMToken<?> existingToken = TokenFamily.CURRENT.putToken(tok);
     if (existingToken != null) {
       Logging.errorPrint(
           "Duplicate "
               + tok.getTokenClass().getSimpleName()
               + " Token found for token "
               + tok.getTokenName()
               + ". Classes were "
               + existingToken.getClass().getName()
               + " and "
               + newToken.getClass().getName());
     }
     if (PCCLASS_CLASS.equals(tok.getTokenClass())) {
       addToTokenMap(new ClassWrappedToken((CDOMPrimaryToken<PCClass>) tok));
     }
   }
   if (newToken instanceof CDOMSecondaryToken) {
     CDOMSecondaryToken<?> tok = (CDOMSecondaryToken<?>) newToken;
     CDOMSubToken<?> existingToken = TokenFamily.CURRENT.putSubToken(tok);
     if (existingToken != null) {
       Logging.errorPrint(
           "Duplicate "
               + tok.getTokenClass().getSimpleName()
               + " Token found for token "
               + tok.getParentToken()
               + ":"
               + tok.getTokenName()
               + ". Classes were "
               + existingToken.getClass().getName()
               + " and "
               + newToken.getClass().getName());
     }
   }
   // if (newToken instanceof ChoiceSetToken)
   // {
   // TokenFamily.CURRENT.putChooseToken((ChoiceSetToken<?>) newToken);
   // }
   if (newToken instanceof PrerequisiteParserInterface) {
     PrerequisiteParserInterface prereqToken = (PrerequisiteParserInterface) newToken;
     TokenFamily.CURRENT.putPrerequisiteToken(prereqToken);
     for (String s : prereqToken.kindsHandled()) {
       /*
        * TODO Theoretically these belong in REV514, but put into
        * current for unparse testing
        */
       PreCompatibilityToken pos = new PreCompatibilityToken(s, prereqToken, false);
       if (TokenFamily.CURRENT.putToken(pos) != null) {
         Logging.errorPrint(
             "Duplicate "
                 + pos.getTokenClass().getSimpleName()
                 + " Token found for token "
                 + pos.getTokenName());
       }
       if (TokenFamily.CURRENT.putSubToken(pos) != null) {
         Logging.errorPrint(
             "Duplicate "
                 + pos.getTokenClass().getSimpleName()
                 + " Token found for token "
                 + pos.getParentToken()
                 + ":"
                 + pos.getTokenName());
       }
       TokenFamily.CURRENT.putSubToken(pos);
       PreCompatibilityToken neg = new PreCompatibilityToken(s, prereqToken, true);
       if (TokenFamily.CURRENT.putToken(neg) != null) {
         Logging.errorPrint(
             "Duplicate "
                 + neg.getTokenClass().getSimpleName()
                 + " Token found for token "
                 + neg.getTokenName());
       }
       if (TokenFamily.CURRENT.putSubToken(neg) != null) {
         Logging.errorPrint(
             "Duplicate "
                 + neg.getTokenClass().getSimpleName()
                 + " Token found for token "
                 + neg.getParentToken()
                 + ":"
                 + neg.getTokenName());
       }
     }
   }
   if (newToken instanceof CDOMCompatibilityToken) {
     CDOMCompatibilityToken<?> tok = (CDOMCompatibilityToken<?>) newToken;
     TokenFamily fam =
         TokenFamily.getConstant(
             tok.compatibilityLevel(), tok.compatibilitySubLevel(), tok.compatibilityPriority());
     if (fam.putToken(tok) != null) {
       Logging.errorPrint(
           "Duplicate "
               + tok.getTokenClass().getSimpleName()
               + " Compatibility Token found for token "
               + tok.getTokenName()
               + " at compatibility level "
               + tok.compatibilityLevel()
               + "."
               + tok.compatibilitySubLevel()
               + "."
               + tok.compatibilityPriority());
     }
     TOKEN_FAMILIES.add(fam);
     if (fam.compareTo(TokenFamily.REV514) <= 0 && PCCLASS_CLASS.equals(tok.getTokenClass())) {
       addToTokenMap(new ClassWrappedToken((CDOMCompatibilityToken<PCClass>) tok));
     }
   }
   // if (newToken instanceof CDOMCompatibilitySubToken)
   // {
   // CDOMCompatibilitySubToken<?> tok = (CDOMCompatibilitySubToken<?>)
   // newToken;
   // TokenFamily fam = TokenFamily.getConstant(tok.compatibilityLevel(),
   // tok.compatibilitySubLevel(), tok.compatibilityPriority());
   // fam.putSubToken(tok);
   // tokenSources.add(fam);
   // }
   // if (newToken instanceof ChoiceSetCompatibilityToken)
   // {
   // ChoiceSetCompatibilityToken tok = (ChoiceSetCompatibilityToken)
   // newToken;
   // TokenFamily fam = TokenFamily.getConstant(tok.compatibilityLevel(),
   // tok.compatibilitySubLevel(), tok.compatibilityPriority());
   // fam.putChooseToken(tok);
   // tokenSources.add(fam);
   // }
 }