@traqula/rules-sparql-1-1 0.0.15 → 0.0.17
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.
- package/lib/MinimalSparqlParser.d.ts +3 -3
- package/lib/MinimalSparqlParser.js +6 -3
- package/lib/MinimalSparqlParser.js.map +1 -1
- package/lib/Sparql11types.d.ts +1 -1
- package/lib/Sparql11types.js.map +1 -1
- package/lib/{factory.d.ts → astFactory.d.ts} +4 -4
- package/lib/{factory.js → astFactory.js} +3 -3
- package/lib/astFactory.js.map +1 -0
- package/lib/expressionHelpers.js +12 -12
- package/lib/expressionHelpers.js.map +1 -1
- package/lib/factoryMixins/ContextFactory.d.ts +2 -2
- package/lib/factoryMixins/ContextFactory.js.map +1 -1
- package/lib/factoryMixins/ExpressionFactory.d.ts +2 -2
- package/lib/factoryMixins/ExpressionFactory.js.map +1 -1
- package/lib/factoryMixins/GraphRefFactory.d.ts +2 -2
- package/lib/factoryMixins/GraphRefFactory.js.map +1 -1
- package/lib/factoryMixins/PathFactory.d.ts +2 -2
- package/lib/factoryMixins/PathFactory.js.map +1 -1
- package/lib/factoryMixins/Patternfactory.d.ts +2 -2
- package/lib/factoryMixins/Patternfactory.js.map +1 -1
- package/lib/factoryMixins/QueryFactory.d.ts +2 -2
- package/lib/factoryMixins/QueryFactory.js.map +1 -1
- package/lib/factoryMixins/SolutionModifiersFactory.d.ts +2 -2
- package/lib/factoryMixins/SolutionModifiersFactory.js.map +1 -1
- package/lib/factoryMixins/TermFactory.d.ts +2 -2
- package/lib/factoryMixins/TermFactory.js.map +1 -1
- package/lib/factoryMixins/UpdateOperationFactory.d.ts +2 -2
- package/lib/factoryMixins/UpdateOperationFactory.js.map +1 -1
- package/lib/grammar/builtIn.d.ts +1 -1
- package/lib/grammar/builtIn.js +7 -7
- package/lib/grammar/builtIn.js.map +1 -1
- package/lib/grammar/dataSetClause.js +6 -6
- package/lib/grammar/dataSetClause.js.map +1 -1
- package/lib/grammar/expression.js +18 -18
- package/lib/grammar/expression.js.map +1 -1
- package/lib/grammar/general.js +12 -10
- package/lib/grammar/general.js.map +1 -1
- package/lib/grammar/index.js +3 -3
- package/lib/grammar/index.js.map +1 -1
- package/lib/grammar/literals.js +24 -24
- package/lib/grammar/literals.js.map +1 -1
- package/lib/grammar/propertyPaths.d.ts +2 -2
- package/lib/grammar/propertyPaths.js +7 -7
- package/lib/grammar/propertyPaths.js.map +1 -1
- package/lib/grammar/queryUnit.js +31 -23
- package/lib/grammar/queryUnit.js.map +1 -1
- package/lib/grammar/solutionModifier.js +26 -16
- package/lib/grammar/solutionModifier.js.map +1 -1
- package/lib/grammar/tripleBlock.d.ts +4 -4
- package/lib/grammar/tripleBlock.js +33 -20
- package/lib/grammar/tripleBlock.js.map +1 -1
- package/lib/grammar/updateUnit.js +75 -41
- package/lib/grammar/updateUnit.js.map +1 -1
- package/lib/grammar/whereClause.d.ts +1 -1
- package/lib/grammar/whereClause.js +46 -32
- package/lib/grammar/whereClause.js.map +1 -1
- package/lib/index.cjs +568 -383
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/lexer/BuiltInCalls.d.ts +1 -1
- package/lib/lexer/lexer.d.ts +2 -2
- package/lib/lexer/symbols.d.ts +1 -1
- package/lib/lexer/terminals.d.ts +1 -1
- package/lib/sparql11HelperTypes.d.ts +9 -6
- package/lib/sparql11HelperTypes.js.map +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/lib/validation/validators.js +63 -81
- package/lib/validation/validators.js.map +1 -1
- package/package.json +3 -3
- package/lib/factory.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { SparqlContext } from './sparql11HelperTypes.js';
|
|
1
|
+
import type { SparqlContext, SparqlGeneratorContext } from './sparql11HelperTypes.js';
|
|
2
2
|
import type { Path, TermIri } from './Sparql11types.js';
|
|
3
3
|
interface Parser<ParseRet> {
|
|
4
4
|
queryOrUpdate: (input: string, context: SparqlContext) => ParseRet;
|
|
5
5
|
path: (input: string, context: SparqlContext) => TermIri | Path;
|
|
6
6
|
}
|
|
7
|
-
export declare function completeParseContext(context: Partial<SparqlContext & {
|
|
7
|
+
export declare function completeParseContext(context: Partial<SparqlContext & SparqlGeneratorContext & {
|
|
8
8
|
origSource: string;
|
|
9
9
|
offset?: number;
|
|
10
|
-
}>): SparqlContext & {
|
|
10
|
+
}>): SparqlContext & SparqlGeneratorContext & {
|
|
11
11
|
origSource: string;
|
|
12
12
|
offset?: number;
|
|
13
13
|
};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { traqulaIndentation } from '@traqula/core';
|
|
2
|
+
import { AstFactory } from './astFactory.js';
|
|
2
3
|
export function completeParseContext(context) {
|
|
3
4
|
return {
|
|
4
|
-
|
|
5
|
+
astFactory: context.astFactory ?? new AstFactory(),
|
|
5
6
|
baseIRI: context.baseIRI,
|
|
6
7
|
prefixes: { ...context.prefixes },
|
|
7
8
|
origSource: context.origSource ?? '',
|
|
8
9
|
offset: context.offset,
|
|
9
10
|
parseMode: context.parseMode ? new Set(context.parseMode) : new Set(['canParseVars', 'canCreateBlankNodes']),
|
|
10
11
|
skipValidation: context.skipValidation ?? false,
|
|
12
|
+
[traqulaIndentation]: context[traqulaIndentation] ?? 0,
|
|
13
|
+
indentInc: context.indentInc ?? 2,
|
|
11
14
|
};
|
|
12
15
|
}
|
|
13
16
|
export class MinimalSparqlParser {
|
|
@@ -15,7 +18,7 @@ export class MinimalSparqlParser {
|
|
|
15
18
|
constructor(parser) {
|
|
16
19
|
this.parser = parser;
|
|
17
20
|
}
|
|
18
|
-
F = new
|
|
21
|
+
F = new AstFactory();
|
|
19
22
|
parse(query, context = {}) {
|
|
20
23
|
return this.parser.queryOrUpdate(query, completeParseContext(context));
|
|
21
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MinimalSparqlParser.js","sourceRoot":"","sources":["MinimalSparqlParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"MinimalSparqlParser.js","sourceRoot":"","sources":["MinimalSparqlParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAS7C,MAAM,UAAU,oBAAoB,CAClC,OAAkG;IAElG,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI,UAAU,EAAE;QAClD,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;QAC/C,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC;QACtD,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC;KAClC,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,mBAAmB;IACM;IAApC,YAAoC,MAAwB;QAAxB,WAAM,GAAN,MAAM,CAAkB;IAAG,CAAC;IAC/C,CAAC,GAAG,IAAI,UAAU,EAAE,CAAC;IAE/B,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 { traqulaIndentation } from '@traqula/core';\nimport { AstFactory } from './astFactory.js';\nimport type { SparqlContext, SparqlGeneratorContext } from './sparql11HelperTypes.js';\nimport type { Path, TermIri } from './Sparql11types.js';\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 & SparqlGeneratorContext & { origSource: string; offset?: number }>,\n): SparqlContext & SparqlGeneratorContext & { origSource: string; offset?: number } {\n return {\n astFactory: context.astFactory ?? new AstFactory(),\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 [traqulaIndentation]: context[traqulaIndentation] ?? 0,\n indentInc: context.indentInc ?? 2,\n };\n}\n\nexport class MinimalSparqlParser<ParseRet> {\n public constructor(private readonly parser: Parser<ParseRet>) {}\n private readonly F = new AstFactory();\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"]}
|
package/lib/Sparql11types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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;
|
|
2
|
+
export type Sparql11Nodes = GraphRef | GraphQuads | UpdateOperation | Update | Query | DatasetClauses | TripleCollection | TripleNesting | Pattern | SolutionModifier | Expression | Path | ContextDefinition | Wildcard | Term;
|
|
3
3
|
export type GraphRefBase = Node & {
|
|
4
4
|
type: 'graphRef';
|
|
5
5
|
subType: string;
|
package/lib/Sparql11types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
+
{"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 | GraphQuads\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,7 +1,7 @@
|
|
|
1
1
|
import type { SourceLocation, SubTyped, Typed } from '@traqula/core';
|
|
2
|
-
import {
|
|
2
|
+
import { AstCoreFactory } from '@traqula/core';
|
|
3
3
|
import type { DatasetClauses, GraphNode, GraphQuads, PatternBgp, Sparql11Nodes, Term, TermBlank, TermIri, TermVariable, TripleCollectionBlankNodeProperties, TripleCollectionList, TripleNesting, Update, Wildcard } from './Sparql11types.js';
|
|
4
|
-
declare const
|
|
4
|
+
declare const AstFactory_base: {
|
|
5
5
|
new (...args: any[]): {
|
|
6
6
|
isUpdateOperation(obj: object): obj is Typed<"updateOperation">;
|
|
7
7
|
updateOperationLoad(loc: SourceLocation, source: TermIri, silent: boolean, destination?: import("./Sparql11types.js").GraphRefSpecific | undefined): import("./Sparql11types.js").UpdateOperationLoad;
|
|
@@ -423,8 +423,8 @@ declare const Factory_base: {
|
|
|
423
423
|
isOfType<Type extends string>(obj: object, type: Type): obj is Typed<Type>;
|
|
424
424
|
isOfSubType<Type extends string, SubType extends string>(obj: object, type: Type, subType: SubType): obj is SubTyped<Type, SubType>;
|
|
425
425
|
};
|
|
426
|
-
} & typeof
|
|
427
|
-
export declare class
|
|
426
|
+
} & typeof AstCoreFactory;
|
|
427
|
+
export declare class AstFactory extends AstFactory_base {
|
|
428
428
|
alwaysSparql11(obj: object): obj is Sparql11Nodes;
|
|
429
429
|
isPath(obj: object): obj is SubTyped<'term', 'namedNode'> | Typed<'path'>;
|
|
430
430
|
isExpression(obj: object): obj is SubTyped<'term', 'namedNode' | 'variable' | 'literal'> | Typed<'expression'>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AstCoreFactory } from '@traqula/core';
|
|
2
2
|
import { ContextFactoryMixin } from './factoryMixins/ContextFactory.js';
|
|
3
3
|
import { ExpressionFactoryMixin } from './factoryMixins/ExpressionFactory.js';
|
|
4
4
|
import { GraphRefFactoryMixin } from './factoryMixins/GraphRefFactory.js';
|
|
@@ -9,7 +9,7 @@ import { QueryFactoryMixin } from './factoryMixins/QueryFactory.js';
|
|
|
9
9
|
import { SolutionModifiersFactoryMixin } from './factoryMixins/SolutionModifiersFactory.js';
|
|
10
10
|
import { TermFactoryMixin } from './factoryMixins/TermFactory.js';
|
|
11
11
|
import { UpdateOperationFactoryMixin } from './factoryMixins/UpdateOperationFactory.js';
|
|
12
|
-
export class
|
|
12
|
+
export class AstFactory extends asArg(AstCoreFactory)
|
|
13
13
|
.call(ContextFactoryMixin)
|
|
14
14
|
.call(ExpressionFactoryMixin)
|
|
15
15
|
.call(GraphRefFactoryMixin)
|
|
@@ -102,4 +102,4 @@ export class Factory extends asArg(CoreFactory)
|
|
|
102
102
|
return super.isOfType(obj, 'update');
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
//# sourceMappingURL=
|
|
105
|
+
//# sourceMappingURL=astFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astFactory.js","sourceRoot":"","sources":["astFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AAkBxF,MAAM,OAAO,UAAW,SAAQ,KAAK,CAAC,cAAc,CAAC;KAClD,IAAI,CAAC,mBAAmB,CAAC;KACzB,IAAI,CAAC,sBAAsB,CAAC;KAC5B,IAAI,CAAC,oBAAoB,CAAC;KAC1B,IAAI,CAAC,gBAAgB,CAAC;KACtB,IAAI,CAAC,mBAAmB,CAAC;KACzB,IAAI,CAAC,iBAAiB,CAAC;KACvB,IAAI,CAAC,6BAA6B,CAAC;KACnC,IAAI,CAAC,gBAAgB,CAAC;KACtB,IAAI,CAAC,2BAA2B,CAAC;KACjC,OAAO,EAAE;IACH,cAAc,CAAC,GAAW;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,GAAW;QACvB,OAAO,IAAI,CAA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CAAC;IACxC,CAAC;IAEM,kBAAkB,CAAC,GAAW;QACnC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IAChD,CAAC;IAEM,mCAAmC,CACxC,UAAqB,EACrB,OAAwB,EACxB,GAAmB;QAEnB,OAAO;YACL,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE,qBAAqB;YAC9B,UAAU;YACV,OAAO;YACP,GAAG;SACJ,CAAC;IACJ,CAAC;IAEM,qCAAqC,CAAC,GAAW;QAEtD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;IAC1E,CAAC;IAEM,oBAAoB,CACzB,UAAqB,EACrB,OAAwB,EACxB,GAAmB;QAEnB,OAAO;YACL,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE,MAAM;YACf,UAAU;YACV,OAAO;YACP,GAAG;SACJ,CAAC;IACJ,CAAC;IAEM,sBAAsB,CAAC,GAAW;QAEvC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IAEM,UAAU,CAAC,KAA6B,EAAE,OAAmB,EAAE,GAAmB;QACvF,OAAO;YACL,IAAI,EAAE,OAAO;YACb,KAAK;YACL,OAAO;YACP,GAAG;SACJ,CAAC;IACJ,CAAC;IAEM,YAAY,CAAC,GAAW;QAC7B,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAEM,QAAQ,CAAC,GAAW;QACzB,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;CACF","sourcesContent":["import type { SourceLocation, SubTyped, Typed } from '@traqula/core';\nimport { AstCoreFactory } from '@traqula/core';\nimport { ContextFactoryMixin } from './factoryMixins/ContextFactory.js';\nimport { ExpressionFactoryMixin } from './factoryMixins/ExpressionFactory.js';\nimport { GraphRefFactoryMixin } from './factoryMixins/GraphRefFactory.js';\nimport { asArg } from './factoryMixins/mixins.js';\nimport { PathFactoryMixin } from './factoryMixins/PathFactory.js';\nimport { PatternFactoryMixin } from './factoryMixins/Patternfactory.js';\nimport { QueryFactoryMixin } from './factoryMixins/QueryFactory.js';\nimport { SolutionModifiersFactoryMixin } from './factoryMixins/SolutionModifiersFactory.js';\nimport { TermFactoryMixin } from './factoryMixins/TermFactory.js';\nimport { UpdateOperationFactoryMixin } from './factoryMixins/UpdateOperationFactory.js';\nimport type {\n DatasetClauses,\n GraphNode,\n GraphQuads,\n PatternBgp,\n Sparql11Nodes,\n Term,\n TermBlank,\n TermIri,\n TermVariable,\n TripleCollectionBlankNodeProperties,\n TripleCollectionList,\n TripleNesting,\n Update,\n Wildcard,\n} from './Sparql11types.js';\n\nexport class AstFactory extends asArg(AstCoreFactory)\n .call(ContextFactoryMixin)\n .call(ExpressionFactoryMixin)\n .call(GraphRefFactoryMixin)\n .call(PathFactoryMixin)\n .call(PatternFactoryMixin)\n .call(QueryFactoryMixin)\n .call(SolutionModifiersFactoryMixin)\n .call(TermFactoryMixin)\n .call(UpdateOperationFactoryMixin)\n .returns() {\n public alwaysSparql11(obj: object): obj is Sparql11Nodes {\n return true;\n }\n\n public isPath(obj: object): obj is SubTyped<'term', 'namedNode'> | Typed<'path'> {\n return this.isPathPure(obj) || this.isTermNamed(obj);\n }\n\n public isExpression(obj: object):\n obj is SubTyped<'term', 'namedNode' | 'variable' | 'literal'> | Typed<'expression'> {\n return this.isExpressionPure(obj) || this.isTermNamed(obj) || this.isTermVariable(obj) || this.isTermLiteral(obj);\n }\n\n public graphNodeIdentifier(graphNode: GraphNode): Term {\n return graphNode.type === 'tripleCollection' ? graphNode.identifier : graphNode;\n }\n\n public triple(\n subject: TripleNesting['subject'],\n predicate: TripleNesting['predicate'],\n object: TripleNesting['object'],\n loc?: SourceLocation,\n ): TripleNesting {\n return {\n type: 'triple',\n subject,\n predicate,\n object,\n loc: loc ?? this.sourceLocation(subject, predicate, object),\n };\n }\n\n public isTriple(obj: object): obj is Typed<'triple'> {\n return this.isOfType(obj, 'triple');\n }\n\n public datasetClauses(clauses: DatasetClauses['clauses'], loc: SourceLocation): DatasetClauses {\n return {\n type: 'datasetClauses',\n clauses,\n loc,\n };\n }\n\n public isDatasetClauses(obj: object): obj is Typed<'datasetClauses'> {\n return this.isOfType(obj, 'datasetClauses');\n }\n\n public wildcard(loc: SourceLocation): Wildcard {\n return { type: 'wildcard', loc };\n }\n\n public isWildcard(obj: object): obj is Typed<'wildcard'> {\n return this.isOfType(obj, 'wildcard');\n }\n\n public isTripleCollection(obj: object): obj is Typed<'tripleCollection'> {\n return this.isOfType(obj, 'tripleCollection');\n }\n\n public tripleCollectionBlankNodeProperties(\n identifier: TermBlank,\n triples: TripleNesting[],\n loc: SourceLocation,\n ): TripleCollectionBlankNodeProperties {\n return {\n type: 'tripleCollection',\n subType: 'blankNodeProperties',\n identifier,\n triples,\n loc,\n };\n }\n\n public isTripleCollectionBlankNodeProperties(obj: object):\n obj is SubTyped<'tripleCollection', 'blankNodeProperties'> {\n return this.isOfSubType(obj, 'tripleCollection', 'blankNodeProperties');\n }\n\n public tripleCollectionList(\n identifier: TermBlank,\n triples: TripleNesting[],\n loc: SourceLocation,\n ): TripleCollectionList {\n return {\n type: 'tripleCollection',\n subType: 'list',\n identifier,\n triples,\n loc,\n };\n }\n\n public isTripleCollectionList(obj: object):\n obj is SubTyped<'tripleCollection', 'list'> {\n return this.isOfSubType(obj, 'tripleCollection', 'list');\n }\n\n public graphQuads(graph: TermIri | TermVariable, triples: PatternBgp, loc: SourceLocation): GraphQuads {\n return {\n type: 'graph',\n graph,\n triples,\n loc,\n };\n }\n\n public isGraphQuads(obj: object): obj is GraphQuads {\n return super.isOfType(obj, 'graph');\n }\n\n public isUpdate(obj: object): obj is Update {\n return super.isOfType(obj, 'update');\n }\n}\n"]}
|
package/lib/expressionHelpers.js
CHANGED
|
@@ -9,7 +9,7 @@ export function funcExpr1(func) {
|
|
|
9
9
|
CONSUME(l.symbols.LParen);
|
|
10
10
|
const arg = SUBRULE(expression);
|
|
11
11
|
const close = CONSUME(l.symbols.RParen);
|
|
12
|
-
return ACTION(() => C.
|
|
12
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg], C.astFactory.sourceLocation(operator, close)));
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -23,7 +23,7 @@ export function funcExpr2(func) {
|
|
|
23
23
|
CONSUME(l.symbols.comma);
|
|
24
24
|
const arg2 = SUBRULE2(expression);
|
|
25
25
|
const close = CONSUME(l.symbols.RParen);
|
|
26
|
-
return ACTION(() => C.
|
|
26
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg1, arg2], C.astFactory.sourceLocation(operator, close)));
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
29
|
}
|
|
@@ -39,7 +39,7 @@ export function funcExpr3(func) {
|
|
|
39
39
|
CONSUME2(l.symbols.comma);
|
|
40
40
|
const arg3 = SUBRULE3(expression);
|
|
41
41
|
const close = CONSUME(l.symbols.RParen);
|
|
42
|
-
return ACTION(() => C.
|
|
42
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg1, arg2, arg3], C.astFactory.sourceLocation(operator, close)));
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
45
|
}
|
|
@@ -51,7 +51,7 @@ export function funcVar1(func) {
|
|
|
51
51
|
CONSUME(l.symbols.LParen);
|
|
52
52
|
const arg = SUBRULE(var_);
|
|
53
53
|
const close = CONSUME(l.symbols.RParen);
|
|
54
|
-
return ACTION(() => C.
|
|
54
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg], C.astFactory.sourceLocation(operator, close)));
|
|
55
55
|
},
|
|
56
56
|
};
|
|
57
57
|
}
|
|
@@ -65,11 +65,11 @@ export function funcExprOrNil1(func) {
|
|
|
65
65
|
CONSUME(l.symbols.LParen);
|
|
66
66
|
const arg = SUBRULE(expression);
|
|
67
67
|
const close = CONSUME(l.symbols.RParen);
|
|
68
|
-
return ACTION(() => C.
|
|
68
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg], C.astFactory.sourceLocation(operator, close)));
|
|
69
69
|
} },
|
|
70
70
|
{ ALT: () => {
|
|
71
71
|
const nil = CONSUME(l.terminals.nil);
|
|
72
|
-
return ACTION(() => C.
|
|
72
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [], C.astFactory.sourceLocation(operator, nil)));
|
|
73
73
|
} },
|
|
74
74
|
]);
|
|
75
75
|
},
|
|
@@ -81,7 +81,7 @@ export function funcNil1(func) {
|
|
|
81
81
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
82
82
|
const operator = CONSUME(func);
|
|
83
83
|
const nil = CONSUME(l.terminals.nil);
|
|
84
|
-
return ACTION(() => C.
|
|
84
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [], C.astFactory.sourceLocation(operator, nil)));
|
|
85
85
|
},
|
|
86
86
|
};
|
|
87
87
|
}
|
|
@@ -91,7 +91,7 @@ export function funcExprList1(func) {
|
|
|
91
91
|
impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
|
|
92
92
|
const operator = CONSUME(func);
|
|
93
93
|
const args = SUBRULE(expressionList);
|
|
94
|
-
return ACTION(() => C.
|
|
94
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, args.val, C.astFactory.sourceLocation(operator, args)));
|
|
95
95
|
},
|
|
96
96
|
};
|
|
97
97
|
}
|
|
@@ -109,7 +109,7 @@ export function funcExpr2or3(func) {
|
|
|
109
109
|
return SUBRULE3(expression);
|
|
110
110
|
});
|
|
111
111
|
const close = CONSUME(l.symbols.RParen);
|
|
112
|
-
return ACTION(() => C.
|
|
112
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, arg3 ? [arg1, arg2, arg3] : [arg1, arg2], C.astFactory.sourceLocation(operator, close)));
|
|
113
113
|
},
|
|
114
114
|
};
|
|
115
115
|
}
|
|
@@ -129,7 +129,7 @@ export function funcExpr3or4(func) {
|
|
|
129
129
|
return SUBRULE4(expression);
|
|
130
130
|
});
|
|
131
131
|
const close = CONSUME(l.symbols.RParen);
|
|
132
|
-
return ACTION(() => C.
|
|
132
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, arg4 ? [arg1, arg2, arg3, arg4] : [arg1, arg2, arg3], C.astFactory.sourceLocation(operator, close)));
|
|
133
133
|
},
|
|
134
134
|
};
|
|
135
135
|
}
|
|
@@ -139,7 +139,7 @@ export function funcGroupGraphPattern(func) {
|
|
|
139
139
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
140
140
|
const operator = CONSUME(func);
|
|
141
141
|
const group = SUBRULE(groupGraphPattern);
|
|
142
|
-
return ACTION(() => C.
|
|
142
|
+
return ACTION(() => C.astFactory.expressionPatternOperation(operator.image, group, C.astFactory.sourceLocation(operator, group)));
|
|
143
143
|
},
|
|
144
144
|
};
|
|
145
145
|
}
|
|
@@ -152,7 +152,7 @@ export function baseAggregateFunc(func) {
|
|
|
152
152
|
const distinct = OPTION(() => CONSUME(l.distinct));
|
|
153
153
|
const expr1 = SUBRULE(expression);
|
|
154
154
|
const close = CONSUME(l.symbols.RParen);
|
|
155
|
-
return ACTION(() => C.
|
|
155
|
+
return ACTION(() => C.astFactory.aggregate(operator.image, distinct !== undefined, expr1, undefined, C.astFactory.sourceLocation(operator, close)));
|
|
156
156
|
},
|
|
157
157
|
};
|
|
158
158
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expressionHelpers.js","sourceRoot":"","sources":["expressionHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,KAAK,CAAC,MAAM,kBAAk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,CAAC;KACF,CAAC;AACJ,CAAC;AAID,MAAM,UAAU,iBAAiB,CAAmB,IAA6B;IAE/E,OAAO;QACL,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;QAC7B,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;YACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;YAC/B,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnD,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;YAClC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAExC,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CACrC,QAAQ,CAAC,KAAK,EACd,QAAQ,KAAK,SAAS,EACtB,KAAK,EACL,SAAS,EACT,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAC1C,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { unCapitalize } from '@traqula/core';\nimport type { TokenType } from 'chevrotain';\nimport { var_, expression, expressionList, groupGraphPattern } from './grammar/index.js';\nimport * as l from './lexer/index.js';\nimport type { SparqlGrammarRule } from './sparql11HelperTypes.js';\nimport type {\n Expression,\n ExpressionAggregateDefault,\n ExpressionOperation,\n ExpressionPatternOperation,\n TermVariable,\n} from './Sparql11types.js';\n\nexport type ExpressionFunctionX<U extends Expression[]> = ExpressionOperation & {\n args: U;\n};\n\nexport type RuleDefExpressionFunctionX<T extends string, U extends Expression[]>\n = SparqlGrammarRule<T, ExpressionFunctionX<U>>;\n\nexport function funcExpr1<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [Expression]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg = SUBRULE(expression);\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() =>\n C.factory.expressionOperation(operator.image, [ arg ], C.factory.sourceLocation(operator, close)));\n },\n };\n}\n\nexport function funcExpr2<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [Expression, Expression]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg1 = SUBRULE1(expression);\n CONSUME(l.symbols.comma);\n const arg2 = SUBRULE2(expression);\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() =>\n C.factory.expressionOperation(operator.image, [ arg1, arg2 ], C.factory.sourceLocation(operator, close)));\n },\n };\n}\n\nexport function funcExpr3<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [Expression, Expression, Expression]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, CONSUME1, CONSUME2, SUBRULE1, SUBRULE2, SUBRULE3 }) => (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg1 = SUBRULE1(expression);\n CONSUME1(l.symbols.comma);\n const arg2 = SUBRULE2(expression);\n CONSUME2(l.symbols.comma);\n const arg3 = SUBRULE3(expression);\n const close = CONSUME(l.symbols.RParen);\n\n return ACTION(() =>\n C.factory.expressionOperation(operator.image, [ arg1, arg2, arg3 ], C.factory.sourceLocation(operator, close)));\n },\n };\n}\n\nexport function funcVar1<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [TermVariable]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg = SUBRULE(var_);\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() =>\n C.factory.expressionOperation(operator.image, [ arg ], C.factory.sourceLocation(operator, close)));\n },\n };\n}\n\nexport function funcExprOrNil1<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [] | [Expression]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {\n const operator = CONSUME(func);\n return OR<ExpressionFunctionX<[] | [Expression]>>([\n { ALT: () => {\n CONSUME(l.symbols.LParen);\n const arg = SUBRULE(expression);\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() =>\n C.factory.expressionOperation(operator.image, [ arg ], C.factory.sourceLocation(operator, close)));\n } },\n { ALT: () => {\n const nil = CONSUME(l.terminals.nil);\n return ACTION(() =>\n C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil)));\n } },\n ]);\n },\n };\n}\n\nexport function funcNil1<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, []> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME }) => (C) => {\n const operator = CONSUME(func);\n const nil = CONSUME(l.terminals.nil);\n return ACTION(() =>\n C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil)));\n },\n };\n}\n\nexport function funcExprList1<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, Expression[]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {\n const operator = CONSUME(func);\n const args = SUBRULE(expressionList);\n return ACTION(() =>\n C.factory.expressionOperation(operator.image, args.val, C.factory.sourceLocation(operator, args)));\n },\n };\n}\n\nexport function funcExpr2or3<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [Expression, Expression] | [Expression, Expression, Expression]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, CONSUME1, OPTION, CONSUME2 }) =>\n (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg1 = SUBRULE1(expression);\n CONSUME1(l.symbols.comma);\n const arg2 = SUBRULE2(expression);\n const arg3 = OPTION(() => {\n CONSUME2(l.symbols.comma);\n return SUBRULE3(expression);\n });\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() => C.factory.expressionOperation(\n operator.image,\n arg3 ? <const> [ arg1, arg2, arg3 ] : <const> [ arg1, arg2 ],\n C.factory.sourceLocation(operator, close),\n ));\n },\n };\n}\n\nexport function funcExpr3or4<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<\n Uncapitalize<T>,\n [Expression, Expression, Expression] | [Expression, Expression, Expression, Expression]\n> {\n return {\n name: unCapitalize(func.name),\n impl: ({\n ACTION,\n CONSUME,\n SUBRULE1,\n SUBRULE2,\n SUBRULE3,\n SUBRULE4,\n CONSUME1,\n OPTION,\n CONSUME2,\n CONSUME3,\n }) =>\n (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg1 = SUBRULE1(expression);\n CONSUME1(l.symbols.comma);\n const arg2 = SUBRULE2(expression);\n CONSUME2(l.symbols.comma);\n const arg3 = SUBRULE3(expression);\n const arg4 = OPTION(() => {\n CONSUME3(l.symbols.comma);\n return SUBRULE4(expression);\n });\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() => C.factory.expressionOperation(\n operator.image,\n arg4 ? <const> [ arg1, arg2, arg3, arg4 ] : <const> [ arg1, arg2, arg3 ],\n C.factory.sourceLocation(operator, close),\n ));\n },\n };\n}\n\nexport function funcGroupGraphPattern<T extends string>(func: TokenType & { name: T }):\nSparqlGrammarRule<Uncapitalize<T>, ExpressionPatternOperation> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {\n const operator = CONSUME(func);\n const group = SUBRULE(groupGraphPattern);\n return ACTION(() => C.factory.expressionPatternOperation(\n operator.image,\n group,\n C.factory.sourceLocation(operator, group),\n ));\n },\n };\n}\n\nexport type RuleDefExpressionAggregatorX<T extends string> = SparqlGrammarRule<T, ExpressionAggregateDefault>;\n\nexport function baseAggregateFunc<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionAggregatorX<Uncapitalize<T>> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const distinct = OPTION(() => CONSUME(l.distinct));\n const expr1 = SUBRULE(expression);\n const close = CONSUME(l.symbols.RParen);\n\n return ACTION(() => C.factory.aggregate(\n operator.image,\n distinct !== undefined,\n expr1,\n undefined,\n C.factory.sourceLocation(operator, close),\n ));\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"expressionHelpers.js","sourceRoot":"","sources":["expressionHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAC;AAiBtC,MAAM,UAAU,SAAS,CAAmB,IAA6B;IAEvE,OAAO;QACL,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;QAC7B,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;YAC5C,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;YAC/B,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAA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AAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnD,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;YAClC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAExC,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CACxC,QAAQ,CAAC,KAAK,EACd,QAAQ,KAAK,SAAS,EACtB,KAAK,EACL,SAAS,EACT,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAC7C,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { unCapitalize } from '@traqula/core';\nimport type { TokenType } from 'chevrotain';\nimport { var_, expression, expressionList, groupGraphPattern } from './grammar/index.js';\nimport * as l from './lexer/index.js';\nimport type { SparqlGrammarRule } from './sparql11HelperTypes.js';\nimport type {\n Expression,\n ExpressionAggregateDefault,\n ExpressionOperation,\n ExpressionPatternOperation,\n TermVariable,\n} from './Sparql11types.js';\n\nexport type ExpressionFunctionX<U extends Expression[]> = ExpressionOperation & {\n args: U;\n};\n\nexport type RuleDefExpressionFunctionX<T extends string, U extends Expression[]>\n = SparqlGrammarRule<T, ExpressionFunctionX<U>>;\n\nexport function funcExpr1<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [Expression]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg = SUBRULE(expression);\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() =>\n C.astFactory.expressionOperation(operator.image, [ arg ], C.astFactory.sourceLocation(operator, close)));\n },\n };\n}\n\nexport function funcExpr2<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [Expression, Expression]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg1 = SUBRULE1(expression);\n CONSUME(l.symbols.comma);\n const arg2 = SUBRULE2(expression);\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() =>\n C.astFactory.expressionOperation(operator.image, [ arg1, arg2 ], C.astFactory.sourceLocation(operator, close)));\n },\n };\n}\n\nexport function funcExpr3<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [Expression, Expression, Expression]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, CONSUME1, CONSUME2, SUBRULE1, SUBRULE2, SUBRULE3 }) => (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg1 = SUBRULE1(expression);\n CONSUME1(l.symbols.comma);\n const arg2 = SUBRULE2(expression);\n CONSUME2(l.symbols.comma);\n const arg3 = SUBRULE3(expression);\n const close = CONSUME(l.symbols.RParen);\n\n return ACTION(() =>\n C.astFactory.expressionOperation(\n operator.image,\n [ arg1, arg2, arg3 ],\n C.astFactory.sourceLocation(operator, close),\n ));\n },\n };\n}\n\nexport function funcVar1<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [TermVariable]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg = SUBRULE(var_);\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() =>\n C.astFactory.expressionOperation(operator.image, [ arg ], C.astFactory.sourceLocation(operator, close)));\n },\n };\n}\n\nexport function funcExprOrNil1<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [] | [Expression]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {\n const operator = CONSUME(func);\n return OR<ExpressionFunctionX<[] | [Expression]>>([\n { ALT: () => {\n CONSUME(l.symbols.LParen);\n const arg = SUBRULE(expression);\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() =>\n C.astFactory.expressionOperation(operator.image, [ arg ], C.astFactory.sourceLocation(operator, close)));\n } },\n { ALT: () => {\n const nil = CONSUME(l.terminals.nil);\n return ACTION(() =>\n C.astFactory.expressionOperation(operator.image, [], C.astFactory.sourceLocation(operator, nil)));\n } },\n ]);\n },\n };\n}\n\nexport function funcNil1<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, []> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME }) => (C) => {\n const operator = CONSUME(func);\n const nil = CONSUME(l.terminals.nil);\n return ACTION(() =>\n C.astFactory.expressionOperation(operator.image, [], C.astFactory.sourceLocation(operator, nil)));\n },\n };\n}\n\nexport function funcExprList1<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, Expression[]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {\n const operator = CONSUME(func);\n const args = SUBRULE(expressionList);\n return ACTION(() =>\n C.astFactory.expressionOperation(operator.image, args.val, C.astFactory.sourceLocation(operator, args)));\n },\n };\n}\n\nexport function funcExpr2or3<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<Uncapitalize<T>, [Expression, Expression] | [Expression, Expression, Expression]> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, CONSUME1, OPTION, CONSUME2 }) =>\n (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg1 = SUBRULE1(expression);\n CONSUME1(l.symbols.comma);\n const arg2 = SUBRULE2(expression);\n const arg3 = OPTION(() => {\n CONSUME2(l.symbols.comma);\n return SUBRULE3(expression);\n });\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() => C.astFactory.expressionOperation(\n operator.image,\n arg3 ? <const> [ arg1, arg2, arg3 ] : <const> [ arg1, arg2 ],\n C.astFactory.sourceLocation(operator, close),\n ));\n },\n };\n}\n\nexport function funcExpr3or4<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionFunctionX<\n Uncapitalize<T>,\n [Expression, Expression, Expression] | [Expression, Expression, Expression, Expression]\n> {\n return {\n name: unCapitalize(func.name),\n impl: ({\n ACTION,\n CONSUME,\n SUBRULE1,\n SUBRULE2,\n SUBRULE3,\n SUBRULE4,\n CONSUME1,\n OPTION,\n CONSUME2,\n CONSUME3,\n }) =>\n (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const arg1 = SUBRULE1(expression);\n CONSUME1(l.symbols.comma);\n const arg2 = SUBRULE2(expression);\n CONSUME2(l.symbols.comma);\n const arg3 = SUBRULE3(expression);\n const arg4 = OPTION(() => {\n CONSUME3(l.symbols.comma);\n return SUBRULE4(expression);\n });\n const close = CONSUME(l.symbols.RParen);\n return ACTION(() => C.astFactory.expressionOperation(\n operator.image,\n arg4 ? <const> [ arg1, arg2, arg3, arg4 ] : <const> [ arg1, arg2, arg3 ],\n C.astFactory.sourceLocation(operator, close),\n ));\n },\n };\n}\n\nexport function funcGroupGraphPattern<T extends string>(func: TokenType & { name: T }):\nSparqlGrammarRule<Uncapitalize<T>, ExpressionPatternOperation> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {\n const operator = CONSUME(func);\n const group = SUBRULE(groupGraphPattern);\n return ACTION(() => C.astFactory.expressionPatternOperation(\n operator.image,\n group,\n C.astFactory.sourceLocation(operator, group),\n ));\n },\n };\n}\n\nexport type RuleDefExpressionAggregatorX<T extends string> = SparqlGrammarRule<T, ExpressionAggregateDefault>;\n\nexport function baseAggregateFunc<T extends string>(func: TokenType & { name: T }):\nRuleDefExpressionAggregatorX<Uncapitalize<T>> {\n return {\n name: unCapitalize(func.name),\n impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {\n const operator = CONSUME(func);\n CONSUME(l.symbols.LParen);\n const distinct = OPTION(() => CONSUME(l.distinct));\n const expr1 = SUBRULE(expression);\n const close = CONSUME(l.symbols.RParen);\n\n return ACTION(() => C.astFactory.aggregate(\n operator.image,\n distinct !== undefined,\n expr1,\n undefined,\n C.astFactory.sourceLocation(operator, close),\n ));\n },\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AstCoreFactory, SubTyped, SourceLocation } from '@traqula/core';
|
|
2
2
|
import type { ContextDefinitionBase, ContextDefinitionPrefix, TermIriFull } from '../Sparql11types.js';
|
|
3
3
|
import type { Constructor } from './mixins.js';
|
|
4
4
|
type NodeType = 'contextDef';
|
|
5
|
-
export declare function ContextFactoryMixin<TBase extends Constructor<
|
|
5
|
+
export declare function ContextFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase): {
|
|
6
6
|
new (...args: any[]): {
|
|
7
7
|
contextDefinitionPrefix(loc: SourceLocation, key: string, value: TermIriFull): ContextDefinitionPrefix;
|
|
8
8
|
isContextDefinitionPrefix(contextDef: object): contextDef is SubTyped<NodeType, "prefix">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextFactory.js","sourceRoot":"","sources":["ContextFactory.ts"],"names":[],"mappings":"AASA,MAAM,QAAQ,GAAa,YAAY,CAAC;AAExC,4DAA4D;AAC5D,MAAM,UAAU,mBAAmB,
|
|
1
|
+
{"version":3,"file":"ContextFactory.js","sourceRoot":"","sources":["ContextFactory.ts"],"names":[],"mappings":"AASA,MAAM,QAAQ,GAAa,YAAY,CAAC;AAExC,4DAA4D;AAC5D,MAAM,UAAU,mBAAmB,CAA4C,IAAW;IACxF,OAAO,MAAM,cAAe,SAAQ,IAAI;QAC/B,uBAAuB,CAAC,GAAmB,EAAE,GAAW,EAAE,KAAkB;YACjF,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,QAAQ;gBACjB,GAAG;gBACH,KAAK;gBACL,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,yBAAyB,CAAC,UAAkB;YACjD,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC1D,CAAC;QAEM,qBAAqB,CAAC,GAAmB,EAAE,KAAkB;YAClE,OAAO;gBACL,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,MAAM;gBACf,KAAK;gBACL,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,uBAAuB,CAAC,UAAkB;YAC/C,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AstCoreFactory, SubTyped, SourceLocation } from '@traqula/core';\nimport type {\n ContextDefinitionBase,\n ContextDefinitionPrefix,\n TermIriFull,\n} from '../Sparql11types.js';\nimport type { Constructor } from './mixins.js';\n\ntype NodeType = 'contextDef';\nconst nodeType: NodeType = 'contextDef';\n\n// eslint-disable-next-line ts/explicit-function-return-type\nexport function ContextFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase) {\n return class ContextFactory extends Base {\n public contextDefinitionPrefix(loc: SourceLocation, key: string, value: TermIriFull): ContextDefinitionPrefix {\n return {\n type: nodeType,\n subType: 'prefix',\n key,\n value,\n loc,\n };\n }\n\n public isContextDefinitionPrefix(contextDef: object): contextDef is SubTyped<NodeType, 'prefix'> {\n return this.isOfSubType(contextDef, nodeType, 'prefix');\n }\n\n public contextDefinitionBase(loc: SourceLocation, value: TermIriFull): ContextDefinitionBase {\n return {\n type: 'contextDef',\n subType: 'base',\n value,\n loc,\n };\n }\n\n public isContextDefinitionBase(contextDef: object): contextDef is SubTyped<NodeType, 'base'> {\n return this.isOfSubType(contextDef, nodeType, 'base');\n }\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AstCoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';
|
|
2
2
|
import type { Expression, ExpressionAggregate, ExpressionAggregateDefault, ExpressionAggregateOnWildcard, ExpressionAggregateSeparator, ExpressionFunctionCall, ExpressionOperation, ExpressionPatternOperation, PatternGroup, TermIri, Wildcard } from '../Sparql11types.js';
|
|
3
3
|
import type { Constructor } from './mixins.js';
|
|
4
4
|
type NodeType = 'expression';
|
|
5
|
-
export declare function ExpressionFactoryMixin<TBase extends Constructor<
|
|
5
|
+
export declare function ExpressionFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase): {
|
|
6
6
|
new (...args: any[]): {
|
|
7
7
|
isExpressionPure(obj: object): obj is Typed<NodeType>;
|
|
8
8
|
formatOperator(operator: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionFactory.js","sourceRoot":"","sources":["ExpressionFactory.ts"],"names":[],"mappings":"AAiBA,MAAM,QAAQ,GAAa,YAAY,CAAC;AAExC,4DAA4D;AAC5D,MAAM,UAAU,sBAAsB,
|
|
1
|
+
{"version":3,"file":"ExpressionFactory.js","sourceRoot":"","sources":["ExpressionFactory.ts"],"names":[],"mappings":"AAiBA,MAAM,QAAQ,GAAa,YAAY,CAAC;AAExC,4DAA4D;AAC5D,MAAM,UAAU,sBAAsB,CAA4C,IAAW;IAC3F,OAAO,MAAM,iBAAkB,SAAQ,IAAI;QAClC,gBAAgB,CAAC,GAAW;YACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACtC,CAAC;QAEM,cAAc,CAAC,QAAgB;YACpC,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,EAA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AQ,EAAE,WAAW,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;gBACrF,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QACvF,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AstCoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';\nimport type {\n Expression,\n ExpressionAggregate,\n ExpressionAggregateDefault,\n ExpressionAggregateOnWildcard,\n ExpressionAggregateSeparator,\n ExpressionFunctionCall,\n ExpressionOperation,\n ExpressionPatternOperation,\n PatternGroup,\n TermIri,\n Wildcard,\n} from '../Sparql11types.js';\nimport type { Constructor } from './mixins.js';\n\ntype NodeType = 'expression';\nconst nodeType: NodeType = 'expression';\n\n// eslint-disable-next-line ts/explicit-function-return-type\nexport function ExpressionFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase) {\n return class ExpressionFactory extends Base {\n public isExpressionPure(obj: object): obj is Typed<NodeType> {\n return this.isOfType(obj, nodeType);\n }\n\n public formatOperator(operator: string): string {\n return operator.toLowerCase().replaceAll(' ', '');\n }\n\n public expressionOperation<Args extends Expression[]>(\n operator: string,\n args: Args,\n loc: SourceLocation,\n ): ExpressionOperation & { args: Args } {\n return {\n type: nodeType,\n subType: 'operation',\n operator: this.formatOperator(operator),\n args,\n loc,\n };\n }\n\n public isExpressionOperator(obj: object): obj is SubTyped<NodeType, 'operation'> {\n return this.isOfSubType(obj, nodeType, 'operation');\n }\n\n public expressionFunctionCall<Args extends Expression[]>(\n functionOp: TermIri,\n args: Args,\n distinct: boolean,\n loc: SourceLocation,\n ): ExpressionFunctionCall & { args: Args } {\n return {\n type: 'expression',\n subType: 'functionCall',\n function: functionOp,\n args,\n distinct,\n loc,\n };\n }\n\n public isExpressionFunctionCall(obj: object): obj is SubTyped<NodeType, 'functionCall'> {\n return this.isOfSubType(obj, nodeType, 'functionCall');\n }\n\n public expressionPatternOperation(\n operator: string,\n args: PatternGroup,\n loc: SourceLocation,\n ): ExpressionPatternOperation {\n return {\n type: nodeType,\n subType: 'patternOperation',\n operator: this.formatOperator(operator),\n args,\n loc,\n };\n }\n\n public isExpressionPatternOperation(obj: object): obj is SubTyped<NodeType, 'patternOperation'> {\n return this.isOfSubType(obj, nodeType, 'patternOperation');\n }\n\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression,\n separator: undefined,\n loc: SourceLocation\n ): ExpressionAggregateDefault;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Wildcard,\n separator: undefined,\n loc: SourceLocation\n ): ExpressionAggregateOnWildcard;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression,\n separator: string,\n loc: SourceLocation\n ): ExpressionAggregateSeparator;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression | Wildcard,\n separator: string | undefined,\n loc: SourceLocation,\n ): ExpressionAggregate;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression | Wildcard,\n separator: string | undefined,\n loc: SourceLocation,\n ): ExpressionAggregate {\n const base = <const> {\n type: 'expression',\n subType: 'aggregate',\n aggregation: this.formatOperator(aggregation),\n distinct,\n loc,\n };\n if (this.isOfType(arg, 'wildcard')) {\n return { ...base, expression: [ arg ]} satisfies ExpressionAggregateOnWildcard;\n }\n if (separator === undefined) {\n return { ...base, expression: [ arg ]} satisfies ExpressionAggregateDefault;\n }\n return { ...base, expression: [ arg ], separator } satisfies ExpressionAggregateSeparator;\n }\n\n public isExpressionAggregate(obj: object): obj is SubTyped<NodeType, 'aggregate'> {\n return this.isOfSubType(obj, nodeType, 'aggregate');\n }\n\n public isExpressionAggregateSeparator(obj: object): obj is SubTyped<NodeType, 'aggregate'> & { separator: string } {\n return this.isOfSubType(obj, nodeType, 'aggregate') &&\n typeof (<{ separator?: unknown }> obj).separator === 'string';\n }\n\n public isExpressionAggregateOnWildcard(obj: object):\n obj is SubTyped<NodeType, 'aggregate'> & { expression: [Typed<'wildcard'>]} {\n const casted = <{ expression?: unknown }> obj;\n return this.isOfSubType(obj, nodeType, 'aggregate') && Array.isArray(casted.expression) &&\n casted.expression.length === 1 && this.isOfType(casted.expression[0], 'wildcard');\n }\n\n public isExpressionAggregateDefault(obj: object):\n obj is SubTyped<NodeType, 'aggregate'> & { expression: [Expression]} {\n const casted = <{ expression?: unknown }> obj;\n\n return this.isOfSubType(obj, nodeType, 'operation') && Array.isArray(casted.expression) &&\n casted.expression.length === 1 && !this.isOfType(casted.expression[0], 'wildcard');\n }\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AstCoreFactory, SubTyped, SourceLocation, Typed } from '@traqula/core';
|
|
2
2
|
import type { GraphRefAll, GraphRefDefault, GraphRefNamed, GraphRefSpecific, TermIri } from '../Sparql11types.js';
|
|
3
3
|
import type { Constructor } from './mixins.js';
|
|
4
4
|
type NodeType = 'graphRef';
|
|
5
|
-
export declare function GraphRefFactoryMixin<TBase extends Constructor<
|
|
5
|
+
export declare function GraphRefFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase): {
|
|
6
6
|
new (...args: any[]): {
|
|
7
7
|
isGraphRef(obj: object): obj is Typed<NodeType>;
|
|
8
8
|
graphRefDefault(loc: SourceLocation): GraphRefDefault;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphRefFactory.js","sourceRoot":"","sources":["GraphRefFactory.ts"],"names":[],"mappings":"AAWA,MAAM,QAAQ,GAAa,UAAU,CAAC;AAEtC,4DAA4D;AAC5D,MAAM,UAAU,oBAAoB,
|
|
1
|
+
{"version":3,"file":"GraphRefFactory.js","sourceRoot":"","sources":["GraphRefFactory.ts"],"names":[],"mappings":"AAWA,MAAM,QAAQ,GAAa,UAAU,CAAC;AAEtC,4DAA4D;AAC5D,MAAM,UAAU,oB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@traqula/core';\nimport type {\n GraphRefAll,\n GraphRefDefault,\n GraphRefNamed,\n GraphRefSpecific,\n TermIri,\n} from '../Sparql11types.js';\nimport type { Constructor } from './mixins.js';\n\ntype NodeType = 'graphRef';\nconst nodeType: NodeType = 'graphRef';\n\n// eslint-disable-next-line ts/explicit-function-return-type\nexport function GraphRefFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase) {\n return class GraphRefFactory extends Base {\n public isGraphRef(obj: object): obj is Typed<NodeType> {\n return this.isOfType(obj, nodeType);\n }\n\n public graphRefDefault(loc: SourceLocation): GraphRefDefault {\n return {\n type: nodeType,\n subType: 'default',\n loc,\n };\n }\n\n public isGraphRefDefault(graphRef: object): graphRef is SubTyped<NodeType, 'default'> {\n return this.isOfSubType(graphRef, nodeType, 'default');\n }\n\n public graphRefNamed(loc: SourceLocation): GraphRefNamed {\n return {\n type: nodeType,\n subType: 'named',\n loc,\n };\n }\n\n public isGraphRefNamed(graphRef: object): graphRef is SubTyped<NodeType, 'named'> {\n return this.isOfSubType(graphRef, nodeType, 'named');\n }\n\n public graphRefAll(loc: SourceLocation): GraphRefAll {\n return {\n type: nodeType,\n subType: 'all',\n loc,\n };\n }\n\n public isGraphRefAll(graphRef: object): graphRef is SubTyped<NodeType, 'all'> {\n return this.isOfSubType(graphRef, nodeType, 'all');\n }\n\n public graphRefSpecific(graph: TermIri, loc: SourceLocation): GraphRefSpecific {\n return {\n type: nodeType,\n subType: 'specific',\n graph,\n loc,\n };\n }\n\n public isGraphRefSpecific(graphRef: object): graphRef is SubTyped<NodeType, 'specific'> {\n return this.isOfSubType(graphRef, nodeType, 'specific');\n }\n };\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AstCoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';
|
|
2
2
|
import type { Path, PathAlternativeLimited, PathModified, PathNegated, PathNegatedElt, PropertyPathChain, TermIri } from '../Sparql11types.js';
|
|
3
3
|
import type { Constructor } from './mixins.js';
|
|
4
4
|
type NodeType = 'path';
|
|
5
5
|
type RawNegatedElt = SubTyped<NodeType, '^'> & {
|
|
6
6
|
items: [SubTyped<'term', 'namedNode'>];
|
|
7
7
|
};
|
|
8
|
-
export declare function PathFactoryMixin<TBase extends Constructor<
|
|
8
|
+
export declare function PathFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase): {
|
|
9
9
|
new (...args: any[]): {
|
|
10
10
|
isPathPure(obj: object): obj is Typed<NodeType>;
|
|
11
11
|
path(subType: "|", items: (TermIri | PathNegatedElt)[], loc: SourceLocation): PathAlternativeLimited;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathFactory.js","sourceRoot":"","sources":["PathFactory.ts"],"names":[],"mappings":"AAaA,MAAM,QAAQ,GAAa,MAAM,CAAC;AAIlC,4DAA4D;AAC5D,MAAM,UAAU,gBAAgB,
|
|
1
|
+
{"version":3,"file":"PathFactory.js","sourceRoot":"","sources":["PathFactory.ts"],"names":[],"mappings":"AAaA,MAAM,QAAQ,GAAa,MAAM,CAAC;AAIlC,4DAA4D;AAC5D,MAAM,UAAU,gBAAgB,CAA4C,IAAW;IACrF,OAAO,MAAM,WAAY,SAAQ,IAAI;QAC5B,UAAU,CAAC,GAAW;YAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACtC,CAAC;QAgBM,IAAI,CACT,OAAoE,EACpE,KAAa,EACb,GAAmB;YAEnB,MAAM,IAAI,GAAU;gBAClB,IAAI,EAAE,QAAQ;gBACd,GAAG;gBACH,KAAK;aACN,CAAC;YACF,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;gBACvC,OAAO;oBACL,GAAG,IAAI;oBACP,OAAO;iBACoB,CAAC;YAChC,CAAC;YACD,IAAI,CAAC,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,GA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AC,CAAC;QACtF,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AstCoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';\nimport type {\n Path,\n PathAlternativeLimited,\n PathModified,\n PathNegated,\n PathNegatedElt,\n PropertyPathChain,\n TermIri,\n} from '../Sparql11types.js';\nimport type { Constructor } from './mixins.js';\n\ntype NodeType = 'path';\nconst nodeType: NodeType = 'path';\n\ntype RawNegatedElt = SubTyped<NodeType, '^'> & { items: [SubTyped<'term', 'namedNode'>]};\n\n// eslint-disable-next-line ts/explicit-function-return-type\nexport function PathFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase) {\n return class PathFactory extends Base {\n public isPathPure(obj: object): obj is Typed<NodeType> {\n return this.isOfType(obj, nodeType);\n }\n\n public path(\n subType: '|',\n items: (TermIri | PathNegatedElt)[],\n loc: SourceLocation\n ): PathAlternativeLimited;\n public path(\n subType: '!',\n items: [TermIri | PathNegatedElt | PathAlternativeLimited],\n loc: SourceLocation\n ): PathNegated;\n public path(subType: '^', items: [TermIri], loc: SourceLocation): PathNegatedElt;\n public path(subType: PathModified['subType'], item: [Path], loc: SourceLocation): PathModified;\n public path(subType: '|' | '/', items: Path[], loc: SourceLocation):\n PropertyPathChain;\n public path(\n subType: (PropertyPathChain | PathModified | PathNegated)['subType'],\n items: Path[],\n loc: SourceLocation,\n ): Path {\n const base = <const>{\n type: nodeType,\n loc,\n items,\n };\n if (subType === '|' || subType === '/') {\n return {\n ...base,\n subType,\n } satisfies PropertyPathChain;\n }\n if ((subType === '?' || subType === '*' || subType === '+' || subType === '^') && items.length === 1) {\n return {\n ...base,\n subType,\n items: <[Path]>items,\n } satisfies PathModified;\n }\n if (subType === '^' && items.length === 1 && !this.isPathPure(items[0])) {\n return {\n ...base,\n subType,\n items: <[TermIri]>items,\n } satisfies PathNegatedElt;\n }\n if (subType === '!' && items.length === 1 && (\n this.isPathAlternativeLimited(items[0]) || !this.isPathPure(items[0]) || this.isPathNegatedElt(items[0]))) {\n return {\n ...base,\n subType,\n items: <[TermIri | PathNegatedElt | PathAlternativeLimited]>items,\n } satisfies PathNegated;\n }\n throw new Error('Invalid path type');\n }\n\n public isPathOfType<T extends U[], U extends string>(obj: object, subTypes: T): obj is SubTyped<NodeType, U> {\n return this.isOfType(obj, nodeType) && subTypes.includes(<any>(<{ subType?: unknown }>obj).subType);\n }\n\n public isPathChain(obj: object): obj is SubTyped<NodeType, '|' | '/'> {\n return this.isOfSubType(obj, nodeType, '/') || this.isOfSubType(obj, nodeType, '|');\n }\n\n public isPathModified(obj: object): obj is SubTyped<NodeType, '?' | '*' | '+' | '^'> {\n return this.isOfSubType(obj, nodeType, '?') || this.isOfSubType(obj, nodeType, '*') ||\n this.isOfSubType(obj, nodeType, '+') || this.isOfSubType(obj, nodeType, '^');\n }\n\n public isPathNegatedElt(obj: object): obj is RawNegatedElt {\n const casted: { items?: unknown } = obj;\n return this.isOfSubType(obj, nodeType, '^') && Array.isArray(casted.items) && casted.items.length === 1 &&\n typeof casted.items[0] === 'object' && (casted.items[0] ?? false) && !this.isPathPure(casted.items[0]);\n }\n\n public isPathNegated(obj: object): obj is SubTyped<NodeType, '!'> {\n return this.isOfSubType(obj, nodeType, '!');\n }\n\n public isPathAlternativeLimited(obj: object):\n obj is SubTyped<NodeType, '|'> & { items: (SubTyped<'term', 'namedNode'> | RawNegatedElt)[] } {\n const casted: { items?: unknown } = obj;\n return this.isOfSubType(obj, nodeType, '|') && Array.isArray(casted.items) &&\n casted.items.every(item => !this.isPathPure(item) || this.isPathNegatedElt(item));\n }\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AstCoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';
|
|
2
2
|
import type { BasicGraphPattern, Expression, Pattern, PatternBgp, PatternBind, PatternFilter, PatternGraph, PatternGroup, PatternMinus, PatternOptional, PatternService, PatternUnion, PatternValues, TermIri, TermVariable, ValuePatternRow } from '../Sparql11types.js';
|
|
3
3
|
import type { Constructor } from './mixins.js';
|
|
4
4
|
type NodeType = 'pattern';
|
|
5
|
-
export declare function PatternFactoryMixin<TBase extends Constructor<
|
|
5
|
+
export declare function PatternFactoryMixin<TBase extends Constructor<AstCoreFactory>>(Base: TBase): {
|
|
6
6
|
new (...args: any[]): {
|
|
7
7
|
isPattern(obj: object): obj is Typed<NodeType>;
|
|
8
8
|
patternBgp(triples: BasicGraphPattern, loc: SourceLocation): PatternBgp;
|