Пример #1
0
 @Subroutine(value = "string-match")
 public static LispObject stringMatch(
     Environment environment, LispString regexp, LispString string, @Optional LispInteger start) {
   int from = 0;
   if (start != null) {
     from = start.getData();
     if (from < 0 || from >= string.size())
       throw new ArgumentOutOfRange(string.toString(), start.toString());
   }
   LispSymbol s = environment.find("case-fold-search");
   int r =
       string.match(
           environment, regexp, from, (s != null && !s.getValue().equals(LispSymbol.ourNil)));
   if (r == -1) return LispSymbol.ourNil;
   return new LispInteger(r);
 }
Пример #2
0
 private static int processBound(LispInteger bound, int length) {
   return bound.getData() < 0 ? length + bound.getData() : bound.getData();
 }