示例#1
0
        public virtual mysToken Call(
			List<mysToken> arguments,
			mysState state,
			Stack<mysSymbolSpace> spaceStack
		)
        {
            arguments = arguments.Select( t =>
                t.Type == typeof(mysSymbol) && !t.Quoted
                ? ( t.Value as mysSymbol ).Value( spaceStack )
                : t
            ).ToList();

            // future, cache somehow?
            mysSymbolSpace internalSpace = new mysSymbolSpace();

            Symbols.DoPaired(
                arguments,
                (s, a) => internalSpace.Define( s, a )
            );

            spaceStack.Push( internalSpace );

            EvaluationMachine em = new EvaluationMachine(
                Function,
                state,
                spaceStack
            );
            mysToken result = em.Evaluate();

            spaceStack.Pop();

            return result;
        }
示例#2
0
        void EvaluateLists()
        {
            // while any list
            // eval list
            while ( true && tokens.Count > 0 ) {

                mysToken list = tokens.FirstOrDefault( t =>
                    t.Type == typeof(List<mysToken>) &&
                    !t.Quoted
                );

                if ( list == null ) {
                    break;
                }

                int index = tokens.IndexOf( list );
                tokens.Remove( list );

                EvaluationMachine em = new EvaluationMachine(
                    (List<mysToken>)list.Value,
                    state,
                    spaceStack
                );

                mysToken result = em.Evaluate();

                if ( result != null ) {
                    tokens.Insert(
                        index,
                        result
                    );
                }
            }
        }