Beispiel #1
0
    public static int ParseQuotedString(
string str,
int index,
int endIndex,
ITokener tokener) {
      int indexStart, indexStart2, indexTemp, indexTemp2, state, state2, tx3;
      indexStart = index;
      state = (tokener != null) ? tokener.GetState() : 0;
      indexTemp = index;
      do {
        index = ParseCFWS(str, index, endIndex, tokener);
        if (index < endIndex && (str[index] == 34)) {
          ++index;
        } else {
          index = indexStart; break;
        }
        while (true) {
          state2 = (tokener != null) ? tokener.GetState() : 0;
          indexTemp2 = index;
          do {
            indexStart2 = index;
            index = ParseFWS(str, index, endIndex, tokener);
            tx3 = ParseQcontent(str, index, endIndex, tokener);
            if (tx3 == index) {
              index = indexStart2; break;
            } else {
              index = tx3;
            }
            indexTemp2 = index;
            index = indexStart2;
          } while (false);
          if (indexTemp2 != index) {
            index = indexTemp2;
          } else if (tokener != null) {
            tokener.RestoreState(state2); break;
          } else {
 break;
}
        }
        index = ParseFWS(str, index, endIndex, tokener);
        if (index < endIndex && (str[index] == 34)) {
          ++index;
        } else {
          index = indexStart; break;
        }
        index = ParseCFWS(str, index, endIndex, tokener);
        indexTemp = index;
      } while (false);
      if (tokener != null) {
        if (indexTemp == indexStart) {
 tokener.RestoreState(state);
} else {
 tokener.Commit(7, indexStart, indexTemp);
}
      }
      return indexTemp;
    }
    // Parses a comment using the obsolete syntax.
    internal static int ParseCommentLax(
string str,
int index,
int endIndex,
ITokener tokener) {
      int indexStart = index;
      var depth = 0;
      if (index < endIndex && (str[index] == 40)) {
        ++index;
      } else {
        return index;
      }
      int state = (tokener != null) ? tokener.GetState() : 0;
      do {
        while (true) {
          int indexTemp2;
          int state2 = (tokener != null) ? tokener.GetState() : 0;
          indexTemp2 = index;
          do {
            int indexStart2 = index;
            index = HeaderParser.ParseFWS(str, index, endIndex, null);
            do {
              int indexTemp3 = index;
              do {
                if (index < endIndex && ((str[index] >= 128 && str[index] <=
                  55295) || (str[index] >= 57344 && str[index] <= 65535))) {
                  ++indexTemp3; break;
                }
                if (index + 1 < endIndex && ((str[index] >= 55296 &&
                  str[index] <= 56319) && (str[index + 1] >= 56320 &&
                  str[index + 1] <= 57343))) {
                  indexTemp3 += 2; break;
                }
                int indexTemp4;
      indexTemp4 = HeaderParser.ParseQuotedPair(
str,
index,
endIndex,
null);
                if (indexTemp4 != index) {
                  indexTemp3 = indexTemp4; break;
                }
                if (index < endIndex && ((str[index] >= 1 && str[index] <=
                  8) || (str[index] >= 11 && str[index] <= 12) ||
                  (str[index] >= 14 && str[index] <= 31) || (str[index] ==
                  127))) {
                  ++indexTemp3; break;
                }
                if (index < endIndex && ((str[index] >= 93 && str[index] <=
                  126) || (str[index] >= 42 && str[index] <= 91) ||
                  (str[index] >= 33 && str[index] <= 39))) {
                  ++indexTemp3; break;
                }
              } while (false);
              if (indexTemp3 != index) {
                index = indexTemp3;
              } else {
                index = indexStart2; break;
              }
            } while (false);
            if (index == indexStart2) {
              break;
            }
            indexTemp2 = index;
            index = indexStart2;
          } while (false);
          if (indexTemp2 != index) {
            index = indexTemp2;
          } else if (tokener != null) {
            tokener.RestoreState(state2); break;
          } else {
            break;
          }
        }
        index = HeaderParser.ParseFWS(str, index, endIndex, null);
        if (index < endIndex && str[index] == 41) {
          // End of current comment
          ++index;
          if (depth == 0) {
            if (tokener != null) {
              tokener.Commit(TokenComment, indexStart, index);
            }
            return index;
          }
          --depth;
        } else if (index < endIndex && str[index] == 40) {
          // Start of nested comment
          ++index;
          ++depth;
        } else {
          if (tokener != null) {
            tokener.RestoreState(state);
          }
          return indexStart;
        }
      } while (true);
    }
Beispiel #3
0
    public static int ParsePhraseAtom(
string str,
int index,
int endIndex,
ITokener tokener) {
      int i, indexStart, indexTemp, indexTemp2, indexTemp3, state;
      indexStart = index;
      state = (tokener != null) ? tokener.GetState() : 0;
      indexTemp = index;
      do {
        for (i = 0; true; ++i) {
          indexTemp2 = index;
          do {
            if (index < endIndex && ((str[index] >= 65 && str[index] <=
              90) || (str[index] >= 97 && str[index] <= 122))) {
              ++indexTemp2; break;
            }
            if (index < endIndex && ((str[index] >= 48 && str[index] <= 57) ||
              (str[index] == 33) || (str[index] == 35) || (str[index] ==
              36) || (str[index] == 37) || (str[index] == 38) || (str[index]
              == 39) || (str[index] == 42) || (str[index] == 43) ||
              (str[index] == 45) || (str[index] == 47) || (str[index] == 61) ||
              (str[index] == 63) || (str[index] == 94) || (str[index] ==
              95) || (str[index] == 96) || (str[index] == 123) ||
              (str[index] == 124) || (str[index] == 125) || (str[index] ==
              126))) {
              ++indexTemp2; break;
            }
            indexTemp3 = index;
            do {
              if (index < endIndex && ((str[index] >= 128 && str[index] <=
                55295) || (str[index] >= 57344 && str[index] <= 65535))) {
                ++indexTemp3; break;
              }
              if (index + 1 < endIndex && ((str[index] >= 55296 &&
                str[index] <= 56319) && (str[index + 1] >= 56320 &&
                str[index + 1] <= 57343))) {
                indexTemp3 += 2; break;
              }
            } while (false);
            if (indexTemp3 != index) {
              indexTemp2 = indexTemp3; break;
            }
          } while (false);
          if (indexTemp2 != index) {
            index = indexTemp2;
          } else {
            if (i < 1) {
              index = indexStart;
            }
            break;
          }
        }
        if (index == indexStart) {
          break;
        }
        indexTemp = index;
      } while (false);
      if (tokener != null) {
        if (indexTemp == indexStart) {
 tokener.RestoreState(state);
} else {
 tokener.Commit(3, indexStart, indexTemp);
}
      }
      return indexTemp;
    }
Beispiel #4
0
    public static int ParsePhraseAtomOrDot(
string str,
int index,
int endIndex,
ITokener tokener) {
      int i, indexStart, indexTemp, indexTemp2, state;
      indexStart = index;
      state = (tokener != null) ? tokener.GetState() : 0;
      indexTemp = index;
      do {
        indexTemp2 = index;
        for (i = 0; true; ++i) {
          indexTemp2 = ParseAtext(str, index, endIndex, tokener);
          if (indexTemp2 == index) {
            if (i < 1) {
              indexTemp = indexStart;
            }
            break;
          } else {
 index = indexTemp2;
}
        }
        index = indexStart;
        if (indexTemp2 != indexStart) {
          indexTemp = indexTemp2; break;
        }
        if (index < endIndex && (str[index] == 46)) {
          ++indexTemp; break;
        }
      } while (false);
      if (tokener != null) {
        if (indexTemp == indexStart) {
 tokener.RestoreState(state);
} else {
 tokener.Commit(4, indexStart, indexTemp);
}
      }
      return indexTemp;
    }
Beispiel #5
0
    public static int ParsePhrase(
string str,
int index,
int endIndex,
ITokener tokener) {
      int indexStart, indexTemp, indexTemp2, state, tx2;
      indexStart = index;
      state = (tokener != null) ? tokener.GetState() : 0;
      indexTemp = index;
      do {
        tx2 = ParsePhraseWord(str, index, endIndex, tokener);
        if (tx2 == index) {
          break;
        } else {
          index = tx2;
        }
        while (true) {
          indexTemp2 = ParsePhraseWordOrDot(str, index, endIndex, tokener);
          if (indexTemp2 != index) {
            index = indexTemp2;
          } else {
 break;
}
        }
        indexTemp = index;
      } while (false);
      if (tokener != null) {
        if (indexTemp == indexStart) {
 tokener.RestoreState(state);
} else {
 tokener.Commit(1, indexStart, indexTemp);
}
      }
      return indexTemp;
    }
Beispiel #6
0
    public static int ParseMailbox(
string str,
int index,
int endIndex,
ITokener tokener) {
      int indexStart, indexTemp, indexTemp2, state;
      indexStart = index;
      state = (tokener != null) ? tokener.GetState() : 0;
      indexTemp = index;
      do {
        indexTemp2 = ParseNameAddr(str, index, endIndex, tokener);
        if (indexTemp2 != index) {
          indexTemp = indexTemp2; break;
        }
        indexTemp2 = ParseAddrSpec(str, index, endIndex, tokener);
        if (indexTemp2 != index) {
          indexTemp = indexTemp2; break;
        }
      } while (false);
      if (tokener != null) {
        if (indexTemp == indexStart) {
 tokener.RestoreState(state);
} else {
 tokener.Commit(6, indexStart, indexTemp);
}
      }
      return indexTemp;
    }
Beispiel #7
0
    public static int ParseLocalPart(
string str,
int index,
int endIndex,
ITokener tokener) {
   int indexStart, indexStart2, indexTemp, indexTemp2, state, state2, tx2,
        tx3;
      indexStart = index;
      state = (tokener != null) ? tokener.GetState() : 0;
      indexTemp = index;
      do {
        tx2 = ParseWord(str, index, endIndex, tokener);
        if (tx2 == index) {
          break;
        } else {
          index = tx2;
        }
        while (true) {
          state2 = (tokener != null) ? tokener.GetState() : 0;
          indexTemp2 = index;
          do {
            indexStart2 = index;
            if (index < endIndex && (str[index] == 46)) {
              ++index;
            } else {
              break;
            }
            tx3 = ParseWord(str, index, endIndex, tokener);
            if (tx3 == index) {
              index = indexStart2; break;
            } else {
              index = tx3;
            }
            indexTemp2 = index;
            index = indexStart2;
          } while (false);
          if (indexTemp2 != index) {
            index = indexTemp2;
          } else if (tokener != null) {
            tokener.RestoreState(state2); break;
          } else {
 break;
}
        }
        indexTemp = index;
      } while (false);
      if (tokener != null) {
        if (indexTemp == indexStart) {
 tokener.RestoreState(state);
} else {
 tokener.Commit(8, indexStart, indexTemp);
}
      }
      return indexTemp;
    }
Beispiel #8
0
    public static int ParseGroup(
string str,
int index,
int endIndex,
ITokener tokener) {
      int indexStart, indexTemp, state, tx2;
      indexStart = index;
      state = (tokener != null) ? tokener.GetState() : 0;
      indexTemp = index;
      do {
        tx2 = ParseDisplayName(str, index, endIndex, tokener);
        if (tx2 == index) {
          break;
        } else {
          index = tx2;
        }
        if (index < endIndex && (str[index] == 58)) {
          ++index;
        } else {
          index = indexStart; break;
        }
        index = ParseGroupList(str, index, endIndex, tokener);
        if (index < endIndex && (str[index] == 59)) {
          ++index;
        } else {
          index = indexStart; break;
        }
        index = ParseCFWS(str, index, endIndex, tokener);
        indexTemp = index;
      } while (false);
      if (tokener != null) {
        if (indexTemp == indexStart) {
 tokener.RestoreState(state);
} else {
 tokener.Commit(5, indexStart, indexTemp);
}
      }
      return indexTemp;
    }
Beispiel #9
0
    public static int ParseDomain(
string str,
int index,
int endIndex,
ITokener tokener) {
      int indexStart, indexStart2, indexStart3, indexTemp, indexTemp2,
        indexTemp3, state, state2, state3, tx3, tx4;
      indexStart = index;
      state = (tokener != null) ? tokener.GetState() : 0;
      indexTemp = index;
      do {
        indexTemp2 = ParseDomainLiteral(str, index, endIndex, tokener);
        if (indexTemp2 != index) {
          indexTemp = indexTemp2; break;
        }
        state2 = (tokener != null) ? tokener.GetState() : 0;
        indexTemp2 = index;
        do {
          indexStart2 = index;
          tx3 = ParseAtom(str, index, endIndex, tokener);
          if (tx3 == index) {
            break;
          } else {
            index = tx3;
          }
          while (true) {
            state3 = (tokener != null) ? tokener.GetState() : 0;
            indexTemp3 = index;
            do {
              indexStart3 = index;
              if (index < endIndex && (str[index] == 46)) {
                ++index;
              } else {
                break;
              }
              tx4 = ParseAtom(str, index, endIndex, tokener);
              if (tx4 == index) {
                index = indexStart3; break;
              } else {
                index = tx4;
              }
              indexTemp3 = index;
              index = indexStart3;
            } while (false);
            if (indexTemp3 != index) {
              index = indexTemp3;
            } else if (tokener != null) {
              tokener.RestoreState(state3); break;
            } else {
 break;
}
          }
          indexTemp2 = index;
          index = indexStart2;
        } while (false);
        if (indexTemp2 != index) {
          indexTemp = indexTemp2; break;
        }
        if (tokener != null) {
 tokener.RestoreState(state2);
}
      } while (false);
      if (tokener != null) {
        if (indexTemp == indexStart) {
 tokener.RestoreState(state);
} else {
 tokener.Commit(9, indexStart, indexTemp);
}
      }
      return indexTemp;
    }