private static Node BuildTree(TokenList tokens) { var nodes = new NodeStack(); while (tokens.Any() && !(tokens.Current.EndsExpressionOrParameters || tokens.Current.IsParameterSeparator || tokens.Current.EndsIndex)) { if (tokens.Current.StartsExpressionOrParameters && nodes.LastAdded is MethodNode method) { tokens.MoveNext(); ProcessParameters(tokens, method); } else if (tokens.Current.StartsExpressionOrParameters) { tokens.MoveNext(); ProcessExpression(tokens, nodes); } else if (tokens.Current.StartsIndex) { tokens.MoveNext(); ProcessIndex(tokens, nodes); } else { nodes.Add(tokens.Current.CreateNode()); } tokens.MoveNext(); } return(nodes.Pop()); }