private IOperationCollection pushGenericBinaryLeftToRightOperation(Scope scope, Func <Scope, IOperationCollection> nextLevel, Dictionary <TokenType, Func <long, IOperationCollection> > operationConverters) { // left-to-right IOperationCollection operations = new OperationCollection(); // Get allowed operations TokenType[] allOperationTokens = operationConverters.Keys.ToArray(); // Push first value operations.Append(nextLevel(scope)); while (_iterator.Is(allOperationTokens)) { var operation = _iterator.Current.Type; var position = _iterator.Position; _iterator.Next(); // Push next value ... operations.Append(nextLevel(scope)); // ... and the operation operations.Append(operationConverters[operation](position)); } return(operations); }
/// <summary> /// Reads a namespace path (tokens separated by '::') from the tokenizer. /// </summary> /// <returns>a list containing the several parts of the path.</returns> private List <string> ReadNamespacePath() { List <string> ns = new List <string>(); // Read namespace name if (!_iterator.Is(TokenType.Name)) { throw new SyntaxException(_iterator.Position, "Expected namespace name"); } ns.Add(_iterator.GetValue <string>()); _iterator.Next(); // And potential parent namespaces while (_iterator.Is(TokenType.DoubleColon)) { _iterator.Next(); if (!_iterator.Is(TokenType.Name)) { throw new SyntaxException(_iterator.Position, "Expected namespace name"); } ns.Add(_iterator.GetValue <string>()); _iterator.Next(); } return(ns); }