@Test void lexerError() { final var exception = assertThrows(DslAggregateException.class, () -> RulesDsl.makeRules("reduction test: 2. 5 -> 1") ); final var expectedErrors = Collections.singletonList( new IncompleteNumberLiteral(16, "2.") ); assertEquals(expectedErrors, exception.getErrors()); }
public static List<Rule> makeRules(final String source) throws DslAggregateException { final List<DslError> errors = new ArrayList<>(); final Lexer lexer = new Lexer(source, errors::add); final Parser parser = new Parser(lexer.lex(), errors::add); final List<PatternRule> rules = parser.parse(); for (final PatternRule rule : rules) { undefinedSubFunctions(rule) .map(subFunc -> new UndefinedSubFunction( parser.getSubFunctionIdentifier(subFunc) )) .forEach(errors::add); } if (!errors.isEmpty()) { throw new DslAggregateException(errors); } return Collections.unmodifiableList(rules); }
RulesDsl { public static List<Rule> makeRules(final String source) throws DslAggregateException { final List<DslError> errors = new ArrayList<>(); final Lexer lexer = new Lexer(source, errors::add); final Parser parser = new Parser(lexer.lex(), errors::add); final List<PatternRule> rules = parser.parse(); for (final PatternRule rule : rules) { undefinedSubFunctions(rule) .map(subFunc -> new UndefinedSubFunction( parser.getSubFunctionIdentifier(subFunc) )) .forEach(errors::add); } if (!errors.isEmpty()) { throw new DslAggregateException(errors); } return Collections.unmodifiableList(rules); } }
RulesDsl { public static List<Rule> makeRules(final String source) throws DslAggregateException { final List<DslError> errors = new ArrayList<>(); final Lexer lexer = new Lexer(source, errors::add); final Parser parser = new Parser(lexer.lex(), errors::add); final List<PatternRule> rules = parser.parse(); for (final PatternRule rule : rules) { undefinedSubFunctions(rule) .map(subFunc -> new UndefinedSubFunction( parser.getSubFunctionIdentifier(subFunc) )) .forEach(errors::add); } if (!errors.isEmpty()) { throw new DslAggregateException(errors); } return Collections.unmodifiableList(rules); } private  RulesDsl(); }
RulesDsl { public static List<Rule> makeRules(final String source) throws DslAggregateException { final List<DslError> errors = new ArrayList<>(); final Lexer lexer = new Lexer(source, errors::add); final Parser parser = new Parser(lexer.lex(), errors::add); final List<PatternRule> rules = parser.parse(); for (final PatternRule rule : rules) { undefinedSubFunctions(rule) .map(subFunc -> new UndefinedSubFunction( parser.getSubFunctionIdentifier(subFunc) )) .forEach(errors::add); } if (!errors.isEmpty()) { throw new DslAggregateException(errors); } return Collections.unmodifiableList(rules); } private  RulesDsl(); static List<Rule> makeRules(final String source); }
RulesDsl { public static List<Rule> makeRules(final String source) throws DslAggregateException { final List<DslError> errors = new ArrayList<>(); final Lexer lexer = new Lexer(source, errors::add); final Parser parser = new Parser(lexer.lex(), errors::add); final List<PatternRule> rules = parser.parse(); for (final PatternRule rule : rules) { undefinedSubFunctions(rule) .map(subFunc -> new UndefinedSubFunction( parser.getSubFunctionIdentifier(subFunc) )) .forEach(errors::add); } if (!errors.isEmpty()) { throw new DslAggregateException(errors); } return Collections.unmodifiableList(rules); } private  RulesDsl(); static List<Rule> makeRules(final String source);  }