Ejemplo n.º 1
0
        public Variable GetField(Interpreter interpreter, bool isPrivate)
        {
            interpreter.Eat();

            string varName = interpreter.Eat("IDENTIFIER").ToString();

            Variable variable = new Variable();

            variable.name = varName;

            MinceObject value;

            if (interpreter.currentToken.type == "EQUALS")
            {
                interpreter.Eat();

                value = interpreter.evaluation.Evaluate();
            }
            else
            {
                value = new MinceNull();
            }

            variable.SetValue(value);
            variable.isPrivate = isPrivate;

            interpreter.Eat("SEMICOLON");

            return(variable);
        }
Ejemplo n.º 2
0
        public MinceObject EvaluateBlock(int?startDepth = null)
        {
            startDepth = startDepth == null ? depth - 1 : startDepth;

            MinceObject result = new MinceNull();

            while (depth > startDepth)
            {
                if (currentToken.type == "EOF")
                {
                    break;
                }

                var r = EvaluateOnce();

                if (result.GetType() == typeof(MinceNull) && r.GetType() != typeof(MinceNull))
                {
                    result = r;
                }
            }

            return(result);
        }