2using System.Collections.Generic;
45 private static readonly Dictionary<string, IExtensionFunction> functionsPerUri =
new Dictionary<string, IExtensionFunction>(StringComparer.CurrentCultureIgnoreCase);
49 Types.OnInvalidated += (Sender, e) =>
51 lock (functionsPerUri)
53 functionsPerUri.Clear();
58 private readonly
string preamble;
59 private readonly
int preambleLen;
60 private readonly Dictionary<string, string> namespaces =
new Dictionary<string, string>()
62 {
"xsd", XmlSchema.Namespace },
63 {
"rdf", Rdf.Namespace },
64 {
"rdfs", RdfSchema.Namespace },
65 {
"fn",
"http://www.w3.org/2005/xpath-functions#" },
66 {
"sfn",
"http://www.w3.org/ns/sparql#" }
71 private int preamblePos;
72 private System.Uri baseUri =
null;
73 private int blankNodeIndex = 0;
82 this.preamble = Preamble;
83 this.preambleLen = Preamble?.Length ?? 0;
149 bool Distinct =
false;
150 bool Reduced =
false;
153 s = this.PeekNextToken(Parser).ToUpper();
154 if (
string.IsNullOrEmpty(s))
157 while (s !=
"SELECT" && s !=
"ASK" && s !=
"CONSTRUCT")
162 this.NextToken(Parser);
163 this.SkipWhiteSpace(Parser);
164 if (this.preamblePos < this.preambleLen)
171 this.baseUri = this.ParseUri(Parser).
Uri;
176 this.NextToken(Parser);
177 this.SkipWhiteSpace(Parser);
178 if (this.preamblePos < this.preambleLen)
183 s = this.ParseName(Parser);
191 this.namespaces[s] = this.ParseUri(Parser).
Uri.
ToString();
199 if (
string.IsNullOrEmpty(s))
203 List<ScriptNode> Columns =
null;
204 List<ScriptNode> ColumnNames =
null;
205 List<ScriptNode> GroupBy =
null;
206 List<ScriptNode> GroupByNames =
null;
207 List<KeyValuePair<ScriptNode, bool>> OrderBy =
null;
211 List<ScriptNode> From;
212 Dictionary<UriNode, ISemanticCube> NamedGraphs =
null;
218 this.NextToken(Parser);
219 s = this.PeekNextToken(Parser).ToUpper();
220 if (
string.IsNullOrEmpty(s))
226 this.NextToken(Parser);
237 throw Parser.
SyntaxError(
"Expected regular pattern.");
239 Construct = RegularPattern;
241 throw Parser.
SyntaxError(
"Bound variables not permitted in construct statement.");
243 if (!(Construct.
Filter is
null))
244 throw Parser.
SyntaxError(
"Filters not permitted in construct statement.");
252 this.NextToken(Parser);
253 s = this.PeekNextToken(Parser).ToUpper();
254 if (
string.IsNullOrEmpty(s))
260 this.NextToken(Parser);
263 s = this.PeekNextToken(Parser).ToUpper();
267 this.NextToken(Parser);
270 s = this.PeekNextToken(Parser).ToUpper();
276 this.NextToken(Parser);
277 s = this.PeekNextToken(Parser).ToUpper();
284 Columns =
new List<ScriptNode>();
285 ColumnNames =
new List<ScriptNode>();
287 while (!
string.IsNullOrEmpty(s) && s !=
"WHERE" && s !=
"FROM" && s !=
"{")
289 Node = this.ParseNamedExpression(Parser);
298 ColumnNames.Add(
null);
307 throw Parser.
SyntaxError(
"Expected SELECT or ASK.");
315 From =
new List<ScriptNode>();
325 UriNode FromUri = this.ParseUri(Parser);
332 if (
string.Compare(Parser.
PeekNextToken(),
"NAMED",
true) == 0)
338 FromUri = this.ParseUri(Parser);
340 if (NamedGraphs is
null)
341 NamedGraphs =
new Dictionary<UriNode, ISemanticCube>();
343 NamedGraphs[FromUri] =
null;
360 Where = this.ParsePattern(Parser);
365 Where = this.ParsePattern(Parser);
371 if (this.queryType ==
QueryType.Construct && Construct is
null)
374 Construct = RegularPattern;
376 throw Parser.
SyntaxError(
"CONSTRUCT WHERE queries require a regular WHERE pattern.");
397 if (
string.Compare(Parser.
NextToken(),
"BY",
true) != 0)
400 GroupBy =
new List<ScriptNode>();
401 GroupByNames =
new List<ScriptNode>();
403 while (!
string.IsNullOrEmpty(s) && s !=
"HAVING" && s !=
"ORDER" && s !=
";" && s !=
")" && s !=
"}")
405 Node = this.ParseNamedExpression(Parser);
414 GroupByNames.Add(
null);
423 Having = this.ParseExpression(Parser,
false);
435 throw Parser.
SyntaxError(
"ORDER BY not expected in ASK queries.");
442 OrderBy =
new List<KeyValuePair<ScriptNode, bool>>();
446 Node = this.ParseExpression(Parser,
true);
450 OrderBy.Add(
new KeyValuePair<ScriptNode, bool>(
Asc.
Argument,
true));
452 OrderBy.Add(
new KeyValuePair<ScriptNode, bool>(
Desc.
Argument,
false));
454 OrderBy.Add(
new KeyValuePair<ScriptNode, bool>(Node,
true));
469 Limit = this.ParsePositiveInteger(Parser);
474 Offset = this.ParsePositiveInteger(Parser);
478 Result =
new SparqlQuery(this.queryType, Distinct, Reduced, Columns?.ToArray(),
479 ColumnNames?.ToArray(), From?.ToArray(), NamedGraphs, Where,
480 GroupBy?.ToArray(), GroupByNames?.ToArray(), Having, OrderBy?.ToArray(),
492 if (this.preamblePos < this.preambleLen)
493 return this.preamble[this.preamblePos];
500 if (this.preamblePos < this.preambleLen)
501 return this.preamble[this.preamblePos++];
508 char ch = this.PeekNextChar(Parser);
510 while (ch != 0 && (ch <=
' ' || ch == 160))
512 this.NextChar(Parser);
513 ch = this.PeekNextChar(Parser);
519 this.SkipWhiteSpace(Parser);
521 if (this.preamblePos < this.preambleLen)
523 int Start = this.preamblePos;
524 char ch = this.preamble[this.preamblePos];
526 if (
char.IsLetter(ch))
528 while (this.preamblePos < this.preambleLen &&
char.IsLetterOrDigit(this.preamble[this.preamblePos]))
531 else if (
char.IsDigit(ch))
533 while (this.preamblePos < this.preambleLen &&
char.IsDigit(this.preamble[this.preamblePos]))
536 else if (
char.IsSymbol(ch))
538 while (this.preamblePos < this.preambleLen &&
char.IsSymbol(this.preamble[this.preamblePos]))
544 return this.preamble.Substring(Start, this.preamblePos - Start);
552 this.SkipWhiteSpace(Parser);
554 if (this.preamblePos < this.preambleLen)
556 int Bak = this.preamblePos;
557 string Token = this.NextToken(Parser);
558 this.preamblePos = Bak;
582 this.currentPattern = this.currentRegularPattern;
584 this.ParseTriples(Parser);
591 this.currentRegularPattern = Bak;
592 this.currentPattern = Bak2;
599 this.ParseTriples(Parser,
null);
606 int TriplePosition =
Subject is
null ? 0 : 1;
607 bool InBlankNode = !(
Subject is
null);
611 if (TriplePosition == 0)
618 if (TriplePosition == 0)
629 this.currentPattern = Pattern;
634 this.currentRegularPattern =
null;
665 if (!this.ParsePatternOperator(Parser))
685 Object = this.ParseElement(Parser, TriplePosition);
713 if (this.currentRegularPattern is
null)
716 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
763 if (
char.ToUpper(Parser.
NextChar()) !=
'I' ||
764 char.ToUpper(Parser.
NextChar()) !=
'N' ||
765 char.ToUpper(Parser.
NextChar()) !=
'D')
780 ScriptNode Node = this.ParseNamedExpression(Parser);
784 if (this.currentRegularPattern is
null)
787 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
800 if (
char.ToUpper(Parser.
NextChar()) !=
'I' ||
801 char.ToUpper(Parser.
NextChar()) !=
'L' ||
802 char.ToUpper(Parser.
NextChar()) !=
'T' ||
803 char.ToUpper(Parser.
NextChar()) !=
'E' ||
804 char.ToUpper(Parser.
NextChar()) !=
'R')
816 Node = this.ParseUnary(Parser,
false);
818 if (this.currentRegularPattern is
null)
821 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
824 this.currentRegularPattern.
AddFilter(Node);
841 if (!this.ParsePatternOperator(Parser))
869 this.currentRegularPattern =
null;
876 Left = this.currentPattern;
877 Pattern = this.ParsePattern(Parser);
879 this.currentRegularPattern =
null;
886 Left = this.currentPattern;
887 Pattern = this.ParsePattern(Parser);
889 this.currentRegularPattern =
null;
898 this.currentRegularPattern =
null;
900 if (this.currentPattern.
IsEmpty)
901 this.currentPattern = Values;
908 SparqlParser SubParser =
new SparqlParser(
string.Empty);
910 foreach (KeyValuePair<string, string> P
in this.namespaces)
911 SubParser.namespaces[P.Key] = P.Value;
914 throw Parser.
SyntaxError(
"Unable to parse subquery.");
921 this.currentRegularPattern =
null;
923 if (this.currentPattern.
IsEmpty)
933 ScriptNode Graph = this.ParseExpression(Parser,
false);
934 Pattern = this.ParsePattern(Parser);
938 this.currentRegularPattern =
null;
940 if (this.currentPattern.
IsEmpty)
961 string s = this.ParseName(Parser);
966 List<ISemanticElement> Values =
new List<ISemanticElement>();
994 List<string> Names =
new List<string>();
1001 Names.Add(this.ParseName(Parser));
1014 int i, c = Names.Count;
1016 throw Parser.
SyntaxError(
"Expected variable name.");
1021 List<ISemanticElement[]> Records =
new List<ISemanticElement[]>();
1028 Values =
new List<ISemanticElement>();
1030 for (i = 0; i < c; i++)
1037 Values.Add(Element);
1043 Records.Add(Values.ToArray());
1047 return new ValuesPattern(Names.ToArray(), Records.ToArray());
1061 ScriptNode Node = this.ParseExpression(Parser,
false);
1067 ScriptNode Name = this.ParseExpression(Parser,
false);
1076 return this.ParseOrs(Parser, Optional);
1138 Right = this.ParseTerms(Parser,
false);
1154 Right = this.ParseTerms(Parser,
false);
1159 Right = this.ParseTerms(Parser,
false);
1170 Right = this.ParseTerms(Parser,
false);
1175 Right = this.ParseTerms(Parser,
false);
1182 if (
string.Compare(Parser.
PeekNextToken(),
"IN",
true) == 0)
1185 Right = this.ParseTerms(Parser,
false);
1194 if (
string.Compare(Parser.
PeekNextToken(),
"NOT",
true) == 0)
1196 if (
string.Compare(Parser.
NextToken(),
"IN",
true) != 0)
1199 Right = this.ParseTerms(Parser,
false);
1230 Right = this.ParseFactors(Parser,
false);
1258 Right = this.ParseUnary(Parser,
false);
1279 ScriptNode Node = this.ParseUnary(Parser,
false);
1284 return this.ParseUnary(Parser,
false);
1307 Node = this.ParseUnary(Parser,
false);
1313 Node = this.ParseNamedExpression(Parser);
1321 string s = this.ParseName(Parser);
1342 Element = this.ParseUri(Parser);
1347 Element = this.ParsePrefixedToken(Parser,
string.Empty);
1351 if (!
char.IsLetter(ch))
1363 UriNode Fqn = this.ParsePrefixedToken(Parser, s);
1367 return this.ParseExtensionFunction(Fqn.
Uri.AbsoluteUri, Parser, Start);
1372 return this.ParseFunction(Parser, s, Start, Optional);
1378 switch (s.ToUpper())
1384 ScriptNode Node = this.ParseNamedExpression(Parser);
1388 if (this.currentRegularPattern is
null)
1391 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
1399 return this.ParseUnary(Parser, Optional);
1402 Node = this.ParseUnary(Parser,
false);
1404 if (this.currentRegularPattern is
null)
1407 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
1410 this.currentRegularPattern.
AddFilter(Node);
1412 return this.ParseUnary(Parser, Optional);
1422 ScriptNode[] Arguments = this.ParseArguments(Parser, 1,
int.MaxValue);
1430 Node = this.ParseArgument(Parser);
1434 Node = this.ParseArgument(Parser);
1438 Arguments = this.ParseArguments(Parser, 2, 3);
1439 if (Arguments.
Length == 2)
1451 return new Exists(this.ParsePattern(Parser),
1458 return new NotExists(this.ParsePattern(Parser),
1462 Node = this.ParseArgument(Parser);
1466 Node = this.ParseArgument(Parser);
1470 Node = this.ParseArgument(Parser);
1471 return new Script.Functions.Vectors.Min(Node, Start, Parser.
Position - Start, Parser.
Expression);
1474 Node = this.ParseArgument(Parser);
1475 return new Script.Functions.Vectors.Max(Node, Start, Parser.
Position - Start, Parser.
Expression);
1478 Node = this.ParseArgument(Parser);
1481 case "GROUP_CONCAT":
1482 Node = this.ParseArgumentOptionalScalarVal(Parser,
"separator", out
ScriptNode Node2);
1489 Node = this.ParseArgument(Parser);
1493 Node = this.ParseArgument(Parser);
1494 return new Script.Functions.Scalar.String(Node, Start, Parser.
Position - Start, Parser.
Expression);
1497 Node = this.ParseArgument(Parser);
1501 Node = this.ParseArgument(Parser);
1505 Node = this.ParseArgument(Parser);
1509 Node = this.ParseArgument(Parser);
1513 Node = this.ParseArgument(Parser);
1517 Node = this.ParseArgument(Parser);
1521 Node = this.ParseArgument(Parser);
1525 this.Parse2Arguments(Parser, out Node, out Node2);
1529 this.Parse2Arguments(Parser, out Node, out Node2);
1533 this.Parse2Arguments(Parser, out Node, out Node2);
1537 this.Parse2Arguments(Parser, out Node, out Node2);
1541 this.Parse2Arguments(Parser, out Node, out Node2);
1545 Arguments = this.ParseArguments(Parser, 2, 3);
1546 int NodeStart = Arguments[1].
Start;
1547 int NodeLen = Arguments[1].
Length;
1549 Arguments[1] =
new Subtract(Arguments[1],
1553 if (Arguments.
Length == 2)
1555 return new Mid(Arguments[0], Arguments[1],
null,
1560 return new Mid(Arguments[0], Arguments[1], Arguments[2],
1565 Node = this.ParseArgument(Parser);
1569 Node = this.ParseArgument(Parser);
1573 Node = this.ParseArgument(Parser);
1577 Node = this.ParseArgument(Parser);
1581 Node = this.ParseArgument(Parser);
1585 Node = this.ParseArgument(Parser);
1589 this.Parse0Arguments(Parser);
1593 Node = this.ParseArgument(Parser);
1594 NodeStart = Node.
Start;
1602 Node = this.ParseArgument(Parser);
1603 NodeStart = Node.
Start;
1611 Node = this.ParseArgument(Parser);
1612 NodeStart = Node.
Start;
1620 Node = this.ParseArgument(Parser);
1621 NodeStart = Node.
Start;
1629 Node = this.ParseArgument(Parser);
1630 NodeStart = Node.
Start;
1638 this.Parse0Arguments(Parser);
1641 case "ENCODE_FOR_URI":
1642 Node = this.ParseArgument(Parser);
1646 this.Parse0Arguments(Parser);
1647 NodeLen = Parser.Position - Start;
1649 return new Script.Functions.Scalar.String(
1654 this.Parse0Arguments(Parser);
1655 NodeLen = Parser.Position - Start;
1657 return new Script.Functions.Scalar.Uri(
1660 new Script.Functions.Scalar.String(
1668 Node = this.ParseArgument(Parser);
1669 return new Script.Functions.Scalar.Uri(Node, Start, Parser.
Position - Start, Parser.
Expression);
1672 Arguments = this.ParseArguments(Parser, 3, 3);
1673 return new If(Arguments[0], Arguments[1], Arguments[2],
1677 this.Parse2Arguments(Parser, out Node, out Node2);
1681 Node = this.ParseArgument(Parser);
1682 return new Script.Functions.Runtime.Exists(Node, Start, Parser.
Position - Start, Parser.
Expression);
1686 Node = this.ParseArgument(Parser);
1690 Node = this.ParseArgument(Parser);
1694 Node = this.ParseArgument(Parser);
1698 Node = this.ParseArgument(Parser);
1702 Node = this.ParseArgument(Parser);
1706 Node = this.ParseArgument(Parser);
1710 Arguments = this.ParseArguments(Parser, 0, 1);
1712 if (Arguments.
Length == 0)
1718 this.Parse2Arguments(Parser, out Node, out Node2);
1722 this.Parse2Arguments(Parser, out Node, out Node2);
1726 this.Parse2Arguments(Parser, out Node, out Node2);
1730 Arguments = this.ParseArguments(Parser, 3, 4);
1731 if (Arguments.
Length == 2)
1733 return new Replace(Arguments[0], Arguments[1], Arguments[2],
true,
1738 return new Replace(Arguments[0], Arguments[1], Arguments[2], Arguments[3],
1743 Node = this.ParseArgument(Parser);
1747 Node = this.ParseArgument(Parser);
1751 Arguments = this.ParseArguments(Parser, 1,
int.MaxValue);
1755 Node = this.ParseArgument(Parser);
1756 return new Script.Functions.Runtime.Error(Node, Start, Parser.
Position - Start, Parser.
Expression);
1759 Arguments = this.ParseArguments(Parser, 3, 3);
1763 Node = this.ParseArgument(Parser);
1767 Node = this.ParseArgument(Parser);
1771 Node = this.ParseArgument(Parser);
1775 Node = this.ParseArgument(Parser);
1781 s = this.ParsePrefixedToken(Parser, s).
Uri.AbsoluteUri;
1782 return this.ParseExtensionFunction(s, Parser, Start);
1794 throw Parser.
SyntaxError(
"Unexpected token: " + s);
1802 lock (functionsPerUri)
1804 if (!functionsPerUri.TryGetValue(FullyQualifiedName, out
Function))
1807 functionsPerUri[FullyQualifiedName] =
Function;
1833 ScriptNode Argument = this.ParseExpression(Parser,
false);
1846 Argument1 = this.ParseExpression(Parser,
false);
1851 Argument2 = this.ParseExpression(Parser,
false);
1862 ScriptNode Argument = this.ParseExpression(Parser,
false);
1871 string s = this.ParseName(Parser);
1872 if (s != ExpectedScalarName)
1873 throw Parser.
SyntaxError(
"Expected " + ExpectedScalarName);
1878 ScalarVal = this.ParseExpression(Parser,
false);
1895 List<ScriptNode> Arguments =
new List<ScriptNode>();
1899 Arguments.Add(this.ParseExpression(Parser,
false));
1908 int c = Arguments.Count;
1918 return Arguments.ToArray();
1933 if (TriplePosition == 1)
1934 throw Parser.
SyntaxError(
"Predicate cannot be a blank node.");
1936 BlankNode Node = this.CreateBlankNode();
1937 this.ParseTriples(Parser, Node);
1941 return this.ParseCollection(Parser);
1951 return this.ParseUri(Parser);
1954 if (TriplePosition != 2)
1955 throw Parser.
SyntaxError(
"Literals can only occur in object position.");
1962 s = this.ParseString(Parser,
'"',
true,
true);
1965 s = this.ParseString(Parser,
'"',
false,
true);
1967 string Language =
null;
1972 Language = this.ParseName(Parser);
1983 else if (!
string.IsNullOrEmpty(Language))
1989 return this.ParsePrefixedToken(Parser,
string.Empty);
1994 s = this.ParseName(Parser);
1998 if (
char.IsWhiteSpace(ch))
2006 return new BlankNode(this.ParseName(Parser));
2008 else if (
char.IsLetter(ch) || ch ==
':')
2012 s = this.ParseName(Parser);
2017 return this.ParsePrefixedToken(Parser, s);
2023 if (TriplePosition == 1)
2028 if (TriplePosition == 2)
2033 if (TriplePosition == 2)
2038 if (
string.Compare(s,
"UNDEF",
true) == 0)
2040 if (TriplePosition != 2)
2050 if (TriplePosition == 0)
2063 if (TriplePosition != 2)
2064 throw Parser.
SyntaxError(
"Literals can only occur in object position.");
2067 return this.ParseNumber(Parser);
2080 LinkedList<ISemanticElement> Elements =
null;
2090 if (Elements is
null)
2093 LinkedListNode<ISemanticElement> Loop = Elements.First;
2094 BlankNode Result = this.CreateBlankNode();
2097 if (this.currentRegularPattern is
null)
2100 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
2103 while (!(Loop is
null))
2109 if (!(Loop is
null))
2111 BlankNode Next = this.CreateBlankNode();
2123 if (Element is
null)
2126 if (Elements is
null)
2127 Elements =
new LinkedList<ISemanticElement>();
2129 Elements.AddLast(Element);
2139 throw Parser.
SyntaxError(
"Expected URI or prefixed token.");
2144 return this.ParseUri(Parser);
2147 string Prefix = this.ParseName(Parser);
2152 return this.ParsePrefixedToken(Parser, Prefix);
2157 if (!this.namespaces.TryGetValue(Prefix, out
string Namespace))
2162 string LocalName = this.ParseName(Parser);
2164 return new UriNode(
new System.Uri(
Namespace + LocalName), Prefix +
":" + LocalName);
2170 return string.Empty;
2193 throw Parser.
SyntaxError(
"Expected non-negative integer.");
2202 bool HasDigits =
false;
2203 bool HasDecimal =
false;
2204 bool HasExponent =
false;
2206 if (ch ==
'+' || ch ==
'-')
2212 while (
char.IsDigit(ch))
2225 while (
char.IsDigit(ch))
2232 if (ch ==
'e' || ch ==
'E')
2238 if (ch ==
'+' || ch ==
'-')
2244 while (
char.IsDigit(ch))
2260 throw Parser.
SyntaxError(
"Invalid double number.");
2262 else if (HasDecimal)
2267 throw Parser.
SyntaxError(
"Invalid decimal number.");
2271 if (BigInteger.TryParse(s, out BigInteger bi))
2274 throw Parser.
SyntaxError(
"Invalid integer number.");
2278 throw Parser.
SyntaxError(
"Expected value element.");
2281 private string ParseString(
ScriptParser Parser,
char EndChar,
bool MultiLine,
bool IncludeWhiteSpace)
2283 StringBuilder sb =
null;
2306 else if (ch ==
'\\')
2310 sb =
new StringBuilder();
2319 throw Parser.
SyntaxError(
"Expected escape code.");
2350 if (Parser.
HasCharacters(4) &&
int.TryParse(Parser.
PeekNextChars(4), System.Globalization.NumberStyles.HexNumber,
null, out
int i))
2356 throw Parser.
SyntaxError(
"Expected 4-character hexadecimal code.");
2360 if (Parser.
HasCharacters(8) &&
int.TryParse(Parser.
PeekNextChars(8), System.Globalization.NumberStyles.HexNumber,
null, out i))
2366 throw Parser.
SyntaxError(
"Expected 8-character hexadecimal code.");
2374 else if (IncludeWhiteSpace || !
char.IsWhiteSpace(ch))
2378 throw Parser.
SyntaxError(
"Expected " +
new string(EndChar, MultiLine ? 3 : 1));
2383 string Short = this.ParseString(Parser,
'>',
false,
false);
2385 if (this.baseUri is
null)
2387 if (System.Uri.TryCreate(Short, UriKind.RelativeOrAbsolute, out System.Uri URI))
2388 return new UriNode(URI, Short);
2394 if (
string.IsNullOrEmpty(Short))
2395 return new UriNode(this.baseUri, Short);
2396 else if (System.Uri.TryCreate(
this.baseUri, Short, out System.Uri URI))
2397 return new UriNode(URI, Short);
Helps with parsing of commong data types.
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Coalesce(Expression, ...)
LangMatches(Language,Pattern)
Triple(Subject,Predicate,Object)
Represents a bool literal.
Represents a decimal literal.
Represents a double literal.
Represents an integer literal of undefined size.
Represents a string literal.
Represents an undefined literal.
Set of semantic elements.
static ISemanticElement Parse(string Value, string DataType, string Language)
Parses a string literal value.
Abstract base class for semantic literal values.
Contains semantic information stored in an RDF document.
static UriNode RdfType
rdf:type predicate
static UriNode RdfNil
Predefined reference to end of collection.
static UriNode RdfRest
Predefined reference to next element in a collection.
static UriNode RdfFirst
Predefined reference to first element in a collection.
Contains semantic information stored in a turtle document. https://www.w3.org/TR/rdf12-turtle/ https:...
static bool IsNameChar(char ch)
Checks if a character can be included in a name.
static bool IsNameStartChar(char ch)
Checks if a character is a character that can start a name.
Static class that dynamically manages types and interfaces available in the runtime environment.
string Script
Original script string.
Concatenates the elements of a vector, optionally delimiting the elements with a Delimiter.
EndsWith(String,Substring)
StartsWith(String,Substring)
ScriptNode RightOperand
Right operand.
ScriptNode LeftOperand
Left operand.
Represents a constant element value.
Base class for all funcions.
ScriptNode Argument
Function argument.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
override string ToString()
int Start
Start position in script expression.
Script parser, for custom parsers.
SyntaxException SyntaxError(string Message)
Returns a Syntax Error Exception object.
string PeekNextToken()
Returns the next token to be parsed, without moving the position forward. If at the end of the expres...
bool HasCharacters(int NrCharacters)
If there are a given number of characters left to parse.
bool IsNextChars(string Token)
If the next characters to be parsed is a given token.
string NextToken()
Returns the next token to be parsed, and moves the position forward correspondingly....
int Start
Start position in expression
int Position
Current parsing position.
bool InScript
If position is in script.
Expression Expression
Expression being parsed.
void UndoChar()
Undoes a character in the parsing of an expression.
string PeekNextChars(int NrChars)
Returns the next given number of characters to be parsed, without moving the position forward one cha...
void SkipChars(int NrChars)
Skips a predefined number of characters.
char PeekNextChar()
Returns the next character to be parsed, without moving the position forward one character....
bool EndOfScript
If position is at end of script.
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....
ScriptNode ParseObject()
Parses an object ex nihilo.
char NextNonWhitespaceChar()
Returns the next non-whitespace character to be parsed, and moves the position forward accordingly....
Represents a variable reference.
static readonly BooleanValue False
Constant false value.
static readonly BooleanValue True
Constant true value.
Greater Than Or Equal To.
Checks if a pattern has at least a match.
Extension of the Like operator, that allows the script to set options.
Checks if a pattern has at least no matches.
Orders in ascending order
Orders in descending order
Parses a SPARQL statement
SparqlParser(string Preamble)
Parses a SPARQL statement
bool TryParse(ScriptParser Parser, int Start, out ScriptNode Result)
Tries to parse a script node.
string[] InternalKeywords
Any keywords used internally by the custom parser.
static readonly SparqlParser RefInstance
Reference instance of SPARQL parser.
string[] Aliases
Keyword aliases, if available, null if none.
string KeyWord
Keyword associated with custom parser.
bool TryParse(ScriptParser Parser, out ScriptNode Result)
Tries to parse a script node.
Complement of a pattern (right) in another (left).
A pattern referencing a named source.
Intersection of two patterns.
Represents a pattern in a SPARQL query.
void AddFilter(ScriptNode Filter)
Adds a filter to the pattern.
void AddTriple(SemanticQueryTriple Triple)
Adds a triple to the pattern
void AddVariableBinding(ScriptNode Value, ScriptNode Variable)
Adds a variable binding to the pattern.
IEnumerable< IFilterNode > Filter
Filter, null if none.
IEnumerable< KeyValuePair< ScriptNode, ScriptNode > > BoundVariables
Bound variables, null if none.
A collection of predefined values
Semantic element based on script.
Interface for semantic nodes.
Interface for keywords with custom parsing.
Interface for extension functions
Interface for SPARQL patterns.
bool IsEmpty
If pattern is empty.
delegate string ToString(IElement Element)
Delegate for callback methods that convert an element value to a string.
QueryType
SPARQL query type.
Prefix
SI prefixes. http://physics.nist.gov/cuu/Units/prefixes.html