Skip to content
Snippets Groups Projects
Commit 6c999e77 authored by Daniel Plagge's avatar Daniel Plagge
Browse files

inglorious fix: when detecting an EOF in the lexer, throw a runtime exception

  to stop the evaluation loop. 

git-svn-id: https://cobra.cs.uni-duesseldorf.de/prob/trunk/experimental/plagge/probkodkod@7393 7aec93f6-bc54-0410-ac70-7d7c9efa889a
parent bb83281f
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,6 @@ import de.stups.probkodkod.parser.node.Token;
* @author plagge
*/
public class EOFLexer extends Lexer {
public EOFLexer(final PushbackReader in) {
super(in);
}
......@@ -39,10 +38,15 @@ public class EOFLexer extends Lexer {
}
private Token filter(Token token) {
if (token instanceof TFullstop) {
if (token instanceof EOF)
throw new AbortException();
else if (token instanceof TFullstop) {
token = new EOF();
}
return token;
}
public static class AbortException extends RuntimeException {
private static final long serialVersionUID = 4042645224685292559L;
}
}
......@@ -48,11 +48,15 @@ public class KodkodInteraction {
final Lexer lexer = new EOFLexer(in);
final Parser parser = new Parser(lexer);
try {
while (!session.isStopped()) {
final Start tree = parser.parse();
tree.apply(analysis);
pto.flush();
}
} catch (EOFLexer.AbortException e) {
logger.info("EOF reached");
}
logger.info("Kodkod session finished");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment