internal CalculatorImpl(CommandProvider commandProvider) { _commands = commandProvider; _tokenizer = new Tokenizer(GetAllOperators(_commands)); _scope = new Scope(); //scope lives with this instance _opStack = new Stack<OpSlot>(); _valueStack = new Stack<ValueSlot>(); _tokenBuffer = new TokenBufferItem[2]; //need to look 2 ahead to decide type of operator (e.g. prefix or suffix) _commands.loadConstants(_scope); }
private static String[] GetAllOperators(CommandProvider commandProvider) { return commandProvider.GetOperators().Concat(new[] { ":=", "(", ")", "," }).OrderByDescending(x => x.Length).ToArray(); }
public CalculatorFactory(CommandConfigurer commandConfigurer) { commandProvider = new CommandProvider(commandConfigurer); }