/// <summary> /// Initializes a new instance of the <see cref="Executor"/> class. /// </summary> /// <param name="teletype">Teletype to use for input output.</param> /// <param name="runEnvironment">Run time environment.</param> /// <param name="programRepository">Program repository.</param> /// <param name="tokensProvider">Provider of tokens.</param> /// <param name="tokeniser">Tokeniser to pass to ITokeniserCommands.</param> public Executor( ITeletype teletype, IRunEnvironment runEnvironment, IProgramRepository programRepository, ITokensProvider tokensProvider, ITokeniser tokeniser) { _runEnvironment = runEnvironment; _programRepository = programRepository; _tokeniser = tokeniser; _letToken = tokensProvider.Tokens.Find(t => t.Statement == TokenType.Let); teletype.CancelEventHandler += InterruptExecution; }
public ConsoleBASICInterpreter() { BASICRunEnvironment = new RunEnvironment(); BASICProgramRepository = new ProgramRepository(); BASICVariableRepository = new VariableRepository(); BASICDataStatement = new DataStatementReader(BASICRunEnvironment, BASICProgramRepository); BASICExpresionEval = new ExpressionEvaluator(BASICVariableRepository, BASICRunEnvironment); BASICTokensProvider = new TokensProvider(new IToken[] { new ClassicBasic.Interpreter.Commands.Clear(BASICRunEnvironment, BASICVariableRepository, BASICDataStatement), new ClassicBasic.Interpreter.Commands.Cont(BASICRunEnvironment, BASICProgramRepository), new ClassicBasic.Interpreter.Commands.Data(BASICRunEnvironment), new ClassicBasic.Interpreter.Commands.Def(BASICRunEnvironment, BASICExpresionEval), new ClassicBasic.Interpreter.Commands.Del(BASICRunEnvironment, BASICProgramRepository), new ClassicBasic.Interpreter.Commands.Dim(BASICRunEnvironment, BASICExpresionEval, BASICVariableRepository), new ClassicBasic.Interpreter.Commands.Dim(BASICRunEnvironment, BASICExpresionEval, BASICVariableRepository), new ClassicBasic.Interpreter.Commands.Edit(BASICRunEnvironment, BASICProgramRepository, this), new ClassicBasic.Interpreter.Commands.Else(BASICRunEnvironment), new ClassicBasic.Interpreter.Commands.End(BASICRunEnvironment), new ClassicBasic.Interpreter.Commands.For(BASICRunEnvironment, BASICExpresionEval, BASICVariableRepository), //new ClassicBasic.Interpreter.Commands.Get(BASICRunEnvironment,BASICExpresionEval,this), new ClassicBasic.Interpreter.Commands.Gosub(BASICRunEnvironment, BASICProgramRepository), new ClassicBasic.Interpreter.Commands.Goto(BASICRunEnvironment, BASICExpresionEval, BASICProgramRepository), new ClassicBasic.Interpreter.Commands.If(BASICRunEnvironment, BASICExpresionEval, BASICProgramRepository), //new ClassicBasic.Interpreter.Commands.Input(BASICRunEnvironment,BASICExpresionEval,BASICVariableRepository, this), new ClassicBasic.Interpreter.Commands.Let(BASICRunEnvironment, BASICExpresionEval), new ClassicBasic.Interpreter.Commands.List(BASICProgramRepository, this, BASICRunEnvironment), //new ClassicBasic.Interpreter.Commands.Load(BASICRunEnvironment,BASICProgramRepository), new ClassicBasic.Interpreter.Commands.New(BASICRunEnvironment, BASICProgramRepository, BASICVariableRepository, BASICDataStatement), new ClassicBasic.Interpreter.Commands.Next(BASICRunEnvironment, BASICVariableRepository), new ClassicBasic.Interpreter.Commands.On(BASICRunEnvironment, BASICExpresionEval, BASICProgramRepository), new ClassicBasic.Interpreter.Commands.OnErr(BASICRunEnvironment), new ClassicBasic.Interpreter.Commands.Pop(BASICRunEnvironment), new ClassicBasic.Interpreter.Commands.Print(BASICRunEnvironment, BASICExpresionEval, this), new ClassicBasic.Interpreter.Commands.Read(BASICRunEnvironment, BASICExpresionEval, BASICDataStatement), new ClassicBasic.Interpreter.Commands.Remark(BASICRunEnvironment), new ClassicBasic.Interpreter.Commands.Restore(BASICRunEnvironment, BASICDataStatement), new ClassicBasic.Interpreter.Commands.Resume(BASICRunEnvironment, BASICProgramRepository), new ClassicBasic.Interpreter.Commands.Return(BASICRunEnvironment), new ClassicBasic.Interpreter.Commands.Run(BASICRunEnvironment, BASICProgramRepository, BASICVariableRepository, BASICDataStatement), //new ClassicBasic.Interpreter.Commands.Save(BASICRunEnvironment,BASICProgramRepository), new ClassicBasic.Interpreter.Commands.Stop(BASICRunEnvironment), }); BASICTokeniser = new Tokeniser(BASICTokensProvider); BASICExecutor = new ExecutorFrameBased(this, BASICRunEnvironment, BASICProgramRepository, BASICTokensProvider, BASICTokeniser); }
/// <summary> /// Initializes a new instance of the <see cref="Tokeniser"/> class. /// </summary> /// <param name="tokensProvider">Token provider with a list of tokens.</param> public Tokeniser(ITokensProvider tokensProvider) { _tokensProvider = tokensProvider; }