@Test public void shouldRaiseErrorWhenPatternHasNonTerminalDefaultCase() { exception.expect(PatternReductionException.class); exception.expect(is(new PatternReductionException("Non-terminal default pattern case", NULL_SOURCE))); Value pattern = matcher("scotch.test.max", t(1), asList(arg("#0", t(2)), arg("#1", t(3))), pattern( "scotch.test.(max#0)", asList(capture(arg("#0", t(10)), "a", t(4)), capture(arg("#1", t(12)), "b", t(5))), id("a", t(6)) ), pattern( "scotch.test.(max#1)", asList(capture(arg("#0", t(10)), "a", t(4)), capture(arg("#1", t(12)), "b", t(5))), id("b", t(7)) ) ); SymbolGenerator generator = new DefaultSymbolGenerator(); pattern.reducePatterns(new DefaultPatternReducer(generator)); }
private PatternState pattern() { return patterns.peek(); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); @Override void addAssignment(CaptureMatch capture); @Override void addCondition(Value argument, Value value); @Override void addCondition(IsConstructor constructor); @Override void addTaggedArgument(Value taggedArgument); @Override void beginPattern(PatternMatcher matcher); @Override void beginPatternCase(PatternCase patternCase); @Override void endPattern(); @Override void endPatternCase(); @Override Value getTaggedArgument(Value argument); @Override void markFunction(FunctionValue function); @Override Value reducePattern(); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); @Override void addAssignment(CaptureMatch capture); @Override void addCondition(Value argument, Value value); @Override void addCondition(IsConstructor constructor); @Override void addTaggedArgument(Value taggedArgument); @Override void beginPattern(PatternMatcher matcher); @Override void beginPatternCase(PatternCase patternCase); @Override void endPattern(); @Override void endPatternCase(); @Override Value getTaggedArgument(Value argument); @Override void markFunction(FunctionValue function); @Override Value reducePattern();  }