@Test public void should_catch_StackOverflowError() { when(machine.length()).thenReturn(1); when(machine.charAt(0)).thenThrow(StackOverflowError.class); thrown.expect(GrammarException.class); thrown.expectMessage("The regular expression 'foo|bar' has led to a stack overflow error." + " This error is certainly due to an inefficient use of alternations. See http: expression.execute(machine); }
@Override public void execute(Machine machine) { matcher.reset(machine); boolean result; try { result = matcher.lookingAt(); } catch (StackOverflowError e) { throw new GrammarException(e, "The regular expression '" + matcher.pattern().pattern() + "' has led to a stack overflow error." + " This error is certainly due to an inefficient use of alternations. See http: } if (result) { machine.createLeafNode(this, matcher.end()); machine.jump(1); } else { machine.backtrack(); } matcher.reset(""); }
PatternExpression extends NativeExpression implements org.sonar.sslr.internal.matchers.Matcher { @Override public void execute(Machine machine) { matcher.reset(machine); boolean result; try { result = matcher.lookingAt(); } catch (StackOverflowError e) { throw new GrammarException(e, "The regular expression '" + matcher.pattern().pattern() + "' has led to a stack overflow error." + " This error is certainly due to an inefficient use of alternations. See http: } if (result) { machine.createLeafNode(this, matcher.end()); machine.jump(1); } else { machine.backtrack(); } matcher.reset(""); } }
PatternExpression extends NativeExpression implements org.sonar.sslr.internal.matchers.Matcher { @Override public void execute(Machine machine) { matcher.reset(machine); boolean result; try { result = matcher.lookingAt(); } catch (StackOverflowError e) { throw new GrammarException(e, "The regular expression '" + matcher.pattern().pattern() + "' has led to a stack overflow error." + " This error is certainly due to an inefficient use of alternations. See http: } if (result) { machine.createLeafNode(this, matcher.end()); machine.jump(1); } else { machine.backtrack(); } matcher.reset(""); } PatternExpression(String regex); }
PatternExpression extends NativeExpression implements org.sonar.sslr.internal.matchers.Matcher { @Override public void execute(Machine machine) { matcher.reset(machine); boolean result; try { result = matcher.lookingAt(); } catch (StackOverflowError e) { throw new GrammarException(e, "The regular expression '" + matcher.pattern().pattern() + "' has led to a stack overflow error." + " This error is certainly due to an inefficient use of alternations. See http: } if (result) { machine.createLeafNode(this, matcher.end()); machine.jump(1); } else { machine.backtrack(); } matcher.reset(""); } PatternExpression(String regex); @Override void execute(Machine machine); @Override String toString(); }
PatternExpression extends NativeExpression implements org.sonar.sslr.internal.matchers.Matcher { @Override public void execute(Machine machine) { matcher.reset(machine); boolean result; try { result = matcher.lookingAt(); } catch (StackOverflowError e) { throw new GrammarException(e, "The regular expression '" + matcher.pattern().pattern() + "' has led to a stack overflow error." + " This error is certainly due to an inefficient use of alternations. See http: } if (result) { machine.createLeafNode(this, matcher.end()); machine.jump(1); } else { machine.backtrack(); } matcher.reset(""); } PatternExpression(String regex); @Override void execute(Machine machine); @Override String toString();  }