// not sure we need to override? but I'm not chancing public override 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(); // do we need to push our own internal space here? // I mean, maybe? mysSymbolSpace internalSpace = new mysSymbolSpace(); spaceStack.Push( internalSpace ); mysToken result = Function( arguments, state, spaceStack ); spaceStack.Pop(); return result; }
public EvaluationMachine( List<mysToken> tokenList, mysState state, Stack<mysSymbolSpace> spaceStack ) { tokens = new List<mysToken>( tokenList ); this.state = state; this.spaceStack = spaceStack; }
// arg 1 function // arg 2 instance (with . operator) // arg 3+ arguments public List<mysToken> Call( mysToken target, List<mysToken> arguments, mysState state, Stack<mysSymbolSpace> spaceStack ) { object targetObject = null; if ( target.Type != typeof(Type) ) { targetObject = target.Value; } List<object> realArguments = new List<object>(); foreach ( mysToken t in arguments ) { mysToken current = t; while ( current.Type == typeof(mysSymbol) ) { current = (current.Value as mysSymbol) .Value( spaceStack ); } realArguments.Add( current.Value ); } object result = method.Invoke( targetObject, realArguments.ToArray() ); if ( result == null ) { return null; } return new List<mysToken>() { Builtins.Clr.ClrTools.ConvertClrObject( result ) }; }
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; }
public mysREPL() { State = new mysState(); }
bool handleSpecialInput( string expression ) { switch ( expression ) { case "(clear)": Console.Clear(); return true; case "(nuke!)": State = new mysState(); REPLstart(); Console.WriteLine( ">> Cleared execution state, REPL status, "+ "parser status. All to new. <<\n" ); return true; case "(quit)": Quit(); return true; case "(strict)": strict = !strict; Console.WriteLine( "Strict is now {0}.\n", strict ); return true; } return false; }