/// <summary> /// The root node of the parse tree. /// Jumps to the next node under the root. /// There must be at least one variable node. /// </summary> public void Visit(SelectNode node) { node.next.Accept(this); if (result.Count < 1) { throw new ArgumentException($"{ this.GetType()}, final result is empty or null."); } }
/// <summary> /// Parses a select query part. /// Select is only parsing expressions separated by comma. /// Select -> SELECT (*|(SelectPrintTerm (, SelectPrintTerm)*) /// SelectPrintTerm -> Expression /// </summary> /// <returns> A tree representation of a SELECT query part. </returns> static public SelectNode ParseSelect(ref int position, List <Token> tokens) { SelectNode selectNode = new SelectNode(); // Parsing Select always starts at position 0. if (position > 0 || tokens[position].type != Token.TokenType.Select) { ThrowError("Select parser", "Failed to find SELECT token.", position, tokens); } else { position++; Node node = ParseVarExprForSelect(ref position, tokens); if (node == null) { ThrowError("Select parser", "Expected Select print term.", position, tokens); } selectNode.AddNext(node); } return(selectNode); }
public void Visit(SelectNode node) { throw new NotImplementedException(); }
/// <summary> /// Creates a Select object. /// Parsing is done beforehand because first we need to parse match expression for variable definitions. /// </summary> /// <param name="graph"> A property graph. </param> /// <param name="map"> A variable map. </param> /// <param name="executionHelper"> A select execution helper. </param> /// <param name="selectNode"> A parsed tree of select expression. </param> /// <param name="exprInfo"> A query expression information. </param> public SelectObject(Graph graph, VariableMap map, ISelectExecutionHelper executionHelper, SelectNode selectNode, QueryExpressionInfo exprInfo) { if (executionHelper == null || selectNode == null || exprInfo == null) { throw new ArgumentNullException($"{this.GetType()}, passing null arguments to constructor. "); } this.helper = executionHelper; // Process the parse tree and creates a List of expression to be printed. SelectVisitor visitor = new SelectVisitor(graph.labels, map, exprInfo); selectNode.Accept(visitor); this.rowFormat = visitor.GetResult(); }