Skip to content

Commit

Permalink
Fixed a bug in the tokenizer that limited the parser's ability to par…
Browse files Browse the repository at this point in the history
…se exists statements that are followed by a negated class.
  • Loading branch information
MichaelRoeder committed Nov 8, 2024
1 parent 5344d78 commit df0c429
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/dice_research/cel/expression/parse/CEParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
import org.dice_research.cel.expression.NamedClass;
import org.dice_research.cel.expression.SimpleQuantifiedRole;

/**
*
* <b>WARNING</b>: This parser cannot parse {@code ∃r.A} correctly since the
* tokenizer has no chance to identify the dot as separator of the names (which
* could also be IRIs). Hence, it will be parser as a single role name
* {@code r.A}.
*
* @author Michael R&ouml;der (michael.roeder@uni-paderborn.de)
*
*/
public class CEParser {

public ClassExpression parse(String expressionString) throws CEParserException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ protected boolean newStmtFollows(String substring) {
switch (substring.charAt(0)) {
case '(': // falls through
case ')':
case '¬':
case '∃':
case '∀':
case '⊔':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ public static List<Object[]> parameters() {
testCases.add(new Object[] { new SimpleQuantifiedRole(true, "http://example.org/r", false, NamedClass.TOP) });
testCases.add(new Object[] { new SimpleQuantifiedRole(true, "http://example.org/r", true, NamedClass.TOP) });

// Exists r A
testCases.add(new Object[] { new SimpleQuantifiedRole(true, "r", false, new NamedClass("http://example.org/A", true)) });
testCases.add(new Object[] { new SimpleQuantifiedRole(true, "r", true, new NamedClass("http://example.org/A", true)) });
testCases.add(new Object[] {
new SimpleQuantifiedRole(true, "http://example.org/r", false, new NamedClass("http://example.org/A", true)) });
testCases.add(new Object[] {
new SimpleQuantifiedRole(true, "http://example.org/r", true, new NamedClass("http://example.org/A", true)) });
testCases.add(new Object[] { new SimpleQuantifiedRole(true, "r", false, new NamedClass("http://example.org/A", false)) });
testCases.add(new Object[] { new SimpleQuantifiedRole(true, "r", true, new NamedClass("http://example.org/A", false)) });
testCases.add(new Object[] {
new SimpleQuantifiedRole(true, "http://example.org/r", false, new NamedClass("http://example.org/A", false)) });
testCases.add(new Object[] {
new SimpleQuantifiedRole(true, "http://example.org/r", true, new NamedClass("http://example.org/A", false)) });

// Forall r BOTTOM
testCases.add(new Object[] { new SimpleQuantifiedRole(false, "r", false, NamedClass.BOTTOM) });
testCases.add(new Object[] { new SimpleQuantifiedRole(false, "r", true, NamedClass.BOTTOM) });
Expand Down

0 comments on commit df0c429

Please sign in to comment.