public final RegExp normaliseCCLs()

in jflex/src/main/java/jflex/core/RegExp.java [360:421]


  public final RegExp normaliseCCLs(File f, int line) {
    RegExp1 unary;
    RegExp2 binary;
    RegExp content;

    try {
      switch (type) {
        case sym.BAR:
        case sym.CONCAT:
          binary = (RegExp2) this;
          return new RegExp2(
              type, binary.r1.normaliseCCLs(f, line), binary.r2.normaliseCCLs(f, line));

        case sym.STAR:
        case sym.PLUS:
        case sym.QUESTION:
        case sym.BANG:
        case sym.TILDE:
          unary = (RegExp1) this;
          content = (RegExp) unary.content;
          return new RegExp1(type, content.normaliseCCLs(f, line));

        case sym.STRING:
        case sym.STRING_I:
        case sym.CHAR:
        case sym.CHAR_I:
        case sym.PRIMCLASS:
          unary = (RegExp1) this;
          return new RegExp1(type, unary.content);

        case sym.CCLASS:
        case sym.CCLASSNOT:
          {
            unary = (RegExp1) this;
            List<RegExp> contents = (List<RegExp>) unary.content;
            IntCharSet set = new IntCharSet();
            for (RegExp r : contents) {
              RegExp1 n = checkPrimClass(r.normaliseCCLs(f, line));
              set.add((IntCharSet) n.content);
            }
            return new RegExp1(
                sym.PRIMCLASS, type == sym.CCLASS ? set : IntCharSet.complementOf(set));
          }

        case sym.CCLASSOP:
          unary = (RegExp1) this;
          binary = (RegExp2) unary.content;
          RegExp1 l = checkPrimClass(binary.r1.normaliseCCLs(f, line));
          IntCharSet setl = (IntCharSet) l.content;
          RegExp1 r = checkPrimClass(binary.r2.normaliseCCLs(f, line));
          IntCharSet setr = (IntCharSet) r.content;
          IntCharSet set = performClassOp(binary.type, setl, setr, this);
          return new RegExp1(sym.PRIMCLASS, set);

        default:
          throw new RegExpException(this);
      }
    } catch (CharClassException e) {
      Out.error(f, ErrorMessages.NOT_CHARCLASS, line, -1);
      throw new GeneratorException(e);
    }
  }