-
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.
Add new checks from the most recent version of Griddle develop.
- Loading branch information
1 parent
948bb56
commit 69742f9
Showing
5 changed files
with
92 additions
and
0 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
24 changes: 24 additions & 0 deletions
24
src/main/java/net/alloyggp/griddle/validator/check/EmptyDisjunctionCheck.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,24 @@ | ||
package net.alloyggp.griddle.validator.check; | ||
|
||
import net.alloyggp.griddle.grammar.GdlVisitor; | ||
import net.alloyggp.griddle.grammar.Literal; | ||
import net.alloyggp.griddle.validator.AnalyzedGame; | ||
|
||
public class EmptyDisjunctionCheck implements Check { | ||
public static final EmptyDisjunctionCheck INSTANCE = new EmptyDisjunctionCheck(); | ||
private EmptyDisjunctionCheck() { | ||
//Singleton | ||
} | ||
|
||
@Override | ||
public void findProblems(AnalyzedGame game, final ProblemReporter reporter) { | ||
game.visitAll(new GdlVisitor() { | ||
@Override | ||
public void visitDisjunction(Literal disjunction) { | ||
if (disjunction.getDisjunction().isEmpty()) { | ||
reporter.report("Disjunctions should not be empty.", disjunction.getPosition()); | ||
} | ||
} | ||
}); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/net/alloyggp/griddle/validator/check/VariablesOnlyInRulesCheck.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 net.alloyggp.griddle.validator.check; | ||
|
||
import net.alloyggp.griddle.Position; | ||
import net.alloyggp.griddle.grammar.GdlVisitor; | ||
import net.alloyggp.griddle.grammar.Sentence; | ||
import net.alloyggp.griddle.grammar.TopLevelGdl; | ||
import net.alloyggp.griddle.validator.AnalyzedGame; | ||
|
||
public class VariablesOnlyInRulesCheck implements Check { | ||
public static final VariablesOnlyInRulesCheck INSTANCE = new VariablesOnlyInRulesCheck(); | ||
private VariablesOnlyInRulesCheck() { | ||
//Singleton | ||
} | ||
|
||
@Override | ||
public void findProblems(AnalyzedGame game, final ProblemReporter reporter) { | ||
for (TopLevelGdl gdl : game.getTopLevelComponents()) { | ||
if (gdl.isSentence()) { | ||
Sentence sentence = gdl.getSentence(); | ||
sentence.accept(new GdlVisitor() { | ||
@Override | ||
public void visitVariable(String variable, Position position) { | ||
reporter.report("Variables may only appear within rules.", position); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
|
||
} |
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