示例#1
0
文件: Prog.java 项目: Godin/re2j
 void patch(int l, int val) {
   while (l != 0) {
     Inst i = inst.get(l >> 1);
     if ((l & 1) == 0) {
       l = i.out;
       i.out = val;
     } else {
       l = i.arg;
       i.arg = val;
     }
   }
 }
示例#2
0
文件: Prog.java 项目: Godin/re2j
  // prefix() returns a pair of a literal string that all matches for the
  // regexp must start with, and a boolean which is true if the prefix is the
  // entire match.  The string is returned by appending to |prefix|.
  boolean prefix(StringBuilder prefix) {
    Inst i = skipNop(start);

    // Avoid allocation of buffer if prefix is empty.
    if (i.op() != Inst.Op.RUNE || i.runes.length != 1) {
      return i.op == Inst.Op.MATCH; // (append "" to prefix)
    }

    // Have prefix; gather characters.
    while (i.op() == Inst.Op.RUNE && i.runes.length == 1 && (i.arg & RE2.FOLD_CASE) == 0) {
      prefix.appendCodePoint(i.runes[0]); // an int, not a byte.
      i = skipNop(i.out);
    }
    return i.op == Inst.Op.MATCH;
  }
示例#3
0
文件: Prog.java 项目: Godin/re2j
 int append(int l1, int l2) {
   if (l1 == 0) {
     return l2;
   }
   if (l2 == 0) {
     return l1;
   }
   int last = l1;
   for (; ; ) {
     int next = next(last);
     if (next == 0) {
       break;
     }
     last = next;
   }
   Inst i = inst.get(last >> 1);
   if ((last & 1) == 0) {
     i.out = l2;
   } else {
     i.arg = l2;
   }
   return l1;
 }