예제 #1
0
        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);
        }
예제 #2
0
 private static String[] GetAllOperators(CommandProvider commandProvider)
 {
     return commandProvider.GetOperators().Concat(new[] { ":=", "(", ")", "," }).OrderByDescending(x => x.Length).ToArray();
 }
예제 #3
0
 public CalculatorFactory(CommandConfigurer commandConfigurer)
 {
     commandProvider = new CommandProvider(commandConfigurer);
 }