46 private static readonly Dictionary<string, IExtensionFunction> functionsPerUri =
new Dictionary<string, IExtensionFunction>(StringComparer.CurrentCultureIgnoreCase);
50 Types.OnInvalidated += (Sender, e) =>
52 lock (functionsPerUri)
54 functionsPerUri.Clear();
59 private readonly
string preamble;
60 private readonly
int preambleLen;
61 private readonly Dictionary<string, string> namespaces =
new Dictionary<string, string>()
63 {
"xsd", XmlSchema.Namespace },
64 {
"rdf", Rdf.Namespace },
65 {
"rdfs", RdfSchema.Namespace },
66 {
"fn",
"http://www.w3.org/2005/xpath-functions#" },
67 {
"sfn",
"http://www.w3.org/ns/sparql#" }
72 private int preamblePos;
73 private System.Uri baseUri =
null;
74 private int blankNodeIndex = 0;
83 this.preamble = Preamble;
84 this.preambleLen = Preamble?.Length ?? 0;
150 bool Distinct =
false;
151 bool Reduced =
false;
154 s = this.PeekNextToken(Parser).ToUpper();
155 if (
string.IsNullOrEmpty(s))
158 while (s !=
"SELECT" && s !=
"ASK" && s !=
"CONSTRUCT")
163 this.NextToken(Parser);
164 this.SkipWhiteSpace(Parser);
165 if (this.preamblePos < this.preambleLen)
172 this.baseUri = this.ParseUri(Parser).
Uri;
177 this.NextToken(Parser);
178 this.SkipWhiteSpace(Parser);
179 if (this.preamblePos < this.preambleLen)
184 s = this.ParseName(Parser);
198 this.namespaces[s] = this.ParseUri(Parser).
Uri.
ToString();
206 if (
string.IsNullOrEmpty(s))
219 Dictionary<UriNode, ISemanticCube> NamedGraphs =
null;
225 this.NextToken(Parser);
226 s = this.PeekNextToken(Parser).ToUpper();
227 if (
string.IsNullOrEmpty(s))
233 this.NextToken(Parser);
244 throw Parser.
SyntaxError(
"Expected regular pattern.");
246 Construct = RegularPattern;
248 throw Parser.
SyntaxError(
"Bound variables not permitted in construct statement.");
250 if (!(Construct.
Filter is
null))
251 throw Parser.
SyntaxError(
"Filters not permitted in construct statement.");
259 this.NextToken(Parser);
260 s = this.PeekNextToken(Parser).ToUpper();
261 if (
string.IsNullOrEmpty(s))
267 this.NextToken(Parser);
270 s = this.PeekNextToken(Parser).ToUpper();
274 this.NextToken(Parser);
277 s = this.PeekNextToken(Parser).ToUpper();
283 this.NextToken(Parser);
284 s = this.PeekNextToken(Parser).ToUpper();
294 while (!
string.IsNullOrEmpty(s) && s !=
"WHERE" && s !=
"FROM" && s !=
"{")
296 Node = this.ParseNamedExpression(Parser);
305 ColumnNames.
Add(
null);
314 throw Parser.
SyntaxError(
"Expected SELECT or ASK.");
333 UriNode FromUri = this.ParseUri(Parser);
340 if (
string.Compare(Parser.
PeekNextToken(),
"NAMED",
true) == 0)
348 FromUri = this.ParseUri(Parser);
357 FromUri = this.ParsePrefixedToken(Parser, Ref3.VariableName);
360 throw Parser.
SyntaxError(
"Aboslute or prefixed URI expected.");
363 if (NamedGraphs is
null)
364 NamedGraphs =
new Dictionary<UriNode, ISemanticCube>();
366 NamedGraphs[FromUri] =
null;
372 this.SkipWhiteSpace(Parser);
376 FromUri = this.ParsePrefixedToken(Parser, Ref2.VariableName);
387 this.SkipWhiteSpace(Parser);
391 FromUri = this.ParsePrefixedToken(Parser, Ref.VariableName);
405 Where = this.ParsePattern(Parser);
410 Where = this.ParsePattern(Parser);
416 if (this.queryType ==
QueryType.Construct && Construct is
null)
419 Construct = RegularPattern;
421 throw Parser.
SyntaxError(
"CONSTRUCT WHERE queries require a regular WHERE pattern.");
429 if (!(AdditionalTriples is
null))
430 throw Parser.
SyntaxError(
"Blank Nodes not supported in a VALUES statement.");
444 if (
string.Compare(Parser.
NextToken(),
"BY",
true) != 0)
450 while (!
string.IsNullOrEmpty(s) && s !=
"HAVING" && s !=
"ORDER" && s !=
";" && s !=
")" && s !=
"}")
452 Node = this.ParseNamedExpression(Parser);
461 GroupByNames.
Add(
null);
470 Having = this.ParseExpression(Parser,
false);
482 throw Parser.
SyntaxError(
"ORDER BY not expected in ASK queries.");
493 Node = this.ParseExpression(Parser,
true);
497 OrderBy.
Add(
new KeyValuePair<ScriptNode, bool>(
Asc.
Argument,
true));
501 OrderBy.
Add(
new KeyValuePair<ScriptNode, bool>(Node,
true));
516 Limit = this.ParsePositiveInteger(Parser);
521 Offset = this.ParsePositiveInteger(Parser);
525 Result =
new SparqlQuery(this.queryType, Distinct, Reduced, Columns?.ToArray(),
526 ColumnNames?.ToArray(), From?.ToArray(), NamedGraphs, Where,
527 GroupBy?.ToArray(), GroupByNames?.ToArray(), Having, OrderBy?.ToArray(),
539 if (this.preamblePos < this.preambleLen)
540 return this.preamble[this.preamblePos];
547 if (this.preamblePos < this.preambleLen)
548 return this.preamble[this.preamblePos++];
555 char ch = this.PeekNextChar(Parser);
557 while (ch != 0 && (ch <=
' ' || ch == 160))
559 this.NextChar(Parser);
560 ch = this.PeekNextChar(Parser);
566 this.SkipWhiteSpace(Parser);
568 if (this.preamblePos < this.preambleLen)
570 int Start = this.preamblePos;
571 char ch = this.preamble[this.preamblePos];
573 if (
char.IsLetter(ch))
575 while (this.preamblePos < this.preambleLen &&
char.IsLetterOrDigit(this.preamble[this.preamblePos]))
578 else if (
char.IsDigit(ch))
580 while (this.preamblePos < this.preambleLen &&
char.IsDigit(this.preamble[this.preamblePos]))
583 else if (
char.IsSymbol(ch))
585 while (this.preamblePos < this.preambleLen &&
char.IsSymbol(this.preamble[this.preamblePos]))
591 return this.preamble.Substring(Start, this.preamblePos - Start);
599 this.SkipWhiteSpace(Parser);
601 if (this.preamblePos < this.preambleLen)
603 int Bak = this.preamblePos;
604 string Token = this.NextToken(Parser);
605 this.preamblePos = Bak;
632 this.currentPattern = this.currentRegularPattern;
634 this.ParseTriples(Parser);
644 this.currentRegularPattern = Bak;
645 this.currentPattern = Bak2;
652 this.ParseTriples(Parser,
null);
659 int TriplePosition =
Subject is
null ? 0 : 1;
660 bool InBlankNode = !(
Subject is
null);
664 if (TriplePosition == 0)
671 if (TriplePosition == 0)
682 this.currentPattern = Pattern;
687 this.currentRegularPattern =
null;
718 if (!this.ParsePatternOperator(Parser))
738 Object = this.ParseElement(Parser, TriplePosition,
761 if (!(AdditionalTriples is
null))
762 this.AddTriples(AdditionalTriples);
769 if (!(AdditionalTriples is
null))
770 this.AddTriples(AdditionalTriples);
774 if (this.currentRegularPattern is
null)
777 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
782 if (!(AdditionalTriples is
null))
783 this.AddTriples(AdditionalTriples);
827 if (
char.ToUpper(Parser.
NextChar()) !=
'I' ||
828 char.ToUpper(Parser.
NextChar()) !=
'N' ||
829 char.ToUpper(Parser.
NextChar()) !=
'D')
847 ScriptNode Node = this.ParseNamedExpression(Parser);
851 if (this.currentRegularPattern is
null)
854 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
870 if (
char.ToUpper(Parser.
NextChar()) !=
'I' ||
871 char.ToUpper(Parser.
NextChar()) !=
'L' ||
872 char.ToUpper(Parser.
NextChar()) !=
'T' ||
873 char.ToUpper(Parser.
NextChar()) !=
'E' ||
874 char.ToUpper(Parser.
NextChar()) !=
'R')
886 Node = this.ParseUnary(Parser,
false);
888 if (this.currentRegularPattern is
null)
891 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
894 this.currentRegularPattern.
AddFilter(Node);
911 if (!this.ParsePatternOperator(Parser))
931 if (this.currentRegularPattern is
null)
934 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
951 this.currentRegularPattern =
null;
958 Left = this.currentPattern;
959 Pattern = this.ParsePattern(Parser);
961 this.currentRegularPattern =
null;
968 Left = this.currentPattern;
969 Pattern = this.ParsePattern(Parser);
971 this.currentRegularPattern =
null;
981 if (!(AdditionalTriples is
null))
982 throw Parser.
SyntaxError(
"Blank Nodes not supported in a VALUES statement.");
984 this.currentRegularPattern =
null;
986 if (this.currentPattern.
IsEmpty)
987 this.currentPattern = Values;
994 SparqlParser SubParser =
new SparqlParser(
string.Empty);
996 foreach (KeyValuePair<string, string> P
in this.namespaces)
997 SubParser.namespaces[P.Key] = P.Value;
1000 throw Parser.
SyntaxError(
"Unable to parse subquery.");
1007 this.currentRegularPattern =
null;
1009 if (this.currentPattern.
IsEmpty)
1019 ScriptNode Graph = this.ParseExpression(Parser,
false);
1020 Pattern = this.ParsePattern(Parser);
1024 this.currentRegularPattern =
null;
1026 if (this.currentPattern.
IsEmpty)
1042 AdditionalTriples =
null;
1050 string s = this.ParseName(Parser);
1077 if (!(AdditionalTriples2 is
null))
1079 if (AdditionalTriples is
null)
1082 AdditionalTriples.AddRange(AdditionalTriples2);
1088 Values.
Add(Element);
1103 Names.Add(this.ParseName(Parser));
1116 int i, c =
Names.Count;
1118 throw Parser.
SyntaxError(
"Expected variable name.");
1135 for (i = 0; i < c; i++)
1140 if (!(AdditionalTriples2 is
null))
1142 if (AdditionalTriples is
null)
1145 AdditionalTriples.AddRange(AdditionalTriples2);
1151 Values.
Add(Element);
1178 ScriptNode Node = this.ParseExpression(Parser,
false);
1184 ScriptNode Name = this.ParseExpression(Parser,
false);
1193 return this.ParseOrs(Parser, Optional);
1255 Right = this.ParseTerms(Parser,
false);
1271 Right = this.ParseTerms(Parser,
false);
1276 Right = this.ParseTerms(Parser,
false);
1287 Right = this.ParseTerms(Parser,
false);
1292 Right = this.ParseTerms(Parser,
false);
1299 if (
string.Compare(Parser.
PeekNextToken(),
"IN",
true) == 0)
1302 Right = this.ParseTerms(Parser,
false);
1311 if (
string.Compare(Parser.
PeekNextToken(),
"NOT",
true) == 0)
1313 if (
string.Compare(Parser.
NextToken(),
"IN",
true) != 0)
1316 Right = this.ParseTerms(Parser,
false);
1347 Right = this.ParseFactors(Parser,
false);
1375 Right = this.ParseUnary(Parser,
false);
1396 ScriptNode Node = this.ParseUnary(Parser,
false);
1401 return this.ParseUnary(Parser,
false);
1425 Node = this.ParseUnary(Parser,
false);
1431 Node = this.ParseNamedExpression(Parser);
1439 string s = this.ParseName(Parser);
1461 Element = this.ParseUri(Parser);
1466 Element = this.ParsePrefixedToken(Parser,
string.Empty);
1470 if (!
char.IsLetter(ch))
1482 UriNode Fqn = this.ParsePrefixedToken(Parser, s);
1486 return this.ParseExtensionFunction(Fqn.
Uri.AbsoluteUri, Parser, Start);
1491 return this.ParseFunction(Parser, s, Start, Optional);
1497 switch (s.ToUpper())
1506 ScriptNode Node = this.ParseNamedExpression(Parser);
1510 if (this.currentRegularPattern is
null)
1513 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
1524 return this.ParseUnary(Parser, Optional);
1527 Node = this.ParseUnary(Parser,
false);
1529 if (this.currentRegularPattern is
null)
1532 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
1535 this.currentRegularPattern.
AddFilter(Node);
1537 return this.ParseUnary(Parser, Optional);
1547 ScriptNode[] Arguments = this.ParseArguments(Parser, 1,
int.MaxValue);
1555 Node = this.ParseArgument(Parser);
1559 Node = this.ParseArgument(Parser);
1563 Arguments = this.ParseArguments(Parser, 2, 3);
1564 if (Arguments.
Length == 2)
1576 return new Exists(this.ParsePattern(Parser),
1583 return new NotExists(this.ParsePattern(Parser),
1587 Node = this.ParseArgument(Parser);
1591 Node = this.ParseArgument(Parser);
1595 Node = this.ParseArgument(Parser);
1596 return new Script.Functions.Vectors.Min(Node, Start, Parser.
Position - Start, Parser.
Expression);
1599 Node = this.ParseArgument(Parser);
1600 return new Script.Functions.Vectors.Max(Node, Start, Parser.
Position - Start, Parser.
Expression);
1603 Node = this.ParseArgument(Parser);
1606 case "GROUP_CONCAT":
1607 Node = this.ParseArgumentOptionalScalarVal(Parser,
"separator", out
ScriptNode Node2);
1614 Node = this.ParseArgument(Parser);
1618 Node = this.ParseArgument(Parser);
1619 return new Script.Functions.Scalar.String(Node, Start, Parser.
Position - Start, Parser.
Expression);
1622 Node = this.ParseArgument(Parser);
1626 Node = this.ParseArgument(Parser);
1630 Node = this.ParseArgument(Parser);
1634 Node = this.ParseArgument(Parser);
1638 Node = this.ParseArgument(Parser);
1642 Node = this.ParseArgument(Parser);
1646 Node = this.ParseArgument(Parser);
1650 this.Parse2Arguments(Parser, out Node, out Node2);
1654 this.Parse2Arguments(Parser, out Node, out Node2);
1658 this.Parse2Arguments(Parser, out Node, out Node2);
1662 this.Parse2Arguments(Parser, out Node, out Node2);
1666 this.Parse2Arguments(Parser, out Node, out Node2);
1670 Arguments = this.ParseArguments(Parser, 2, 3);
1671 int NodeStart = Arguments[1].
Start;
1672 int NodeLen = Arguments[1].
Length;
1674 Arguments[1] =
new Subtract(Arguments[1],
1678 if (Arguments.
Length == 2)
1680 return new Mid(Arguments[0], Arguments[1],
null,
1685 return new Mid(Arguments[0], Arguments[1], Arguments[2],
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 Node = this.ParseArgument(Parser);
1714 this.Parse0Arguments(Parser);
1718 Node = this.ParseArgument(Parser);
1719 NodeStart = Node.
Start;
1727 Node = this.ParseArgument(Parser);
1728 NodeStart = Node.
Start;
1736 Node = this.ParseArgument(Parser);
1737 NodeStart = Node.
Start;
1745 Node = this.ParseArgument(Parser);
1746 NodeStart = Node.
Start;
1754 Node = this.ParseArgument(Parser);
1755 NodeStart = Node.
Start;
1763 this.Parse0Arguments(Parser);
1766 case "ENCODE_FOR_URI":
1767 Node = this.ParseArgument(Parser);
1771 this.Parse0Arguments(Parser);
1772 NodeLen = Parser.Position - Start;
1774 return new Script.Functions.Scalar.String(
1779 this.Parse0Arguments(Parser);
1780 NodeLen = Parser.Position - Start;
1782 return new Script.Functions.Scalar.Uri(
1785 new Script.Functions.Scalar.String(
1793 Node = this.ParseArgument(Parser);
1794 return new Script.Functions.Scalar.Uri(Node, Start, Parser.
Position - Start, Parser.
Expression);
1797 Arguments = this.ParseArguments(Parser, 3, 3);
1798 return new If(Arguments[0], Arguments[1], Arguments[2],
1802 this.Parse2Arguments(Parser, out Node, out Node2);
1806 Node = this.ParseArgument(Parser);
1807 return new Script.Functions.Runtime.Exists(Node, Start, Parser.
Position - Start, Parser.
Expression);
1811 Node = this.ParseArgument(Parser);
1815 Node = this.ParseArgument(Parser);
1819 Node = this.ParseArgument(Parser);
1823 Node = this.ParseArgument(Parser);
1827 Node = this.ParseArgument(Parser);
1831 Node = this.ParseArgument(Parser);
1835 Arguments = this.ParseArguments(Parser, 0, 1);
1837 if (Arguments.
Length == 0)
1843 this.Parse2Arguments(Parser, out Node, out Node2);
1847 this.Parse2Arguments(Parser, out Node, out Node2);
1851 this.Parse2Arguments(Parser, out Node, out Node2);
1855 Arguments = this.ParseArguments(Parser, 3, 4);
1856 if (Arguments.
Length == 2)
1858 return new Replace(Arguments[0], Arguments[1], Arguments[2],
true,
1863 return new Replace(Arguments[0], Arguments[1], Arguments[2], Arguments[3],
1868 Node = this.ParseArgument(Parser);
1872 Node = this.ParseArgument(Parser);
1876 Arguments = this.ParseArguments(Parser, 1,
int.MaxValue);
1880 Node = this.ParseArgument(Parser);
1881 return new Script.Functions.Runtime.Error(Node, Start, Parser.
Position - Start, Parser.
Expression);
1884 Arguments = this.ParseArguments(Parser, 3, 3);
1888 Node = this.ParseArgument(Parser);
1892 Node = this.ParseArgument(Parser);
1896 Node = this.ParseArgument(Parser);
1900 Node = this.ParseArgument(Parser);
1906 s = this.ParsePrefixedToken(Parser, s).
Uri.AbsoluteUri;
1907 return this.ParseExtensionFunction(s, Parser, Start);
1919 throw Parser.
SyntaxError(
"Unexpected token: " + s);
1927 lock (functionsPerUri)
1929 if (!functionsPerUri.TryGetValue(FullyQualifiedName, out
Function))
1932 functionsPerUri[FullyQualifiedName] =
Function;
1967 ScriptNode Argument = this.ParseExpression(Parser,
false);
1986 Argument1 = this.ParseExpression(Parser,
false);
1994 Argument2 = this.ParseExpression(Parser,
false);
2011 ScriptNode Argument = this.ParseExpression(Parser,
false);
2020 string s = this.ParseName(Parser);
2021 if (s != ExpectedScalarName)
2022 throw Parser.
SyntaxError(
"Expected " + ExpectedScalarName);
2030 ScalarVal = this.ParseExpression(Parser,
false);
2057 Arguments.
Add(this.ParseExpression(Parser,
false));
2066 int c = Arguments.
Count;
2085 AdditionalTriples =
null;
2097 switch (TriplePosition)
2100 BlankNode Node = this.CreateBlankNode();
2101 this.ParseTriples(Parser, Node);
2105 throw Parser.
SyntaxError(
"Predicate cannot be a blank node.");
2108 Node = this.CreateBlankNode();
2114 this.currentPattern = this.currentRegularPattern;
2116 this.ParseTriples(Parser, Node);
2118 AdditionalTriples = this.currentRegularPattern.
Triples;
2120 this.currentRegularPattern = Bak;
2121 this.currentPattern = Bak2;
2126 throw Parser.
SyntaxError(
"Unrecognized triple position.");
2130 return this.ParseCollection(Parser, out AdditionalTriples);
2140 return this.ParseUri(Parser);
2143 if (TriplePosition != 2)
2144 throw Parser.
SyntaxError(
"Literals can only occur in object position.");
2151 s = this.ParseString(Parser,
'"',
true,
true);
2154 s = this.ParseString(Parser,
'"',
false,
true);
2156 string Language =
null;
2161 Language = this.ParseName(Parser);
2172 else if (!
string.IsNullOrEmpty(Language))
2178 return this.ParsePrefixedToken(Parser,
string.Empty);
2183 s = this.ParseName(Parser);
2187 if (
char.IsWhiteSpace(ch))
2198 return new BlankNode(this.ParseName(Parser));
2200 else if (
char.IsLetter(ch) || ch ==
':')
2204 s = this.ParseName(Parser);
2209 return this.ParsePrefixedToken(Parser, s);
2215 if (TriplePosition == 1)
2220 if (TriplePosition == 2)
2225 if (TriplePosition == 2)
2230 if (
string.Compare(s,
"UNDEF",
true) == 0)
2232 if (TriplePosition != 2)
2242 if (TriplePosition == 0)
2255 if (TriplePosition != 2)
2256 throw Parser.
SyntaxError(
"Literals can only occur in object position.");
2259 return this.ParseNumber(Parser);
2274 AdditionalTriples =
null;
2284 if (Elements is
null)
2288 BlankNode Result = this.CreateBlankNode();
2292 if (this.currentRegularPattern is
null)
2295 this.currentPattern =
new IntersectionPattern(this.currentPattern, this.currentRegularPattern);
2298 while (!(Loop is
null))
2300 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
2304 if (i < c - 1 || !(Loop.
Next is
null))
2306 BlankNode Next = this.CreateBlankNode();
2323 if (!(AdditionalTriples2 is
null))
2325 if (AdditionalTriples is
null)
2328 AdditionalTriples.AddRange(AdditionalTriples2);
2331 if (Element is
null)
2334 if (Elements is
null)
2337 Elements.
Add(Element);
2347 throw Parser.
SyntaxError(
"Expected URI or prefixed token.");
2352 return this.ParseUri(Parser);
2355 string Prefix = this.ParseName(Parser);
2360 return this.ParsePrefixedToken(Parser, Prefix);
2365 if (!this.namespaces.TryGetValue(Prefix, out
string Namespace))
2370 string LocalName = this.ParseName(Parser);
2378 return string.Empty;
2381 bool LastPeriod =
false;
2406 throw Parser.
SyntaxError(
"Expected non-negative integer.");
2415 bool HasDigits =
false;
2416 bool HasDecimal =
false;
2417 bool HasExponent =
false;
2419 if (ch ==
'+' || ch ==
'-')
2425 while (
char.IsDigit(ch))
2438 while (
char.IsDigit(ch))
2445 if (ch ==
'e' || ch ==
'E')
2451 if (ch ==
'+' || ch ==
'-')
2457 while (
char.IsDigit(ch))
2473 throw Parser.
SyntaxError(
"Invalid double number.");
2475 else if (HasDecimal)
2480 throw Parser.
SyntaxError(
"Invalid decimal number.");
2484 if (BigInteger.TryParse(s, out BigInteger bi))
2487 throw Parser.
SyntaxError(
"Invalid integer number.");
2491 throw Parser.
SyntaxError(
"Expected value element.");
2494 private string ParseString(
ScriptParser Parser,
char EndChar,
bool MultiLine,
bool IncludeWhiteSpace)
2496 StringBuilder sb =
null;
2519 else if (ch ==
'\\')
2523 sb =
new StringBuilder();
2532 throw Parser.
SyntaxError(
"Expected escape code.");
2569 throw Parser.
SyntaxError(
"Expected 4-character hexadecimal code.");
2579 throw Parser.
SyntaxError(
"Expected 8-character hexadecimal code.");
2587 else if (IncludeWhiteSpace || !
char.IsWhiteSpace(ch))
2591 throw Parser.
SyntaxError(
"Expected " +
new string(EndChar, MultiLine ? 3 : 1));
2596 string Short = this.ParseString(Parser,
'>',
false,
false);
2598 if (this.baseUri is
null)
2600 if (
System.Uri.TryCreate(Short, UriKind.RelativeOrAbsolute, out
System.Uri URI))
2601 return new UriNode(URI, Short);
2607 if (
string.IsNullOrEmpty(Short))
2608 return new UriNode(this.baseUri, Short);
2609 else if (
System.Uri.TryCreate(
this.baseUri, Short, out
System.Uri URI))
2610 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, ref bool LastPeriod)
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.
Node referencing a chunk in a ChunkedList<T>
ChunkNode< T > Next
Next chunk
int Pos
Index after the last element in chunk.
int Start
Index of first element in chunk.
A chunked list is a linked list of chunks of objects of type T .
ChunkNode< T > FirstChunk
First chunk
int Count
Number of elements in collection.
void Add(T Item)
Adds an item to the collection.
T[] ToArray()
Returns an array containing all elements of the collection.
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
ChunkedList< SemanticQueryTriple > Triples
Triples, null if none.
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.
class Names(Vector NamesVector)
Contains a collection of distinguished names.
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