private static void ProcessIndex(TokenList tokens, NodeStack nodes) { nodes.Add(new ArrayIndexNode()); var childNode = BuildTree(tokens); nodes.Add(childNode); }
private static void ProcessExpression(TokenList tokens, NodeStack nodes) { var childNode = BuildTree(tokens); childNode.KickPrecedenceUp(); nodes.Add(childNode); }
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()); }