@Test void multipleParseCalls() { final List<Token> tokens = Collections.singletonList( new Token(EOF, "", 0) ); final Parser parser = new Parser(tokens, errors::add); parser.parse(); assertThrows(IllegalStateException.class, parser::parse); }
public List<PatternRule> parse() { if (used) { throw new IllegalStateException("Parser.parse can only be called once per instance"); } used = true; return rules(); }
Parser { public List<PatternRule> parse() { if (used) { throw new IllegalStateException("Parser.parse can only be called once per instance"); } used = true; return rules(); } }
Parser { public List<PatternRule> parse() { if (used) { throw new IllegalStateException("Parser.parse can only be called once per instance"); } used = true; return rules(); } Parser(final List<Token> tokens, final Consumer<? super DslError> errorReporter); }
Parser { public List<PatternRule> parse() { if (used) { throw new IllegalStateException("Parser.parse can only be called once per instance"); } used = true; return rules(); } Parser(final List<Token> tokens, final Consumer<? super DslError> errorReporter); List<PatternRule> parse(); Token getSubFunctionIdentifier(final SubFunctionPattern subFunction); }
Parser { public List<PatternRule> parse() { if (used) { throw new IllegalStateException("Parser.parse can only be called once per instance"); } used = true; return rules(); } Parser(final List<Token> tokens, final Consumer<? super DslError> errorReporter); List<PatternRule> parse(); Token getSubFunctionIdentifier(final SubFunctionPattern subFunction);  }