Пример #1
0
        public static mysToken Evaluate(
			mysSymbol symbol,
			mysToken value,
			Stack<mysSymbolSpace> spaceStack
		)
        {
            // NOTICE THIS
            // since each function has it's own internal space
            // before grabbing our reference to the space in which
            // we want to define our symbol, we need to pop the
            // internal off, or we're going to be defining the symbol
            // in our internal space, i.e. it will scope out as soon as
            // we're done. So we pop the internal off, grab our reference
            // to the space outside of that, then push the internal back on.
            mysSymbolSpace top = spaceStack.Pop();
            mysSymbolSpace ss = spaceStack.Peek();

            if ( value.Type == typeof(mysFunction) ) {
                defineFunction(
                    symbol,
                    value.Value as mysFunction,
                    spaceStack.Peek()
                );
            } else {
                mysSymbolSpace space = symbol.DefinedIn( spaceStack );
                if ( space != null ) {
                    space.Define( symbol, value );
                } else {
                    ss.Define( symbol, value );
                }
            }

            spaceStack.Push( top );
            return null;
        }
Пример #2
0
 void eat( mysToken token )
 {
     Tokens.Add( token.Quote( quote ) );
     quote = false;
     removeCurrent();
 }