Exemplo n.º 1
0
 /** TypeArgument: WildcardIndicator_opt FieldTypeSignature "*" */
 private TypeArgument parseTypeArgument() {
   FieldTypeSignature[] ub, lb;
   ub = new FieldTypeSignature[1];
   lb = new FieldTypeSignature[1];
   TypeArgument[] ta = new TypeArgument[0];
   char c = current();
   switch (c) {
     case '+':
       {
         advance();
         ub[0] = parseFieldTypeSignature();
         lb[0] = BottomSignature.make(); // bottom
         return Wildcard.make(ub, lb);
       }
     case '*':
       {
         advance();
         ub[0] = SimpleClassTypeSignature.make("j86.java.lang.Object", false, ta);
         lb[0] = BottomSignature.make(); // bottom
         return Wildcard.make(ub, lb);
       }
     case '-':
       {
         advance();
         lb[0] = parseFieldTypeSignature();
         ub[0] = SimpleClassTypeSignature.make("j86.java.lang.Object", false, ta);
         return Wildcard.make(ub, lb);
       }
     default:
       return parseFieldTypeSignature();
   }
 }
Exemplo n.º 2
0
  /** PackageSpecifier: Identifier "/" PackageSpecifier* */
  private SimpleClassTypeSignature parsePackageNameAndSimpleClassTypeSignature() {
    // Parse both any optional leading PackageSpecifier as well as
    // the following SimpleClassTypeSignature.

    String id = parseIdentifier();

    if (current() == '/') { // package name
      StringBuilder idBuild = new StringBuilder(id);

      while (current() == '/') {
        advance();
        idBuild.append(".");
        idBuild.append(parseIdentifier());
      }
      id = idBuild.toString();
    }

    switch (current()) {
      case ';':
        return SimpleClassTypeSignature.make(id, false, new TypeArgument[0]); // all done!
      case '<':
        if (DEBUG) System.out.println("\t remainder: " + remainder());
        return SimpleClassTypeSignature.make(id, false, parseTypeArguments());
      default:
        throw error("expected '<' or ';' but got " + current());
    }
  }
Exemplo n.º 3
0
  /** SimpleClassTypeSignature: Identifier TypeArguments_opt */
  private SimpleClassTypeSignature parseSimpleClassTypeSignature(boolean dollar) {
    String id = parseIdentifier();
    char c = current();

    switch (c) {
      case ';':
      case '.':
        return SimpleClassTypeSignature.make(id, dollar, new TypeArgument[0]);
      case '<':
        return SimpleClassTypeSignature.make(id, dollar, parseTypeArguments());
      default:
        throw error("expected '<' or ';' or '.', got '" + c + "'.");
    }
  }