public Expression Visit(ParserVariable variable) { if (variable.Type is ParserNumType) { return(new NumVariable(variable.VariableName)); } if (variable.Type is ParserLogicType) { return(new LogicVariable(variable.VariableName)); } if (variable.Type is ParserLambdaType) { return(new LambdaVariable(variable.VariableName)); } if (variable.Type is ParserProdType) { return(new PairVariable(variable.VariableName)); } throw new ArgumentException("Unknown variable type"); }
public ParserType Visit(ParserVariable variable) { ParserType output; try { output = Context[variable.VariableName]; } catch (KeyNotFoundException) { // If the variable is not found in the context we will throw our own exception throw new ArgumentException("Variable not found in context. Name: " + variable.VariableName); } if (output == null) { throw new ArgumentException("Variable Not Found in Context: " + variable.VariableName); } variable.Type = output; return(output); }