public static object Eval(CsEvaluator evaluator) {
if (CsEval.EvalEnvironment == null)
throw new Exception("CsEval.EvalEnvironment must be set first. " +
"Please refer to http://www.csharp-eval.com/HowTo.php for more information");
try {
object result = evaluator.parser.exp().Value;
return result;
}
catch (Antlr.Runtime.RecognitionException re) {
if (re.Token.Type == CseParser.SEMI)
throw new Exception("Parsing Error At EOL");
else
throw new Exception(String.Format("Parsing Error At \"{0}\"", re.Token.Text));
}
catch (Exception npe) {
throw new Exception("Internal error: " + npe.Message);
}
}