コード例 #1
0
    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();
    }
コード例 #2
0
    private double GetDoubleValue(TerminalNodeImpl t)
    {
        if (t.Symbol.Type == VARIABLE)
        {
            return(Convert.ToDouble(ENVIRONMENT[t.ToString()]));
        }

        return(double.Parse(t.GetText()));
    }
コード例 #3
0
    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();
    }