Skip to content
Snippets Groups Projects
Commit 259a1b17 authored by Katja Goltsova's avatar Katja Goltsova Committed by Viktor Kunčak
Browse files

Throw an exception when printing fails

parent 5315d53f
Branches
No related tags found
4 merge requests!62Easy tactics,!58Easy tactics,!54Front integration,!53Front integration
......@@ -12,6 +12,7 @@ object Parser {
class ParserException(msg: String) extends Exception(msg)
object UnreachableException extends ParserException("Internal error: expected unreachable")
class PrintFailedException(inp: Sequent | Formula | Term) extends ParserException(s"Printing of $inp failed unexpectedly")
def parseSequent(s: String): Sequent =
extractParseResult(SequentParser.parseSequent(SequentLexer(s.iterator)))
......@@ -30,11 +31,11 @@ object Parser {
case SequentParser.UnexpectedEnd(_) => throw ParserException(s"Unexpected end of input")
}
def printSequent(s: Sequent): String = SequentParser.printSequent(s).get
def printSequent(s: Sequent): String = SequentParser.printSequent(s).getOrElse(throw PrintFailedException(s))
def printFormula(f: Formula): String = SequentParser.printFormula(f).get
def printFormula(f: Formula): String = SequentParser.printFormula(f).getOrElse(throw PrintFailedException(f))
def printTerm(t: Term): String = SequentParser.printTerm(t).get
def printTerm(t: Term): String = SequentParser.printTerm(t).getOrElse(throw PrintFailedException(t))
private[Parser] object SequentLexer extends Lexers with CharLexers {
sealed abstract class FormulaToken(stringRepr: String) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment