@Test void subFunctionIdentifiers() { final List<ReferenceEqualityToken> rule0x = new ArrayList<>(); final List<ReferenceEqualityToken> rule1x = new ArrayList<>(); final List<ReferenceEqualityToken> rule1y = new ArrayList<>(); final List<ReferenceEqualityToken> rule2x = new ArrayList<>(); final List<ReferenceEqualityToken> rule3x = new ArrayList<>(); final List<Token> tokens = Arrays.asList( new Token(REDUCTION, "reduction", 0), new Token(IDENTIFIER, "test1", 0), new Token(COLON, ":", 0), new Token(PLUS, "+", 0), addIdentifierToken(rule0x, "x"), new Token(ARROW, "->", 0), addIdentifierToken(rule0x, "x"), new Token(EXPANSION, "expansion", 0), new Token(IDENTIFIER, "test2", 0), new Token(COLON, ":", 0), addIdentifierToken(rule1x, "x"), new Token(POWER, "^", 0), new Token(MINUS, "-", 0), addIdentifierToken(rule1y, "y"), new Token(ARROW, "->", 0), new Token(NUMBER, "1", 0), new Token(DIVIDE, "/", 0), addIdentifierToken(rule1x, "x"), new Token(POWER, "^", 0), addIdentifierToken(rule1y, "y"), new Token(CALCULATION, "expansion", 0), new Token(IDENTIFIER, "test2", 0), new Token(COLON, ":", 0), addIdentifierToken(rule2x, "x"), new Token(ARROW, "->", 0), addIdentifierToken(rule2x, "x"), new Token(PLUS, "+", 0), new Token(NUMBER, "0", 0), new Token(CALCULATION, "expansion", 0), new Token(IDENTIFIER, "test2", 0), new Token(COLON, ":", 0), addIdentifierToken(rule3x, "x"), new Token(ARROW, "->", 0), addIdentifierToken(rule3x, "x"), new Token(PLUS, "+", 0), new Token(NUMBER, "0", 0), new Token(EOF, "", 0) ); final Parser parser = new Parser(tokens, errors::add); final List<PatternRule> rules = parser.parse(); assertEquals(rule0x, getSubFunctionIdentifiers(parser, rules.get(0), "x")); assertEquals(rule1x, getSubFunctionIdentifiers(parser, rules.get(1), "x")); assertEquals(rule1y, getSubFunctionIdentifiers(parser, rules.get(1), "y")); assertEquals(rule2x, getSubFunctionIdentifiers(parser, rules.get(2), "x")); assertEquals(rule3x, getSubFunctionIdentifiers(parser, rules.get(3), "x")); }
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);  }