1using System.Collections.Generic;
71 List<ScriptNode> Columns;
72 List<ScriptNode> ColumnNames;
75 bool Distinct =
false;
79 if (
string.IsNullOrEmpty(s))
82 while (s ==
"TOP" || s ==
"DISTINCT" || s ==
"GENERIC")
88 Top = Parser.ParseNoWhiteSpace();
103 if (
string.IsNullOrEmpty(s))
113 if (Top is
null && !Generic)
131 if (!(Top is
null) || Generic)
145 Columns =
new List<ScriptNode>();
146 ColumnNames =
new List<ScriptNode>();
153 if (s ==
"/" || s ==
"." || s ==
"@")
154 Node = ParseXPath(Parser,
true);
157 Node = Parser.ParseNoWhiteSpace();
160 XPath.ExtractValue =
true;
167 if (!
string.IsNullOrEmpty(s) && s !=
"," && s !=
"FROM")
172 Name = Parser.ParseNoWhiteSpace();
181 ColumnNames.Add(Name);
206 if (s ==
"/" || s ==
"." || s ==
"@")
207 Where = ParseXPath(Parser,
false);
214 List<ScriptNode> GroupBy =
null;
215 List<ScriptNode> GroupByNames =
null;
221 if (
string.Compare(Parser.
NextToken(),
"BY",
true) != 0)
224 GroupBy =
new List<ScriptNode>();
225 GroupByNames =
new List<ScriptNode>();
235 if (!
string.IsNullOrEmpty(s) && s !=
"," && s !=
";" && s !=
")" && s !=
"]" && s !=
"}" && s !=
"HAVING" && s !=
"ORDER" && s !=
"OFFSET")
240 Name = Parser.ParseNoWhiteSpace();
255 GroupByNames.Add(Name);
270 else if (!(Columns is
null))
272 bool ImplicitGrouping =
false;
276 if (this.ContainsVectorFunction(Column))
278 ImplicitGrouping =
true;
283 if (ImplicitGrouping)
285 GroupBy =
new List<ScriptNode>();
286 GroupByNames =
new List<ScriptNode>();
290 List<KeyValuePair<ScriptNode, bool>> OrderBy =
null;
295 if (
string.Compare(Parser.
NextToken(),
"BY",
true) != 0)
298 OrderBy =
new List<KeyValuePair<ScriptNode, bool>>();
308 OrderBy.Add(
new KeyValuePair<ScriptNode, bool>(Node,
true));
311 else if (s ==
"DESC")
314 OrderBy.Add(
new KeyValuePair<ScriptNode, bool>(Node,
false));
318 OrderBy.Add(
new KeyValuePair<ScriptNode, bool>(Node,
true));
332 Offset = Parser.ParseNoWhiteSpace();
335 Result =
new Select(Columns?.ToArray(), ColumnNames?.ToArray(), Source, Where, GroupBy?.ToArray(),
336 GroupByNames?.ToArray(), Having, OrderBy?.ToArray(), Top, Offset, Distinct, Generic,
346 StringBuilder sb =
new StringBuilder();
350 while ((ch = Parser.
PeekNextChar()) > 32 && ch != 160 && ch !=
',' && ch !=
';')
358 if (!TryParseSource(Parser, out Source))
381 if (
string.Compare(Parser.
NextToken(),
"JOIN",
true) != 0)
385 if (!TryParseSource(Parser, out Source2))
388 ScriptNode Conditions = ParseJoinConditions(Parser);
401 if (
string.Compare(Parser.
NextToken(),
"JOIN",
true) != 0)
409 if (!TryParseSource(Parser, out Source2))
412 Conditions = ParseJoinConditions(Parser);
425 if (
string.Compare(Parser.
NextToken(),
"JOIN",
true) != 0)
433 if (!TryParseSource(Parser, out Source2))
436 Conditions = ParseJoinConditions(Parser);
449 if (
string.Compare(Parser.
NextToken(),
"JOIN",
true) != 0)
457 if (!TryParseSource(Parser, out Source2))
460 Conditions = ParseJoinConditions(Parser);
467 if (
string.Compare(Parser.
NextToken(),
"JOIN",
true) != 0)
470 if (!TryParseSource(Parser, out Source2))
473 Conditions = ParseJoinConditions(Parser);
505 if (!
string.IsNullOrEmpty(s) &&
530 Name = Parser.ParseNoWhiteSpace();
540 internal static bool IsAlias(
string s)
542 foreach (
char ch
in s)
544 if (!
char.IsLetterOrDigit(ch) && ch !=
'_')
551 private bool ContainsVectorFunction(
ScriptNode Node)
553 if (!this.SearchForVectorFunction(Node, out _,
null))
Represents a constant element value.
Base class for all funcions.
Base class for funcions of one vector variable.
Base class for all nodes in a parsed script tree.
bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
Calls the callback method for all child nodes.
int Length
Length of expression covered by node.
Expression Expression
Expression of which the node is a part.
int Start
Start position in script expression.
Script parser, for custom parsers.
string PeekNextToken()
Returns the next token to be parsed, without moving the position forward. If at the end of the expres...
string NextToken()
Returns the next token to be parsed, and moves the position forward correspondingly....
int Length
Length of script parsed
ScriptNode ParseOrs()
Parses ORs.
int Start
Start position in expression
int Position
Current parsing position.
Expression Expression
Expression being parsed.
char PeekNextChar()
Returns the next character to be parsed, without moving the position forward one character....
void SkipWhiteSpace()
If current position is whitespace, moves the current position forward to the first non-whitespace cha...
char NextChar()
Returns the next character to be parsed, and moves the position forward one character....
Represents a variable reference.
string Name
Name of method.
Node repesenting an XPath expression
Parses a SPARQL statement
bool TryParse(ScriptParser Parser, out ScriptNode Result)
Tries to parse a script node.
Parses a SELECT statement
string[] InternalKeywords
Any keywords used internally by the custom parser.
string[] Aliases
Keyword aliases, if available, null if none.
string KeyWord
Keyword associated with custom parser.
SelectParser()
Parses a SELECT statement
bool TryParse(ScriptParser Parser, out ScriptNode Result)
Tries to parse a script node.
Executes a SELECT statement against the object database.
Abstract base class for source definitions
CROSS JOIN of two source definitions.
FULL [OUTER] JOIN of two source definitions.
[INNER] JOIN of two source definitions.
LEFT [OUTER] JOIN of two source definitions.
RIGHT [OUTER] JOIN of two source definitions.
Direct reference to a data source.
Interface for keywords with custom parsing.
SearchMethod
Method to traverse the expression structure