Example #1
0
    public static string Eval(string input)
    {
        var expression = Expression.Parse(input);
        var state      = new ForthState();

        foreach (var definition in expression)
        {
            definition.Evaluate(state);
        }

        return(state.ToString());
    }
Example #2
0
    public static string Evaluate(string[] instructions)
    {
        var state = new ForthState();

        foreach (var instruction in instructions)
        {
            var expression = Expression.Parse(instruction);

            foreach (var definition in expression)
            {
                definition.Evaluate(state);
            }
        }

        return(state.ToString());
    }