-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1713a2c
commit 2ec6863
Showing
16 changed files
with
576 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/me/paultristanwagner/modelchecking/ctlstar/formula/CTLStarAndFormula.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package me.paultristanwagner.modelchecking.ctlstar.formula; | ||
|
||
import static me.paultristanwagner.modelchecking.util.Symbol.AND_SYMBOL; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class CTLStarAndFormula extends CTLStarFormula { | ||
|
||
private final List<CTLStarFormula> components; | ||
|
||
private CTLStarAndFormula(List<CTLStarFormula> components) { | ||
this.components = components; | ||
} | ||
|
||
public static CTLStarAndFormula and(List<CTLStarFormula> components) { | ||
return new CTLStarAndFormula(components); | ||
} | ||
|
||
public static CTLStarAndFormula and(CTLStarFormula... components) { | ||
return new CTLStarAndFormula(Arrays.asList(components)); | ||
} | ||
|
||
public List<CTLStarFormula> getComponents() { | ||
return components; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder(); | ||
for (int i = 0; i < components.size(); i++) { | ||
builder.append(components.get(i).toString()); | ||
|
||
if (i < components.size() - 1) { | ||
builder.append(" "); | ||
builder.append(AND_SYMBOL); | ||
builder.append(" "); | ||
} | ||
} | ||
|
||
return builder.toString(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/me/paultristanwagner/modelchecking/ctlstar/formula/CTLStarExistsFormula.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package me.paultristanwagner.modelchecking.ctlstar.formula; | ||
|
||
import static me.paultristanwagner.modelchecking.util.Symbol.EXISTENTIAL_QUANTIFIER_SYMBOL; | ||
|
||
public class CTLStarExistsFormula extends CTLStarFormula { | ||
|
||
private final CTLStarFormula formula; | ||
|
||
private CTLStarExistsFormula(CTLStarFormula formula) { | ||
this.formula = formula; | ||
} | ||
|
||
public static CTLStarExistsFormula exists(CTLStarFormula formula) { | ||
return new CTLStarExistsFormula(formula); | ||
} | ||
|
||
public CTLStarFormula getFormula() { | ||
return formula; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return EXISTENTIAL_QUANTIFIER_SYMBOL + formula; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/me/paultristanwagner/modelchecking/ctlstar/formula/CTLStarFormula.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package me.paultristanwagner.modelchecking.ctlstar.formula; | ||
|
||
public class CTLStarFormula {} |
23 changes: 23 additions & 0 deletions
23
...ain/java/me/paultristanwagner/modelchecking/ctlstar/formula/CTLStarIdentifierFormula.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package me.paultristanwagner.modelchecking.ctlstar.formula; | ||
|
||
public class CTLStarIdentifierFormula extends CTLStarFormula { | ||
|
||
private final String identifier; | ||
|
||
private CTLStarIdentifierFormula(String identifier) { | ||
this.identifier = identifier; | ||
} | ||
|
||
public static CTLStarIdentifierFormula identifier(String identifier) { | ||
return new CTLStarIdentifierFormula(identifier); | ||
} | ||
|
||
public String getIdentifier() { | ||
return identifier; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return identifier; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/me/paultristanwagner/modelchecking/ctlstar/formula/CTLStarNextFormula.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package me.paultristanwagner.modelchecking.ctlstar.formula; | ||
|
||
import static me.paultristanwagner.modelchecking.util.Symbol.NEXT_SYMBOL; | ||
|
||
public class CTLStarNextFormula extends CTLStarFormula { | ||
|
||
private final CTLStarFormula formula; | ||
|
||
private CTLStarNextFormula(CTLStarFormula formula) { | ||
this.formula = formula; | ||
} | ||
|
||
public static CTLStarNextFormula next(CTLStarFormula formula) { | ||
return new CTLStarNextFormula(formula); | ||
} | ||
|
||
public CTLStarFormula getFormula() { | ||
return formula; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return NEXT_SYMBOL + formula; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/me/paultristanwagner/modelchecking/ctlstar/formula/CTLStarNotFormula.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package me.paultristanwagner.modelchecking.ctlstar.formula; | ||
|
||
import static me.paultristanwagner.modelchecking.util.Symbol.NOT_SYMBOL; | ||
|
||
public class CTLStarNotFormula extends CTLStarFormula { | ||
|
||
private final CTLStarFormula formula; | ||
|
||
private CTLStarNotFormula(CTLStarFormula formula) { | ||
this.formula = formula; | ||
} | ||
|
||
public static CTLStarNotFormula not(CTLStarFormula formula) { | ||
return new CTLStarNotFormula(formula); | ||
} | ||
|
||
public CTLStarFormula getFormula() { | ||
return formula; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return NOT_SYMBOL + formula; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...in/java/me/paultristanwagner/modelchecking/ctlstar/formula/CTLStarParenthesisFormula.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package me.paultristanwagner.modelchecking.ctlstar.formula; | ||
|
||
public class CTLStarParenthesisFormula extends CTLStarFormula { | ||
|
||
private final CTLStarFormula formula; | ||
|
||
private CTLStarParenthesisFormula(CTLStarFormula formula) { | ||
this.formula = formula; | ||
} | ||
|
||
public static CTLStarParenthesisFormula parenthesis(CTLStarFormula formula) { | ||
return new CTLStarParenthesisFormula(formula); | ||
} | ||
|
||
public CTLStarFormula getFormula() { | ||
return formula; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "(" + formula + ")"; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/me/paultristanwagner/modelchecking/ctlstar/formula/CTLStarTrueFormula.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package me.paultristanwagner.modelchecking.ctlstar.formula; | ||
|
||
public class CTLStarTrueFormula extends CTLStarFormula { | ||
|
||
private CTLStarTrueFormula() {} | ||
|
||
public static CTLStarTrueFormula TRUE() { | ||
return new CTLStarTrueFormula(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "true"; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/me/paultristanwagner/modelchecking/ctlstar/formula/CTLStarUntilFormula.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package me.paultristanwagner.modelchecking.ctlstar.formula; | ||
|
||
public class CTLStarUntilFormula extends CTLStarFormula { | ||
|
||
private final CTLStarFormula left; | ||
private final CTLStarFormula right; | ||
|
||
private CTLStarUntilFormula(CTLStarFormula left, CTLStarFormula right) { | ||
this.left = left; | ||
this.right = right; | ||
} | ||
|
||
public static CTLStarUntilFormula until(CTLStarFormula left, CTLStarFormula right) { | ||
return new CTLStarUntilFormula(left, right); | ||
} | ||
|
||
public CTLStarFormula getLeft() { | ||
return left; | ||
} | ||
|
||
public CTLStarFormula getRight() { | ||
return right; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
// todo: add brackets, but also possibility to parse them properly | ||
return left + " U " + right; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/me/paultristanwagner/modelchecking/ctlstar/parse/CTLStarLexer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package me.paultristanwagner.modelchecking.ctlstar.parse; | ||
|
||
import static me.paultristanwagner.modelchecking.util.Symbol.*; | ||
|
||
import me.paultristanwagner.modelchecking.parse.Lexer; | ||
import me.paultristanwagner.modelchecking.parse.TokenType; | ||
|
||
public class CTLStarLexer extends Lexer { | ||
|
||
static final TokenType LPAREN = TokenType.of("(", "^\\("); | ||
static final TokenType RPAREN = TokenType.of(")", "^\\)"); | ||
static final TokenType TRUE = TokenType.of("true", "^(true|TRUE)"); | ||
// static final TokenType FALSE = TokenType.of("false", "^(false|FALSE)"); | ||
static final TokenType NOT = TokenType.of("not", "^(" + NOT_SYMBOL + "|!|not|NOT|~)"); | ||
static final TokenType AND = TokenType.of("and", "^(" + AND_SYMBOL + "|&|and|AND)"); | ||
// static final TokenType OR = TokenType.of("or", "^(" + OR_SYMBOL + "|\\||or|OR)"); | ||
static final TokenType NEXT = TokenType.of("next", "^(" + NEXT_SYMBOL + "|next|NEXT|O)"); | ||
static final TokenType UNTIL = TokenType.of("until", "^(" + UNTIL_SYMBOL + "|until|UNTIL)"); | ||
// static final TokenType EVENTUALLY = TokenType.of("eventually", "^(" + EVENTUALLY_SYMBOL + | ||
// "|eventually|EVENTUALLY|diamond|DIAMOND)"); | ||
// static final TokenType ALWAYS = TokenType.of("always", "^(" + ALWAYS_SYMBOL + | ||
// "|always|ALWAYS|box|BOX)"); | ||
// static final TokenType ALL = TokenType.of("all", "^(" + UNIVERSAL_QUANTIFIER_SYMBOL + | ||
// "|all|ALL|A)"); | ||
static final TokenType EXISTS = | ||
TokenType.of("exists", "^(" + EXISTENTIAL_QUANTIFIER_SYMBOL + "|exists|EXISTS|ex|EX|E)"); | ||
static final TokenType IDENTIFIER = TokenType.of("identifier", "^[a-z]"); | ||
|
||
public CTLStarLexer(String input) { | ||
super(input); | ||
|
||
/* registerTokenTypes( | ||
LPAREN, RPAREN, TRUE, FALSE, NOT, AND, OR, | ||
NEXT, UNTIL, EVENTUALLY, ALWAYS, ALL, EXISTS, IDENTIFIER | ||
); */ | ||
|
||
registerTokenTypes(LPAREN, RPAREN, TRUE, NOT, AND, NEXT, UNTIL, EXISTS, IDENTIFIER); | ||
|
||
this.initialize(input); | ||
} | ||
} |
Oops, something went wrong.