private IOperationCollection pushGenericBinaryRightToLeftOperation(Scope scope, Func <Scope, IOperationCollection> nextLevel, Dictionary <TokenType, Func <long, IOperationCollection> > operationConverters) { // right-to-left IOperationCollection operations = new OperationCollection(); // Get allowed operations TokenType[] allOperationTokens = operationConverters.Keys.ToArray(); // Store first value var value = nextLevel(scope); // Check if there is an operation while (_iterator.Is(allOperationTokens)) { // Push operation operations.Prepend(operationConverters[_iterator.Current.Type](_iterator.Position)); _iterator.Next(); // Push value operations.Prepend(value); // Read next value value = nextLevel(scope); } // Push last value operations.Prepend(value); return(operations); }
private IOperationCollection pushGenericUnaryRightToLeftOperation(Scope scope, Func <Scope, IOperationCollection> nextLevel, Dictionary <TokenType, Func <long, IOperationCollection> > operationConverters) { // right-to-left IOperationCollection operations = new OperationCollection(); // Get allowed operations TokenType[] allOperationTokens = operationConverters.Keys.ToArray(); // Push first value while (_iterator.Is(allOperationTokens)) { // Push the operation operations.Prepend(operationConverters[_iterator.Current.Type](_iterator.Position)); _iterator.Next(); } // Push value itself operations.Prepend(nextLevel(scope)); return(operations); }