@traqula/rules-sparql-1-1 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +0 -2
  2. package/lib/Sparql11types.d.ts +373 -62
  3. package/lib/Sparql11types.js.map +1 -1
  4. package/lib/SparqlParser.d.ts +4 -4
  5. package/lib/SparqlParser.js +2 -2
  6. package/lib/SparqlParser.js.map +1 -1
  7. package/lib/expressionHelpers.d.ts +2 -2
  8. package/lib/expressionHelpers.js +19 -21
  9. package/lib/expressionHelpers.js.map +1 -1
  10. package/lib/factory.d.ts +66 -66
  11. package/lib/factory.js.map +1 -1
  12. package/lib/factoryMixins/ContextFactory.d.ts +1 -1
  13. package/lib/factoryMixins/ContextFactory.js.map +1 -1
  14. package/lib/factoryMixins/ExpressionFactory.d.ts +1 -1
  15. package/lib/factoryMixins/ExpressionFactory.js.map +1 -1
  16. package/lib/factoryMixins/GraphRefFactory.d.ts +1 -1
  17. package/lib/factoryMixins/GraphRefFactory.js.map +1 -1
  18. package/lib/factoryMixins/PathFactory.d.ts +1 -1
  19. package/lib/factoryMixins/PathFactory.js.map +1 -1
  20. package/lib/factoryMixins/Patternfactory.d.ts +1 -1
  21. package/lib/factoryMixins/Patternfactory.js.map +1 -1
  22. package/lib/factoryMixins/QueryFactory.d.ts +1 -1
  23. package/lib/factoryMixins/QueryFactory.js.map +1 -1
  24. package/lib/factoryMixins/SolutionModifiersFactory.d.ts +1 -1
  25. package/lib/factoryMixins/SolutionModifiersFactory.js.map +1 -1
  26. package/lib/factoryMixins/TermFactory.d.ts +1 -1
  27. package/lib/factoryMixins/TermFactory.js.map +1 -1
  28. package/lib/factoryMixins/UpdateOperationFactory.d.ts +1 -1
  29. package/lib/factoryMixins/UpdateOperationFactory.js.map +1 -1
  30. package/lib/grammar/builtIn.d.ts +2 -2
  31. package/lib/grammar/builtIn.js +66 -66
  32. package/lib/grammar/builtIn.js.map +1 -1
  33. package/lib/grammar/dataSetClause.d.ts +2 -2
  34. package/lib/grammar/dataSetClause.js +7 -7
  35. package/lib/grammar/dataSetClause.js.map +1 -1
  36. package/lib/grammar/expression.d.ts +2 -2
  37. package/lib/grammar/expression.js +47 -47
  38. package/lib/grammar/expression.js.map +1 -1
  39. package/lib/grammar/general.d.ts +2 -2
  40. package/lib/grammar/general.js +25 -25
  41. package/lib/grammar/general.js.map +1 -1
  42. package/lib/grammar/index.d.ts +2 -2
  43. package/lib/grammar/index.js +2 -2
  44. package/lib/grammar/index.js.map +1 -1
  45. package/lib/grammar/literals.d.ts +2 -2
  46. package/lib/grammar/literals.js +10 -10
  47. package/lib/grammar/literals.js.map +1 -1
  48. package/lib/grammar/propertyPaths.d.ts +3 -3
  49. package/lib/grammar/propertyPaths.js +19 -19
  50. package/lib/grammar/propertyPaths.js.map +1 -1
  51. package/lib/grammar/{queryUnit/queryUnit.d.ts → queryUnit.d.ts} +2 -2
  52. package/lib/grammar/{queryUnit/queryUnit.js → queryUnit.js} +67 -67
  53. package/lib/grammar/queryUnit.js.map +1 -0
  54. package/lib/grammar/solutionModifier.d.ts +2 -2
  55. package/lib/grammar/solutionModifier.js +29 -29
  56. package/lib/grammar/solutionModifier.js.map +1 -1
  57. package/lib/grammar/tripleBlock.d.ts +10 -10
  58. package/lib/grammar/tripleBlock.js +37 -37
  59. package/lib/grammar/tripleBlock.js.map +1 -1
  60. package/lib/grammar/{updateUnit/updateUnit.d.ts → updateUnit.d.ts} +2 -2
  61. package/lib/grammar/{updateUnit/updateUnit.js → updateUnit.js} +78 -78
  62. package/lib/grammar/updateUnit.js.map +1 -0
  63. package/lib/grammar/whereClause.d.ts +2 -2
  64. package/lib/grammar/whereClause.js +69 -69
  65. package/lib/grammar/whereClause.js.map +1 -1
  66. package/lib/index.cjs +1485 -1487
  67. package/lib/index.d.ts +1 -2
  68. package/lib/index.js +1 -2
  69. package/lib/index.js.map +1 -1
  70. package/lib/lexer/graph.d.ts +1 -1
  71. package/lib/lexer/lexer.d.ts +1 -1
  72. package/lib/lexer/terminals.d.ts +69 -0
  73. package/lib/lexer/terminals.js +69 -0
  74. package/lib/lexer/terminals.js.map +1 -1
  75. package/lib/sparql11HelperTypes.d.ts +68 -0
  76. package/lib/sparql11HelperTypes.js +2 -0
  77. package/lib/sparql11HelperTypes.js.map +1 -0
  78. package/lib/utils.d.ts +11 -0
  79. package/lib/utils.js +14 -0
  80. package/lib/utils.js.map +1 -1
  81. package/lib/validation/validators.d.ts +1 -1
  82. package/lib/validation/validators.js.map +1 -1
  83. package/package.json +3 -3
  84. package/lib/RoundTripTypes.d.ts +0 -379
  85. package/lib/RoundTripTypes.js +0 -2
  86. package/lib/RoundTripTypes.js.map +0 -1
  87. package/lib/grammar/queryUnit/queryUnit.js.map +0 -1
  88. package/lib/grammar/updateUnit/updateUnit.js.map +0 -1
  89. package/lib/grammar-helpers/utils.d.ts +0 -12
  90. package/lib/grammar-helpers/utils.js +0 -16
  91. package/lib/grammar-helpers/utils.js.map +0 -1
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Traqula Rules SPARQL 1.1
2
2
 
3
- **WARNING:** V2 will come shortly and will have lots of breaking changes.
4
-
5
3
  Traqula rules SPARQL 1.1 contains rules required for creating a parser for SPARQL 1.1.
6
4
 
7
5
  ## Installation
@@ -1,68 +1,379 @@
1
- import type { GeneratorRule, ParserRule } from '@traqula/core';
2
- import type { Factory } from './factory';
3
- export type SparqlRule<
1
+ import type { Localized, Node } from '@traqula/core';
2
+ export type Sparql11Nodes = GraphRef | UpdateOperation | Update | Query | DatasetClauses | TripleCollection | TripleNesting | Pattern | SolutionModifier | Expression | Path | ContextDefinition | Wildcard | Term;
3
+ export type GraphRefBase = Node & {
4
+ type: 'graphRef';
5
+ subType: string;
6
+ };
7
+ export type GraphRefDefault = GraphRefBase & {
8
+ subType: 'default';
9
+ };
10
+ export type GraphRefNamed = GraphRefBase & {
11
+ subType: 'named';
12
+ };
13
+ export type GraphRefAll = GraphRefBase & {
14
+ subType: 'all';
15
+ };
16
+ export type GraphRefSpecific = GraphRefBase & {
17
+ subType: 'specific';
18
+ graph: TermIri;
19
+ };
20
+ export type GraphRef = GraphRefDefault | GraphRefNamed | GraphRefAll | GraphRefSpecific;
21
+ export type Quads = PatternBgp | GraphQuads;
22
+ export type GraphQuads = Node & {
23
+ type: 'graph';
24
+ graph: TermIri | TermVariable;
25
+ triples: PatternBgp;
26
+ };
27
+ export type UpdateOperationBase = Node & {
28
+ type: 'updateOperation';
29
+ subType: string;
30
+ };
31
+ export type UpdateOperationLoad = UpdateOperationBase & {
32
+ subType: 'load';
33
+ silent: boolean;
34
+ source: TermIri;
35
+ destination?: GraphRefSpecific;
36
+ };
37
+ type UpdateOperationClearDropCreateBase = UpdateOperationBase & {
38
+ subType: 'clear' | 'drop' | 'create';
39
+ silent: boolean;
40
+ destination: GraphRef;
41
+ };
42
+ export type UpdateOperationClear = UpdateOperationClearDropCreateBase & {
43
+ subType: 'clear';
44
+ };
45
+ export type UpdateOperationDrop = UpdateOperationClearDropCreateBase & {
46
+ subType: 'drop';
47
+ };
48
+ export type UpdateOperationCreate = UpdateOperationClearDropCreateBase & {
49
+ subType: 'create';
50
+ destination: GraphRefSpecific;
51
+ };
52
+ type UpdateOperationAddMoveCopy = UpdateOperationBase & {
53
+ subType: 'add' | 'move' | 'copy';
54
+ silent: boolean;
55
+ source: GraphRefDefault | GraphRefSpecific;
56
+ destination: GraphRefDefault | GraphRefSpecific;
57
+ };
58
+ export type UpdateOperationAdd = UpdateOperationAddMoveCopy & {
59
+ subType: 'add';
60
+ };
61
+ export type UpdateOperationMove = UpdateOperationAddMoveCopy & {
62
+ subType: 'move';
63
+ };
64
+ export type UpdateOperationCopy = UpdateOperationAddMoveCopy & {
65
+ subType: 'copy';
66
+ };
67
+ type UpdateOperationInsertDeleteDelWhere = UpdateOperationBase & {
68
+ subType: 'insertdata' | 'deletedata' | 'deletewhere';
69
+ data: Quads[];
70
+ };
71
+ export type UpdateOperationInsertData = UpdateOperationInsertDeleteDelWhere & {
72
+ subType: 'insertdata';
73
+ };
74
+ export type UpdateOperationDeleteData = UpdateOperationInsertDeleteDelWhere & {
75
+ subType: 'deletedata';
76
+ };
77
+ export type UpdateOperationDeleteWhere = UpdateOperationInsertDeleteDelWhere & {
78
+ subType: 'deletewhere';
79
+ };
80
+ export type UpdateOperationModify = UpdateOperationBase & {
81
+ subType: 'modify';
82
+ graph: TermIri | undefined;
83
+ insert: Quads[];
84
+ delete: Quads[];
85
+ from: DatasetClauses;
86
+ where: PatternGroup;
87
+ };
88
+ export type UpdateOperation = UpdateOperationLoad | UpdateOperationClear | UpdateOperationDrop | UpdateOperationCreate | UpdateOperationAdd | UpdateOperationMove | UpdateOperationCopy | UpdateOperationInsertData | UpdateOperationDeleteData | UpdateOperationDeleteWhere | UpdateOperationModify;
89
+ export type Update = Node & {
90
+ type: 'update';
91
+ updates: {
92
+ operation?: UpdateOperation;
93
+ context: ContextDefinition[];
94
+ }[];
95
+ };
96
+ export type QueryBase = Node & {
97
+ type: 'query';
98
+ subType: string;
99
+ context: ContextDefinition[];
100
+ values?: PatternValues;
101
+ solutionModifiers: SolutionModifiers;
102
+ datasets: DatasetClauses;
103
+ where?: PatternGroup;
104
+ };
105
+ export type QuerySelect = QueryBase & {
106
+ subType: 'select';
107
+ variables: (TermVariable | PatternBind)[] | [Wildcard];
108
+ distinct?: true;
109
+ reduced?: true;
110
+ where: PatternGroup;
111
+ };
112
+ export type QueryConstruct = QueryBase & {
113
+ subType: 'construct';
114
+ template: PatternBgp;
115
+ where: PatternGroup;
116
+ };
117
+ export type QueryDescribe = QueryBase & {
118
+ subType: 'describe';
119
+ variables: (TermVariable | TermIri)[] | [Wildcard];
120
+ };
121
+ export type QueryAsk = QueryBase & {
122
+ subType: 'ask';
123
+ where: PatternGroup;
124
+ };
125
+ export type Query = QuerySelect | QueryConstruct | QueryDescribe | QueryAsk;
126
+ export type SparqlQuery = Query | Update;
127
+ export type DatasetClauses = Node & {
128
+ type: 'datasetClauses';
129
+ clauses: {
130
+ clauseType: 'default' | 'named';
131
+ value: TermIri;
132
+ }[];
133
+ };
134
+ export type TripleCollectionBase = Node & {
135
+ type: 'tripleCollection';
136
+ subType: string;
137
+ triples: TripleNesting[];
138
+ identifier: Term;
139
+ };
4
140
  /**
5
- * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.
141
+ * The subject of the triples does not have a string manifestation.
6
142
  */
7
- NameType extends string = string,
143
+ export type TripleCollectionList = TripleCollectionBase & {
144
+ subType: 'list';
145
+ identifier: TermBlank;
146
+ };
8
147
  /**
9
- * Type that will be returned after a correct parse of this rule.
10
- * This type will be the return type of calling SUBRULE with this grammar rule.
148
+ * Bot subject and predicate of the triples do not have a string manifestation.
11
149
  */
12
- ReturnType = unknown, GenInputType = ReturnType,
13
- /**
14
- * Function arguments that can be given to convey the state of the current parse operation.
15
- */
16
- ParamType = undefined> = SparqlGrammarRule<NameType, ReturnType, ParamType> & SparqlGeneratorRule<NameType, GenInputType, ParamType>;
17
- export type SparqlGeneratorRule<
18
- /**
19
- * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.
20
- */
21
- NameType extends string = string,
22
- /**
23
- * Type that will be returned after a correct parse of this rule.
24
- * This type will be the return type of calling SUBRULE with this grammar rule.
25
- */
26
- ReturnType = unknown,
27
- /**
28
- * Function arguments that can be given to convey the state of the current parse operation.
29
- */
30
- ParamType = undefined> = GeneratorRule<{
31
- factory: Factory;
32
- }, NameType, ReturnType, ParamType>;
33
- export type SparqlGrammarRule<
34
- /**
35
- * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.
36
- */
37
- NameType extends string = string,
38
- /**
39
- * Type that will be returned after a correct parse of this rule.
40
- * This type will be the return type of calling SUBRULE with this grammar rule.
41
- */
42
- ReturnType = unknown,
43
- /**
44
- * Function arguments that can be given to convey the state of the current parse operation.
45
- */
46
- ParamType = undefined> = ParserRule<SparqlContext, NameType, ReturnType, ParamType>;
47
- export interface SparqlContext {
48
- /**
49
- * Data-factoryMixins to be used when constructing rdf primitives.
50
- */
51
- factory: Factory;
52
- /**
53
- * Current scoped prefixes. Used for resolving prefixed names.
54
- */
55
- prefixes: Record<string, string>;
150
+ export type TripleCollectionBlankNodeProperties = TripleCollectionBase & {
151
+ subType: 'blankNodeProperties';
152
+ identifier: TermBlank;
153
+ };
154
+ export type TripleCollection = TripleCollectionList | TripleCollectionBlankNodeProperties;
155
+ export type GraphNode = Term | TripleCollection;
156
+ export type TripleNesting = Node & {
157
+ type: 'triple';
158
+ subject: GraphNode;
159
+ predicate: TermIri | TermVariable | Path;
160
+ object: GraphNode;
161
+ };
162
+ export type PatternBase = Node & {
163
+ type: 'pattern';
164
+ subType: string;
165
+ };
166
+ export type PatternFilter = PatternBase & {
167
+ subType: 'filter';
168
+ expression: Expression;
169
+ };
170
+ export type PatternMinus = PatternBase & {
171
+ subType: 'minus';
172
+ patterns: Pattern[];
173
+ };
174
+ export type PatternGroup = PatternBase & {
175
+ subType: 'group';
176
+ patterns: Pattern[];
177
+ };
178
+ export type PatternOptional = PatternBase & {
179
+ subType: 'optional';
180
+ patterns: Pattern[];
181
+ };
182
+ export type PatternGraph = PatternBase & {
183
+ subType: 'graph';
184
+ name: TermIri | TermVariable;
185
+ patterns: Pattern[];
186
+ };
187
+ export type PatternUnion = PatternBase & {
188
+ subType: 'union';
189
+ patterns: PatternGroup[];
190
+ };
191
+ export type BasicGraphPattern = (TripleNesting | TripleCollection)[];
192
+ export type PatternBgp = PatternBase & {
193
+ subType: 'bgp';
56
194
  /**
57
- * The base IRI for the query. Used for resolving relative IRIs.
195
+ * Only the first appearance of a subject and predicate have a string manifestation
58
196
  */
59
- baseIRI: string | undefined;
60
- /**
61
- * Can be used to disable the validation that used variables in a select clause are in scope.
62
- */
63
- skipValidation: boolean;
64
- /**
65
- * Set of queryModes. Primarily used for note 8, 14.
66
- */
67
- parseMode: Set<'canParseVars' | 'canCreateBlankNodes' | 'inAggregate' | 'canParseAggregate' | string>;
68
- }
197
+ triples: BasicGraphPattern;
198
+ };
199
+ export type PatternBind = PatternBase & {
200
+ subType: 'bind';
201
+ expression: Expression;
202
+ variable: TermVariable;
203
+ };
204
+ export type PatternService = PatternBase & {
205
+ subType: 'service';
206
+ name: TermIri | TermVariable;
207
+ silent: boolean;
208
+ patterns: Pattern[];
209
+ };
210
+ /**
211
+ * A single list of assignments maps the variable identifier to the value
212
+ */
213
+ export type ValuePatternRow = Record<string, TermIri | TermLiteral | undefined>;
214
+ export type PatternValues = PatternBase & {
215
+ subType: 'values';
216
+ values: ValuePatternRow[];
217
+ };
218
+ export type SubSelect = QuerySelect;
219
+ export type Pattern = PatternBgp | PatternGroup | PatternUnion | PatternOptional | PatternMinus | PatternGraph | PatternService | PatternFilter | PatternBind | PatternValues | SubSelect;
220
+ export type SolutionModifiers = {
221
+ group?: SolutionModifierGroup;
222
+ having?: SolutionModifierHaving;
223
+ order?: SolutionModifierOrder;
224
+ limitOffset?: SolutionModifierLimitOffset;
225
+ };
226
+ export type SolutionModifierBase = Node & {
227
+ type: 'solutionModifier';
228
+ subType: string;
229
+ };
230
+ export type SolutionModifierGroupBind = Localized & {
231
+ variable: TermVariable;
232
+ value: Expression;
233
+ };
234
+ export type SolutionModifierGroup = SolutionModifierBase & {
235
+ subType: 'group';
236
+ groupings: (Expression | SolutionModifierGroupBind)[];
237
+ };
238
+ export type SolutionModifierHaving = SolutionModifierBase & {
239
+ subType: 'having';
240
+ having: Expression[];
241
+ };
242
+ export type Ordering = Localized & {
243
+ descending: boolean;
244
+ expression: Expression;
245
+ };
246
+ export type SolutionModifierOrder = SolutionModifierBase & {
247
+ subType: 'order';
248
+ orderDefs: Ordering[];
249
+ };
250
+ export type SolutionModifierLimitOffset = SolutionModifierBase & {
251
+ subType: 'limitOffset';
252
+ limit: number | undefined;
253
+ offset: number | undefined;
254
+ };
255
+ export type SolutionModifier = SolutionModifierGroup | SolutionModifierHaving | SolutionModifierOrder | SolutionModifierLimitOffset;
256
+ export type ExpressionBase = Node & {
257
+ type: 'expression';
258
+ subType: string;
259
+ };
260
+ type ExpressionAggregateBase = ExpressionBase & {
261
+ subType: 'aggregate';
262
+ distinct: boolean;
263
+ expression: [Expression | Wildcard];
264
+ };
265
+ export type ExpressionAggregateDefault = ExpressionAggregateBase & {
266
+ expression: [Expression];
267
+ aggregation: string;
268
+ };
269
+ export type ExpressionAggregateOnWildcard = ExpressionAggregateBase & {
270
+ expression: [Wildcard];
271
+ aggregation: string;
272
+ };
273
+ export type ExpressionAggregateSeparator = ExpressionAggregateBase & {
274
+ expression: [Expression];
275
+ aggregation: string;
276
+ separator: string;
277
+ };
278
+ export type ExpressionAggregate = ExpressionAggregateDefault | ExpressionAggregateOnWildcard | ExpressionAggregateSeparator;
279
+ export type ExpressionOperation = ExpressionBase & {
280
+ subType: 'operation';
281
+ operator: string;
282
+ args: Expression[];
283
+ };
284
+ export type ExpressionPatternOperation = ExpressionBase & {
285
+ subType: 'patternOperation';
286
+ operator: string;
287
+ args: PatternGroup;
288
+ };
289
+ export type ExpressionFunctionCall = ExpressionBase & {
290
+ subType: 'functionCall';
291
+ function: TermIri;
292
+ distinct: boolean;
293
+ args: Expression[];
294
+ };
295
+ export type Expression = ExpressionOperation | ExpressionPatternOperation | ExpressionFunctionCall | ExpressionAggregate | TermIri | TermVariable | TermLiteral;
296
+ export type PropertyPathBase = Node & {
297
+ type: 'path';
298
+ subType: string;
299
+ };
300
+ export type PropertyPathChain = PropertyPathBase & {
301
+ subType: '|' | '/';
302
+ items: Path[];
303
+ };
304
+ export type PathModified = PropertyPathBase & {
305
+ subType: '?' | '*' | '+' | '^';
306
+ items: [Path];
307
+ };
308
+ export type PathNegatedElt = PropertyPathBase & {
309
+ subType: '^';
310
+ items: [TermIri];
311
+ };
312
+ export type PathAlternativeLimited = PropertyPathBase & {
313
+ subType: '|';
314
+ items: (TermIri | PathNegatedElt)[];
315
+ };
316
+ export type PathNegated = PropertyPathBase & {
317
+ subType: '!';
318
+ items: [TermIri | PathNegatedElt | PathAlternativeLimited];
319
+ };
320
+ export type Path = TermIri | PropertyPathChain | PathModified | PathNegated;
321
+ export type PathPure = PropertyPathChain | PathModified | PathNegated;
322
+ export type ContextDefinitionBase_ = Node & {
323
+ type: 'contextDef';
324
+ subType: string;
325
+ };
326
+ export type ContextDefinitionPrefix = ContextDefinitionBase_ & {
327
+ subType: 'prefix';
328
+ key: string;
329
+ value: TermIriFull;
330
+ };
331
+ export type ContextDefinitionBase = ContextDefinitionBase_ & {
332
+ subType: 'base';
333
+ value: TermIriFull;
334
+ };
335
+ export type ContextDefinition = ContextDefinitionPrefix | ContextDefinitionBase;
336
+ export type Wildcard = Node & {
337
+ type: 'wildcard';
338
+ };
339
+ export type TermBase = Node & {
340
+ type: 'term';
341
+ subType: string;
342
+ };
343
+ export type TermLiteralBase = TermBase & {
344
+ subType: 'literal';
345
+ value: string;
346
+ };
347
+ export type TermLiteralStr = TermLiteralBase & {
348
+ langOrIri: undefined;
349
+ };
350
+ export type TermLiteralLangStr = TermLiteralBase & {
351
+ langOrIri: string;
352
+ };
353
+ export type TermLiteralTyped = TermLiteralBase & {
354
+ langOrIri: TermIri;
355
+ };
356
+ export type TermLiteral = TermLiteralStr | TermLiteralLangStr | TermLiteralTyped;
357
+ export type TermVariable = TermBase & {
358
+ subType: 'variable';
359
+ value: string;
360
+ };
361
+ export type TermIriBase = TermBase & {
362
+ subType: 'namedNode';
363
+ };
364
+ export type TermIriFull = TermIriBase & {
365
+ value: string;
366
+ };
367
+ export type TermIriPrefixed = TermIriBase & {
368
+ value: string;
369
+ prefix: string;
370
+ };
371
+ export type TermIri = TermIriFull | TermIriPrefixed;
372
+ export type TermBlank = TermBase & {
373
+ subType: 'blankNode';
374
+ } & {
375
+ label: string;
376
+ };
377
+ export type GraphTerm = TermIri | TermBlank | TermLiteral;
378
+ export type Term = GraphTerm | TermVariable;
379
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Sparql11types.js","sourceRoot":"","sources":["Sparql11types.ts"],"names":[],"mappings":"","sourcesContent":["import type { GeneratorRule, ParserRule } from '@traqula/core';\nimport type { Factory } from './factory';\n\nexport type SparqlRule<\n /**\n * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.\n */\n NameType extends string = string,\n /**\n * Type that will be returned after a correct parse of this rule.\n * This type will be the return type of calling SUBRULE with this grammar rule.\n */\n ReturnType = unknown,\n GenInputType = ReturnType,\n /**\n * Function arguments that can be given to convey the state of the current parse operation.\n */\n ParamType = undefined,\n> = SparqlGrammarRule<NameType, ReturnType, ParamType>\n & SparqlGeneratorRule<NameType, GenInputType, ParamType>;\n\nexport type SparqlGeneratorRule<\n /**\n * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.\n */\n NameType extends string = string,\n /**\n * Type that will be returned after a correct parse of this rule.\n * This type will be the return type of calling SUBRULE with this grammar rule.\n */\n ReturnType = unknown,\n /**\n * Function arguments that can be given to convey the state of the current parse operation.\n */\n ParamType = undefined,\n> = GeneratorRule<{ factory: Factory }, NameType, ReturnType, ParamType>;\n\nexport type SparqlGrammarRule<\n /**\n * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.\n */\n NameType extends string = string,\n /**\n * Type that will be returned after a correct parse of this rule.\n * This type will be the return type of calling SUBRULE with this grammar rule.\n */\n ReturnType = unknown,\n /**\n * Function arguments that can be given to convey the state of the current parse operation.\n */\n ParamType = undefined,\n> = ParserRule<SparqlContext, NameType, ReturnType, ParamType>;\n\nexport interface SparqlContext {\n /**\n * Data-factoryMixins to be used when constructing rdf primitives.\n */\n factory: Factory;\n /**\n * Current scoped prefixes. Used for resolving prefixed names.\n */\n prefixes: Record<string, string>;\n /**\n * The base IRI for the query. Used for resolving relative IRIs.\n */\n baseIRI: string | undefined;\n /**\n * Can be used to disable the validation that used variables in a select clause are in scope.\n */\n skipValidation: boolean;\n /**\n * Set of queryModes. Primarily used for note 8, 14.\n */\n parseMode: Set<'canParseVars' | 'canCreateBlankNodes' | 'inAggregate' | 'canParseAggregate' | string>;\n}\n"]}
1
+ {"version":3,"file":"Sparql11types.js","sourceRoot":"","sources":["Sparql11types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Localized, Node } from '@traqula/core';\n\nexport type Sparql11Nodes =\n | GraphRef\n | UpdateOperation\n | Update\n | Query\n | DatasetClauses\n | TripleCollection\n | TripleNesting\n | Pattern\n | SolutionModifier\n | Expression\n | Path\n | ContextDefinition\n | Wildcard\n | Term;\n\nexport type GraphRefBase = Node & {\n type: 'graphRef';\n subType: string;\n};\nexport type GraphRefDefault = GraphRefBase & {\n subType: 'default';\n};\nexport type GraphRefNamed = GraphRefBase & {\n subType: 'named';\n};\nexport type GraphRefAll = GraphRefBase & {\n subType: 'all';\n};\nexport type GraphRefSpecific = GraphRefBase & {\n subType: 'specific';\n graph: TermIri;\n};\nexport type GraphRef =\n | GraphRefDefault\n | GraphRefNamed\n | GraphRefAll\n | GraphRefSpecific;\n\nexport type Quads = PatternBgp | GraphQuads;\n\nexport type GraphQuads = Node & {\n type: 'graph';\n graph: TermIri | TermVariable;\n triples: PatternBgp;\n};\n\n// https://www.w3.org/TR/sparql11-query/#rUpdate1\nexport type UpdateOperationBase = Node & { type: 'updateOperation'; subType: string };\nexport type UpdateOperationLoad = UpdateOperationBase & {\n subType: 'load';\n silent: boolean;\n source: TermIri;\n destination?: GraphRefSpecific;\n};\ntype UpdateOperationClearDropCreateBase = UpdateOperationBase & {\n subType: 'clear' | 'drop' | 'create';\n silent: boolean;\n destination: GraphRef;\n};\nexport type UpdateOperationClear = UpdateOperationClearDropCreateBase & { subType: 'clear' };\nexport type UpdateOperationDrop = UpdateOperationClearDropCreateBase & { subType: 'drop' };\nexport type UpdateOperationCreate = UpdateOperationClearDropCreateBase & {\n subType: 'create';\n destination: GraphRefSpecific;\n};\ntype UpdateOperationAddMoveCopy = UpdateOperationBase & {\n subType: 'add' | 'move' | 'copy';\n silent: boolean;\n source: GraphRefDefault | GraphRefSpecific;\n destination: GraphRefDefault | GraphRefSpecific;\n};\nexport type UpdateOperationAdd = UpdateOperationAddMoveCopy & { subType: 'add' };\nexport type UpdateOperationMove = UpdateOperationAddMoveCopy & { subType: 'move' };\nexport type UpdateOperationCopy = UpdateOperationAddMoveCopy & { subType: 'copy' };\ntype UpdateOperationInsertDeleteDelWhere = UpdateOperationBase & {\n subType: 'insertdata' | 'deletedata' | 'deletewhere';\n data: Quads[];\n};\nexport type UpdateOperationInsertData = UpdateOperationInsertDeleteDelWhere & { subType: 'insertdata' };\nexport type UpdateOperationDeleteData = UpdateOperationInsertDeleteDelWhere & { subType: 'deletedata' };\nexport type UpdateOperationDeleteWhere = UpdateOperationInsertDeleteDelWhere & { subType: 'deletewhere' };\nexport type UpdateOperationModify = UpdateOperationBase & {\n subType: 'modify';\n graph: TermIri | undefined;\n insert: Quads[];\n delete: Quads[];\n from: DatasetClauses;\n where: PatternGroup;\n};\nexport type UpdateOperation =\n | UpdateOperationLoad\n | UpdateOperationClear\n | UpdateOperationDrop\n | UpdateOperationCreate\n | UpdateOperationAdd\n | UpdateOperationMove\n | UpdateOperationCopy\n | UpdateOperationInsertData\n | UpdateOperationDeleteData\n | UpdateOperationDeleteWhere\n | UpdateOperationModify;\n\n// https://www.w3.org/TR/sparql11-query/#rUpdate\nexport type Update = Node & {\n type: 'update';\n updates: {\n operation?: UpdateOperation;\n context: ContextDefinition[];\n }[];\n};\n\n// https://www.w3.org/TR/sparql11-query/#rQueryUnit\nexport type QueryBase = Node & {\n type: 'query';\n subType: string;\n\n context: ContextDefinition[];\n values?: PatternValues;\n solutionModifiers: SolutionModifiers;\n datasets: DatasetClauses;\n where?: PatternGroup;\n};\nexport type QuerySelect = QueryBase & {\n subType: 'select';\n variables: (TermVariable | PatternBind)[] | [Wildcard];\n distinct?: true;\n reduced?: true;\n where: PatternGroup;\n};\nexport type QueryConstruct = QueryBase & {\n subType: 'construct';\n template: PatternBgp;\n where: PatternGroup;\n};\nexport type QueryDescribe = QueryBase & {\n subType: 'describe';\n variables: (TermVariable | TermIri)[] | [Wildcard];\n};\nexport type QueryAsk = QueryBase & {\n subType: 'ask';\n where: PatternGroup;\n};\nexport type Query =\n | QuerySelect\n | QueryConstruct\n | QueryDescribe\n | QueryAsk;\n\nexport type SparqlQuery = Query | Update;\n\n// https://www.w3.org/TR/sparql11-query/#rDatasetClause\nexport type DatasetClauses = Node & {\n type: 'datasetClauses';\n clauses: { clauseType: 'default' | 'named'; value: TermIri }[];\n};\n\n// https://www.w3.org/TR/sparql11-query/#rGraphNode\nexport type TripleCollectionBase = Node & {\n type: 'tripleCollection';\n subType: string;\n triples: TripleNesting[];\n identifier: Term;\n};\n/**\n * The subject of the triples does not have a string manifestation.\n */\nexport type TripleCollectionList = TripleCollectionBase & {\n subType: 'list';\n identifier: TermBlank;\n};\n/**\n * Bot subject and predicate of the triples do not have a string manifestation.\n */\nexport type TripleCollectionBlankNodeProperties = TripleCollectionBase & {\n subType: 'blankNodeProperties';\n identifier: TermBlank;\n};\nexport type TripleCollection =\n | TripleCollectionList\n | TripleCollectionBlankNodeProperties;\n\n// https://www.w3.org/TR/sparql11-query/#rGraphNode\nexport type GraphNode = Term | TripleCollection;\n\n// https://www.w3.org/TR/sparql11-query/#rTriplesBlock\nexport type TripleNesting = Node & {\n type: 'triple';\n subject: GraphNode;\n predicate: TermIri | TermVariable | Path;\n object: GraphNode;\n};\n\nexport type PatternBase = Node & { type: 'pattern'; subType: string };\nexport type PatternFilter = PatternBase & {\n subType: 'filter';\n expression: Expression;\n};\nexport type PatternMinus = PatternBase & {\n subType: 'minus';\n patterns: Pattern[];\n};\n\nexport type PatternGroup = PatternBase & {\n subType: 'group';\n patterns: Pattern[];\n};\nexport type PatternOptional = PatternBase & {\n subType: 'optional';\n patterns: Pattern[];\n};\nexport type PatternGraph = PatternBase & {\n subType: 'graph';\n name: TermIri | TermVariable;\n patterns: Pattern[];\n};\nexport type PatternUnion = PatternBase & {\n subType: 'union';\n patterns: PatternGroup[];\n};\nexport type BasicGraphPattern = (TripleNesting | TripleCollection)[];\nexport type PatternBgp = PatternBase & {\n subType: 'bgp';\n /**\n * Only the first appearance of a subject and predicate have a string manifestation\n */\n triples: BasicGraphPattern;\n};\nexport type PatternBind = PatternBase & {\n subType: 'bind';\n expression: Expression;\n variable: TermVariable;\n};\nexport type PatternService = PatternBase & {\n subType: 'service';\n name: TermIri | TermVariable;\n silent: boolean;\n patterns: Pattern[];\n};\n/**\n * A single list of assignments maps the variable identifier to the value\n */\nexport type ValuePatternRow = Record<string, TermIri | TermLiteral | undefined>;\nexport type PatternValues = PatternBase & {\n subType: 'values';\n values: ValuePatternRow[];\n};\nexport type SubSelect = QuerySelect;\n\nexport type Pattern =\n | PatternBgp\n | PatternGroup\n | PatternUnion\n | PatternOptional\n | PatternMinus\n | PatternGraph\n | PatternService\n | PatternFilter\n | PatternBind\n | PatternValues\n | SubSelect;\n\nexport type SolutionModifiers = {\n group?: SolutionModifierGroup;\n having?: SolutionModifierHaving;\n order?: SolutionModifierOrder;\n limitOffset?: SolutionModifierLimitOffset;\n};\nexport type SolutionModifierBase = Node & { type: 'solutionModifier'; subType: string };\nexport type SolutionModifierGroupBind = Localized & {\n variable: TermVariable;\n value: Expression;\n};\nexport type SolutionModifierGroup = SolutionModifierBase & {\n subType: 'group';\n groupings: (Expression | SolutionModifierGroupBind)[];\n};\nexport type SolutionModifierHaving = SolutionModifierBase & {\n subType: 'having';\n having: Expression[];\n};\nexport type Ordering = Localized & {\n descending: boolean;\n expression: Expression;\n};\nexport type SolutionModifierOrder = SolutionModifierBase & {\n subType: 'order';\n orderDefs: Ordering[];\n};\nexport type SolutionModifierLimitOffset = SolutionModifierBase\n & { subType: 'limitOffset'; limit: number | undefined; offset: number | undefined };\n\nexport type SolutionModifier =\n | SolutionModifierGroup\n | SolutionModifierHaving\n | SolutionModifierOrder\n | SolutionModifierLimitOffset;\n\nexport type ExpressionBase = Node & { type: 'expression'; subType: string };\n\ntype ExpressionAggregateBase = ExpressionBase & {\n subType: 'aggregate';\n distinct: boolean;\n expression: [Expression | Wildcard];\n};\nexport type ExpressionAggregateDefault = ExpressionAggregateBase & {\n expression: [Expression];\n aggregation: string;\n};\nexport type ExpressionAggregateOnWildcard = ExpressionAggregateBase & {\n expression: [Wildcard];\n aggregation: string;\n};\nexport type ExpressionAggregateSeparator = ExpressionAggregateBase & {\n expression: [Expression];\n aggregation: string;\n separator: string;\n};\nexport type ExpressionAggregate =\n | ExpressionAggregateDefault\n | ExpressionAggregateOnWildcard\n | ExpressionAggregateSeparator;\n\nexport type ExpressionOperation = ExpressionBase & {\n subType: 'operation';\n operator: string;\n args: Expression[];\n};\n\nexport type ExpressionPatternOperation = ExpressionBase & {\n subType: 'patternOperation';\n operator: string;\n // Can be a pattern in case of exists and not exists\n args: PatternGroup;\n};\n\nexport type ExpressionFunctionCall = ExpressionBase & {\n subType: 'functionCall';\n function: TermIri;\n distinct: boolean;\n args: Expression[];\n};\n\nexport type Expression =\n | ExpressionOperation\n | ExpressionPatternOperation\n | ExpressionFunctionCall\n | ExpressionAggregate\n | TermIri\n | TermVariable\n | TermLiteral;\n\nexport type PropertyPathBase = Node & { type: 'path'; subType: string };\nexport type PropertyPathChain = PropertyPathBase & {\n subType: '|' | '/';\n items: Path[];\n};\n\nexport type PathModified = PropertyPathBase & {\n subType: '?' | '*' | '+' | '^';\n items: [Path];\n};\n\nexport type PathNegatedElt = PropertyPathBase & {\n subType: '^';\n items: [TermIri];\n};\n\nexport type PathAlternativeLimited = PropertyPathBase & {\n subType: '|';\n items: (TermIri | PathNegatedElt)[];\n};\n\nexport type PathNegated = PropertyPathBase & {\n subType: '!';\n items: [TermIri | PathNegatedElt | PathAlternativeLimited];\n};\n\n// [[88]](https://www.w3.org/TR/sparql11-query/#rPath)\nexport type Path =\n | TermIri\n | PropertyPathChain\n | PathModified\n | PathNegated;\nexport type PathPure = PropertyPathChain | PathModified | PathNegated;\n\nexport type ContextDefinitionBase_ = Node & { type: 'contextDef'; subType: string };\nexport type ContextDefinitionPrefix = ContextDefinitionBase_ & {\n subType: 'prefix';\n key: string;\n value: TermIriFull;\n};\nexport type ContextDefinitionBase = ContextDefinitionBase_ & {\n subType: 'base';\n value: TermIriFull;\n};\nexport type ContextDefinition = ContextDefinitionPrefix | ContextDefinitionBase;\n\nexport type Wildcard = Node & {\n type: 'wildcard';\n};\n\nexport type TermBase = Node & { type: 'term'; subType: string };\nexport type TermLiteralBase = TermBase & {\n subType: 'literal';\n value: string;\n};\nexport type TermLiteralStr = TermLiteralBase & { langOrIri: undefined };\nexport type TermLiteralLangStr = TermLiteralBase & { langOrIri: string };\nexport type TermLiteralTyped = TermLiteralBase & { langOrIri: TermIri };\nexport type TermLiteral = TermLiteralStr | TermLiteralLangStr | TermLiteralTyped;\n\nexport type TermVariable = TermBase & {\n subType: 'variable';\n value: string;\n};\n\nexport type TermIriBase = TermBase & { subType: 'namedNode' };\nexport type TermIriFull = TermIriBase & { value: string };\nexport type TermIriPrefixed = TermIriBase & {\n value: string;\n prefix: string;\n};\nexport type TermIri = TermIriFull | TermIriPrefixed;\n\nexport type TermBlank = TermBase & { subType: 'blankNode' } & { label: string };\n\nexport type GraphTerm = TermIri | TermBlank | TermLiteral;\nexport type Term = GraphTerm | TermVariable;\n"]}
@@ -1,8 +1,8 @@
1
- import type { Path, TermIri } from './RoundTripTypes';
2
- import type { SparqlContext } from './Sparql11types';
1
+ import type { SparqlContext } from './sparql11HelperTypes';
2
+ import type { Path, TermIri } from './Sparql11types';
3
3
  interface Parser<ParseRet> {
4
- queryOrUpdate: (input: string, context: SparqlContext, arg: undefined) => ParseRet;
5
- path: (input: string, context: SparqlContext, arg: undefined) => TermIri | Path;
4
+ queryOrUpdate: (input: string, context: SparqlContext) => ParseRet;
5
+ path: (input: string, context: SparqlContext) => TermIri | Path;
6
6
  }
7
7
  export declare function completeParseContext(context: Partial<SparqlContext & {
8
8
  origSource: string;
@@ -16,10 +16,10 @@ export class SparqlParser {
16
16
  this.F = new Factory();
17
17
  }
18
18
  parse(query, context = {}) {
19
- return this.parser.queryOrUpdate(query, completeParseContext(context), undefined);
19
+ return this.parser.queryOrUpdate(query, completeParseContext(context));
20
20
  }
21
21
  parsePath(query, context = {}) {
22
- const result = this.parser.path(query, completeParseContext(context), undefined);
22
+ const result = this.parser.path(query, completeParseContext(context));
23
23
  if (this.F.isPathPure(result)) {
24
24
  return {
25
25
  ...result,
@@ -1 +1 @@
1
- {"version":3,"file":"SparqlParser.js","sourceRoot":"","sources":["SparqlParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,MAAM,UAAU,oBAAoB,CAClC,OAAyE;IAEzE,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI,OAAO,EAAE;QACzC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE;QACjC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAE,cAAc,EAAE,qBAAqB,CAAE,CAAC;QAC9G,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,KAAK;KAChD,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,YAAY;IACvB,YAAoC,MAAwB;QAAxB,WAAM,GAAN,MAAM,CAAkB;QAC3C,MAAC,GAAG,IAAI,OAAO,EAAE,CAAC;IAD4B,CAAC;IAGzD,KAAK,CAAC,KAAa,EAAE,UAAkC,EAAE;QAC9D,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,oBAAoB,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;IACpF,CAAC;IAEM,SAAS,CAAC,KAAa,EAAE,UAAkC,EAAE;QAElE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,oBAAoB,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;QACjF,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,OAAO;gBACL,GAAG,MAAM;gBACT,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { Factory } from './factory';\nimport type { Path, TermIri } from './RoundTripTypes';\nimport type { SparqlContext } from './Sparql11types';\n\ninterface Parser<ParseRet> {\n queryOrUpdate: (input: string, context: SparqlContext, arg: undefined) => ParseRet;\n path: (input: string, context: SparqlContext, arg: undefined) => TermIri | Path;\n}\n\nexport function completeParseContext(\n context: Partial<SparqlContext & { origSource: string; offset?: number }>,\n): SparqlContext & { origSource: string; offset?: number } {\n return {\n factory: context.factory ?? new Factory(),\n baseIRI: context.baseIRI,\n prefixes: { ...context.prefixes },\n origSource: context.origSource ?? '',\n offset: context.offset,\n parseMode: context.parseMode ? new Set(context.parseMode) : new Set([ 'canParseVars', 'canCreateBlankNodes' ]),\n skipValidation: context.skipValidation ?? false,\n };\n}\n\nexport class SparqlParser<ParseRet> {\n public constructor(private readonly parser: Parser<ParseRet>) {}\n private readonly F = new Factory();\n\n public parse(query: string, context: Partial<SparqlContext> = {}): ParseRet {\n return this.parser.queryOrUpdate(query, completeParseContext(context), undefined);\n }\n\n public parsePath(query: string, context: Partial<SparqlContext> = {}):\n (Path & { prefixes: object }) | TermIri {\n const result = this.parser.path(query, completeParseContext(context), undefined);\n if (this.F.isPathPure(result)) {\n return {\n ...result,\n prefixes: {},\n };\n }\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"SparqlParser.js","sourceRoot":"","sources":["SparqlParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,MAAM,UAAU,oBAAoB,CAClC,OAAyE;IAEzE,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI,OAAO,EAAE;QACzC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE;QACjC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAE,cAAc,EAAE,qBAAqB,CAAE,CAAC;QAC9G,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,KAAK;KAChD,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,YAAY;IACvB,YAAoC,MAAwB;QAAxB,WAAM,GAAN,MAAM,CAAkB;QAC3C,MAAC,GAAG,IAAI,OAAO,EAAE,CAAC;IAD4B,CAAC;IAGzD,KAAK,CAAC,KAAa,EAAE,UAAkC,EAAE;QAC9D,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IACzE,CAAC;IAEM,SAAS,CAAC,KAAa,EAAE,UAAkC,EAAE;QAElE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;QACtE,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,OAAO;gBACL,GAAG,MAAM;gBACT,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { Factory } from './factory';\nimport type { SparqlContext } from './sparql11HelperTypes';\nimport type { Path, TermIri } from './Sparql11types';\n\ninterface Parser<ParseRet> {\n queryOrUpdate: (input: string, context: SparqlContext) => ParseRet;\n path: (input: string, context: SparqlContext) => TermIri | Path;\n}\n\nexport function completeParseContext(\n context: Partial<SparqlContext & { origSource: string; offset?: number }>,\n): SparqlContext & { origSource: string; offset?: number } {\n return {\n factory: context.factory ?? new Factory(),\n baseIRI: context.baseIRI,\n prefixes: { ...context.prefixes },\n origSource: context.origSource ?? '',\n offset: context.offset,\n parseMode: context.parseMode ? new Set(context.parseMode) : new Set([ 'canParseVars', 'canCreateBlankNodes' ]),\n skipValidation: context.skipValidation ?? false,\n };\n}\n\nexport class SparqlParser<ParseRet> {\n public constructor(private readonly parser: Parser<ParseRet>) {}\n private readonly F = new Factory();\n\n public parse(query: string, context: Partial<SparqlContext> = {}): ParseRet {\n return this.parser.queryOrUpdate(query, completeParseContext(context));\n }\n\n public parsePath(query: string, context: Partial<SparqlContext> = {}):\n (Path & { prefixes: object }) | TermIri {\n const result = this.parser.path(query, completeParseContext(context));\n if (this.F.isPathPure(result)) {\n return {\n ...result,\n prefixes: {},\n };\n }\n return result;\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { TokenType } from 'chevrotain';
2
- import type { Expression, ExpressionAggregateDefault, ExpressionOperation, ExpressionPatternOperation, TermVariable } from './RoundTripTypes';
3
- import type { SparqlGrammarRule } from './Sparql11types';
2
+ import type { SparqlGrammarRule } from './sparql11HelperTypes';
3
+ import type { Expression, ExpressionAggregateDefault, ExpressionOperation, ExpressionPatternOperation, TermVariable } from './Sparql11types';
4
4
  export type ExpressionFunctionX<U extends Expression[]> = ExpressionOperation & {
5
5
  args: U;
6
6
  };