UserErrorPrinter { public static String print(UserError error) { return error.match(new UserError.MatchBlock<String>() { @Override public String _case(Semantic x) { return print(x.error); } @Override public String _case(Syntactic x) { return print(x.error); } }); }  static String print(UserError error); static String print(SyntaxError error); static String print(SemanticError error);  }
@Test public void test() { assertEquals("Found token 'flurb' but expected 'blurb' at line 13.", print(_Syntactic(_UnexpectedToken("blurb", "flurb", 13)))); assertEquals("Cannot have two datatypes named foo in one jADT document.", print(_Semantic(_DuplicateDataType("foo")))); assertEquals("Data type foo cannot have a constructor with the name foo. Only single constructor data types may have constructors with the same name.", print(_Semantic(_ConstructorDataTypeConflict("foo")))); assertEquals("Data type foo cannot have multiple constructors named bar.", print(_Semantic(_DuplicateConstructor("foo", "bar")))); assertEquals("Duplicated arg name baz in constructor bar of data type foo.", print(_Semantic(_DuplicateArgName("foo", "bar", "baz")))); assertEquals("Duplicated modifier quux on arg name baz in constructor bar of data type foo.", print(_Semantic(_DuplicateModifier("foo", "bar", "baz", "quux")))); }