/*
 * JaamSim Discrete Event Simulation
 * Copyright (C) 2014 Ausenco Engineering Canada Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
package com.jaamsim.input;

import com.jaamsim.basicsim.Entity;
import com.jaamsim.input.ExpParser.Expression;
import com.jaamsim.ui.LogBox;

public class ExpressionInput extends Input<ExpParser.Expression> {
	private Entity thisEnt;

	public ExpressionInput(String key, String cat, ExpParser.Expression def) {
		super(key, cat, def);
	}

	public void setEntity(Entity ent) {
		thisEnt = ent;
	}

	@Override
	public void parse(KeywordIndex kw)
	throws InputErrorException {
		Input.assertCount(kw, 1);
		try {
			Expression exp = ExpParser.parseExpression(ExpEvaluator.getParseContext(), kw.getArg(0));

			// Test whether the expression can be evaluated
			try {
				ExpValidator.validateExpression(exp, thisEnt);
			} catch (ExpError e) {
				throw new InputErrorException(e.toString());
			}

			// Save the expression
			value = exp;

		} catch (ExpError e) {
			LogBox.logException(e);
			throw new InputErrorException(e.toString());
		}
	}

}

@@ -1254,18 +1254,8 @@
 ted%0A
-%09%09%09try %7B%0A%09
 %09%09%09E
@@ -1303,88 +1303,8 @@
 nt);
-%0A%09%09%09%7D catch (ExpError e) %7B%0A%09%09%09%09throw new InputErrorException(e.toString());%0A%09%09%09%7D
 %0A%0A%09%09

Remove useless double try in expression parsing