forked from i21017/JavaTypeUnify
Fix Constraint Set Grammar. Add Or Constraint Test
This commit is contained in:
parent
2cf39b3b8c
commit
cd017ba665
@ -1,12 +1,12 @@
|
||||
grammar ConstraintSet;
|
||||
|
||||
constraintSet : (constraints | orConstraint | extendsRelation)+;
|
||||
constraintSet : (constraints | orConstraint | extendsRelation | ',')+;
|
||||
|
||||
extendsRelation: IDENTIFIER typeParams? '<' type;
|
||||
typeParams : '<' IDENTIFIER (',' IDENTIFIER)* '>';
|
||||
|
||||
orConstraint : '{' constraints ('|' constraints)* '}';
|
||||
constraints : '{' constraint+ '}' | constraint+;
|
||||
constraints : '{' constraint (','? constraint)* '}' | constraint (','? constraint)*;
|
||||
constraint: subtypeCons | equalsCons;
|
||||
|
||||
subtypeCons : type '<.' type;
|
||||
|
@ -40,6 +40,22 @@ public class UnifyTest {
|
||||
//TODO: Finish Extends Relation parser
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alotOfOrConstraintsTest(){
|
||||
String input =
|
||||
"Vector<X> < List<X>," +
|
||||
"MyPair<X,Y> < Pair<X,X>," +
|
||||
"Pair<X,Y> < Object," +
|
||||
"List<X> < Object," +
|
||||
"Integer < Object, String < Object, " +
|
||||
"{List<Integer> <. _a | List<String> <. _a}{List<_c> <. _b | List<_c> <. _b} {List<Integer> <. _b | List<String> <. _b}"+
|
||||
"{List<Integer> <. _aa | List<String> <. _aa}{List<_c> <. _ba | List<_c> <. _ba} {List<Integer> <. _ba | List<String> <. _ba}"+
|
||||
"{List<Integer> <. _a | List<String> <. _aaa}{List<_c> <. _baa | List<_c> <. _baa} {List<Integer> <. _baa | List<String> <. _baa}";
|
||||
|
||||
System.out.println(ASPGenerator.generateASP(ConstraintParser.parse(input)));
|
||||
System.out.println(ASPGenerator.generateExtendsRelations(ConstraintParser.parseExtendsRelations(input)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matrix(){
|
||||
String input = "java.lang.Boolean < Object," +
|
||||
|
Loading…
Reference in New Issue
Block a user