1
0

Fix Constraint Set Grammar. Add Or Constraint Test

This commit is contained in:
JanUlrich 2024-06-23 00:45:49 +02:00
parent 2cf39b3b8c
commit cd017ba665
2 changed files with 18 additions and 2 deletions

View File

@ -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;

View File

@ -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," +