private object Eval(TerminalNodeImpl arg) { if (arg.Symbol.Type == STRING) { return(arg.ToString()); } if (arg.Symbol.Type == NUMBER) { return(arg.ToString()); } if (arg.Symbol.Type == VARIABLE) { return(ENVIRONMENT[arg.ToString()]); } if (arg.Symbol.Type == BOOL_TRUE) { return(true); } if (arg.Symbol.Type == VARIABLE) { return(false); } throw new ChildLangRuntimeException(); }
private double GetDoubleValue(TerminalNodeImpl t) { if (t.Symbol.Type == VARIABLE) { return(Convert.ToDouble(ENVIRONMENT[t.ToString()])); } return(double.Parse(t.GetText())); }
private string GetTerminalString(TerminalNodeImpl t) { if (t.Symbol.Type == VARIABLE) { return(ENVIRONMENT[t.ToString()].ToString()); } if (t.Symbol.Type == NUMBER) { return(t.GetText()); } throw new ChildLangRuntimeException(); }