You must override the reportError methods in lexer and parser. You can do this by adding this code to the lexer file:
@Override
public void reportError(RecognitionException e) {
throw new RuntimeException(e);
}
, , :
public static boolean matches(String input) {
try {
regExLexer lexer = new regExLexer(new ANTLRStringStream(input));
regExParser parser = new regExParser(new CommonTokenStream(lexer));
parser.goal();
return true;
} catch (RuntimeException e) {
return false;
}
catch (Exception e) {
return false;
}
catch (OutOfMemoryError e) {
return false;
}
}
@Override
public void reportError(RecognitionException e) {
throw new RuntimeException(e);
}
Parser.matches(input); , . , true, false, , false, .