a branflakes interpreter i used to play with c++
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

40 lines
842 B

#pragma once
#include <exception>
enum class ErrType {
Success,
BracketMismatch,
NoInput,
Something
};
class ParseExcept: public std::exception {
public:
ErrType err;
ParseExcept(ErrType e) {
err = e;
}
virtual const char* what() const throw() {
switch(err) {
case ErrType::Success:
return "This should not appear."; // successes should be handled
break;
case ErrType::BracketMismatch:
return "Mismatched bracket";
break;
case ErrType::NoInput:
return "No input given";
break;
case ErrType::Something:
return "Something happened";
break;
default:
break; // this should never happen
}
return "a"; // NOT REACHED
}
};