public static double readReal(ParsingContext context, RealValidator validator, String value)
     throws DirectiveException {
   try {
     int currentPos = (int) context.getCurrentOffset();
     double realValue = Double.parseDouble(value);
     if (validator != null) {
       DirectiveError error = validator.validateReal(realValue);
       if (error != null) {
         error.setPosition(currentPos);
         throw error.asException();
       }
     }
     return realValue;
   } catch (NumberFormatException e) {
     throw DirectiveError.asException(Error.INTEGER_EXPECTED, (int) context.getCurrentOffset());
   }
 }
 public static int readInt(ParsingContext context, IntegerValidator validator, String value)
     throws DirectiveException {
   try {
     int currentPos = (int) context.getCurrentOffset();
     int intValue = Integer.parseInt(value);
     if (validator != null) {
       DirectiveError error = validator.validateInteger(intValue);
       if (error != null) {
         error.setPosition(currentPos);
         throw error.asException();
       }
     }
     return intValue;
   } catch (NumberFormatException e) {
     throw DirectiveError.asException(Error.INTEGER_EXPECTED, (int) context.getCurrentOffset());
   }
 }