1
0

Fix Parser. Add Numbers for Identifiers

This commit is contained in:
Andreas Stadelmeier 2024-07-01 12:37:27 +02:00
parent af0dad2b09
commit 3c0f0dcf55
4 changed files with 30 additions and 2 deletions

View File

@ -17,7 +17,7 @@ tph : '_' IDENTIFIER;
namedType : IDENTIFIER params?;
params : '<' type (',' type)* '>';
IDENTIFIER: [A-Za-z.]+;
IDENTIFIER: [0-9A-Za-z.]+;
NEWLINE : [\r\n]+ -> skip;
WS: [ \t] -> skip ;

View File

@ -6,6 +6,6 @@ tph : 'tph("_' IDENTIFIER '")';
type : 'type("' IDENTIFIER '",' params ')';
params : 'null' | 'params(' type (',' type)* ')';
IDENTIFIER: [A-Za-z.]+;
IDENTIFIER: [0-9A-Za-z.]+;
NEWLINE : [\r\n]+ -> skip;
WS: [ \t] -> skip ;

View File

@ -21,4 +21,13 @@ public class SolutionParserTest {
System.out.println(key + " -> " + sigmas.get(key));
}
}
@Test
public void parseSolution(){
String solution ="sigma(tph(\"_O\"),type(\"C1\",null)) sigma(tph(\"_W\"),type(\"C2\",null)) sigma(tph(\"_AM\"),type(\"C1\",null)) sigma(tph(\"_BA\"),type(\"C1\",null)) sigma(tph(\"_AW\"),type(\"C1\",null)) sigma(tph(\"_AO\"),type(\"C1\",null)) sigma(tph(\"_AK\"),type(\"C1\",null)) sigma(tph(\"_AI\"),type(\"C1\",null)) sigma(tph(\"_AQ\"),type(\"C1\",null)) sigma(tph(\"_AY\"),type(\"C1\",null)) sigma(tph(\"_AE\"),type(\"C1\",null)) sigma(tph(\"_BC\"),type(\"C1\",null)) sigma(tph(\"_AU\"),type(\"C1\",null)) sigma(tph(\"_AS\"),type(\"C1\",null)) sigma(tph(\"_V\"),type(\"java.lang.Object\",null)) sigma(tph(\"_N\"),type(\"C1\",null)) sigma(tph(\"_AG\"),type(\"C1\",null)) sigma(tph(\"_AD\"),type(\"C1\",null))\n";
Map<String,String> sigmas = SolutionParser.parse(solution);
for(var key : sigmas.keySet()){
System.out.println(key + " -> " + sigmas.get(key));
}
}
}

View File

@ -3,6 +3,9 @@ import de.dhbwstuttgart.sat.asp.*;
import org.apache.commons.io.output.NullWriter;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashSet;
@ -40,6 +43,22 @@ public class UnifyTest {
//TODO: Finish Extends Relation parser
}
@Test
public void orConsTest() throws IOException {
String input =
"java.lang.Boolean < java.lang.Object," +
"java.lang.String < java.lang.Object," +
"java.lang.Integer < java.lang.Object," +
"OrConsTest < java.lang.Object," +
"MyPair<X,Y> < Pair<X,X>," +
"Pair<X,Y> < Object," +
"List<X> < Object," +
"Integer < Object, String < Object, " +
Files.readString(Paths.get("/","tmp","output"));
System.out.println(ASPGenerator.generateASP(ConstraintParser.parse(input)));
System.out.println(ASPGenerator.generateExtendsRelations(ConstraintParser.parseExtendsRelations(input)));
}
@Test
public void alotOfOrConstraintsTest(){
String input =