@traqula/rules-sparql-1-1 1.0.1 → 1.0.3

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.
@@ -21,6 +21,7 @@ function completeGeneratorContext(context) {
21
21
  origSource: context.origSource ?? '',
22
22
  offset: context.offset,
23
23
  [core_1.traqulaIndentation]: context[core_1.traqulaIndentation] ?? 0,
24
+ [core_1.traqulaNewlineAlternative]: context[core_1.traqulaNewlineAlternative] ?? ' ',
24
25
  indentInc: context.indentInc ?? 2,
25
26
  };
26
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MinimalSparqlParser.js","sourceRoot":"","sources":["../../../lib/MinimalSparqlParser.ts"],"names":[],"mappings":";;;AAWA,oDAUC;AAED,4DAUC;AAED,4CASC;AA3CD,wCAAsE;AACtE,mDAA6C;AAS7C,SAAgB,oBAAoB,CAClC,OAA+B;IAE/B,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI,0BAAU,CAAC,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;QACjF,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE;QACjC,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,SAAgB,wBAAwB,CACtC,OAA8D;IAE9D,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI,0BAAU,EAAE;QAClD,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,CAAC,yBAAkB,CAAC,EAAE,OA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,CAAC,UAAU,CAAC,2BAA2B,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjH,IAAI,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACnD,OAAO;gBACL,GAAG,GAAG;gBACN,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAtCD,kDAsCC","sourcesContent":["import type { Localized } from '@traqula/core';\nimport { TransformerObject, 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>,\n): SparqlContext {\n return {\n astFactory: context.astFactory ?? new AstFactory({ tracksSourceLocation: false }),\n baseIRI: context.baseIRI,\n prefixes: { ...context.prefixes },\n parseMode: context.parseMode ? new Set(context.parseMode) : new Set([ 'canParseVars', 'canCreateBlankNodes' ]),\n skipValidation: context.skipValidation ?? false,\n };\n}\n\nexport function completeGeneratorContext(\n context: Partial<SparqlGeneratorContext & { offset?: number }>,\n): SparqlGeneratorContext & { offset?: number } {\n return {\n astFactory: context.astFactory ?? new AstFactory(),\n origSource: context.origSource ?? '',\n offset: context.offset,\n [traqulaIndentation]: context[traqulaIndentation] ?? 0,\n indentInc: context.indentInc ?? 2,\n };\n}\n\nexport function copyParseContext<T extends\nPartial<SparqlContext & SparqlGeneratorContext & { origSource: string; offset?: number }>>(\n context: T,\n): T {\n return {\n ...context,\n prefixes: { ...context.prefixes },\n parseMode: new Set(context.parseMode),\n };\n}\n\nexport class MinimalSparqlParser<ParseRet extends Localized> {\n protected readonly defaultContext: SparqlContext;\n protected readonly coreTransformer = new TransformerObject();\n\n public constructor(protected readonly parser: Parser<ParseRet>, defaultContext: Partial<SparqlContext> = {}) {\n this.defaultContext = completeParseContext(defaultContext);\n }\n\n /**\n * Parse a query string starting from the\n * [QueryUnit](https://www.w3.org/TR/sparql11-query/#rQueryUnit)\n * or [QueryUpdate](https://www.w3.org/TR/sparql11-query/#rUpdateUnit) rules.\n * @param query\n * @param context\n */\n public parse(query: string, context: Partial<SparqlContext> = {}): ParseRet {\n const ast = this.parser.queryOrUpdate(query, copyParseContext({ ...this.defaultContext, ...context }));\n ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);\n return ast;\n }\n\n /**\n * Parse a query string starting from the [Path](https://www.w3.org/TR/sparql11-query/#rPath) grammar rule.\n * @param query\n * @param context\n */\n public parsePath(query: string, context: Partial<SparqlContext> = {}):\n (Path & { prefixes: object }) | TermIri {\n const ast = this.parser.path(query, copyParseContext({ ...this.defaultContext, ...context }));\n ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);\n if (this.defaultContext.astFactory.isPathPure(ast)) {\n return {\n ...ast,\n prefixes: {},\n };\n }\n return ast;\n }\n}\n"]}
1
+ {"version":3,"file":"MinimalSparqlParser.js","sourceRoot":"","sources":["../../../lib/MinimalSparqlParser.ts"],"names":[],"mappings":";;;AAWA,oDAUC;AAED,4DAWC;AAED,4CASC;AA5CD,wCAAiG;AACjG,mDAA6C;AAS7C,SAAgB,oBAAoB,CAClC,OAA+B;IAE/B,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI,0BAAU,CAAC,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;QACjF,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE;QACjC,SAAS,EAAE,OAAO,CAAC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AAC,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC;QACvG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,2BAA2B,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjH,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,KAAa,EAAE,UAAkC,EAAE;QAElE,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC;QAC9F,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,2BAA2B,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjH,IAAI,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACnD,OAAO;gBACL,GAAG,GAAG;gBACN,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAtCD,kDAsCC","sourcesContent":["import type { Localized } from '@traqula/core';\nimport { traqulaNewlineAlternative, TransformerObject, 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>,\n): SparqlContext {\n return {\n astFactory: context.astFactory ?? new AstFactory({ tracksSourceLocation: false }),\n baseIRI: context.baseIRI,\n prefixes: { ...context.prefixes },\n parseMode: context.parseMode ? new Set(context.parseMode) : new Set([ 'canParseVars', 'canCreateBlankNodes' ]),\n skipValidation: context.skipValidation ?? false,\n };\n}\n\nexport function completeGeneratorContext(\n context: Partial<SparqlGeneratorContext & { offset?: number }>,\n): SparqlGeneratorContext & { offset?: number } {\n return {\n astFactory: context.astFactory ?? new AstFactory(),\n origSource: context.origSource ?? '',\n offset: context.offset,\n [traqulaIndentation]: context[traqulaIndentation] ?? 0,\n [traqulaNewlineAlternative]: context[traqulaNewlineAlternative] ?? ' ',\n indentInc: context.indentInc ?? 2,\n };\n}\n\nexport function copyParseContext<T extends\nPartial<SparqlContext & SparqlGeneratorContext & { origSource: string; offset?: number }>>(\n context: T,\n): T {\n return {\n ...context,\n prefixes: { ...context.prefixes },\n parseMode: new Set(context.parseMode),\n };\n}\n\nexport class MinimalSparqlParser<ParseRet extends Localized> {\n protected readonly defaultContext: SparqlContext;\n protected readonly coreTransformer = new TransformerObject();\n\n public constructor(protected readonly parser: Parser<ParseRet>, defaultContext: Partial<SparqlContext> = {}) {\n this.defaultContext = completeParseContext(defaultContext);\n }\n\n /**\n * Parse a query string starting from the\n * [QueryUnit](https://www.w3.org/TR/sparql11-query/#rQueryUnit)\n * or [QueryUpdate](https://www.w3.org/TR/sparql11-query/#rUpdateUnit) rules.\n * @param query\n * @param context\n */\n public parse(query: string, context: Partial<SparqlContext> = {}): ParseRet {\n const ast = this.parser.queryOrUpdate(query, copyParseContext({ ...this.defaultContext, ...context }));\n ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);\n return ast;\n }\n\n /**\n * Parse a query string starting from the [Path](https://www.w3.org/TR/sparql11-query/#rPath) grammar rule.\n * @param query\n * @param context\n */\n public parsePath(query: string, context: Partial<SparqlContext> = {}):\n (Path & { prefixes: object }) | TermIri {\n const ast = this.parser.path(query, copyParseContext({ ...this.defaultContext, ...context }));\n ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);\n if (this.defaultContext.astFactory.isPathPure(ast)) {\n return {\n ...ast,\n prefixes: {},\n };\n }\n return ast;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sparql11HelperTypes.js","sourceRoot":"","sources":["../../../lib/sparql11HelperTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { GeneratorRule, ParserRule, traqulaIndentation } from '@traqula/core';\nimport type { AstFactory } from './astFactory.js';\n\nexport interface SparqlContext {\n /**\n * Data-factoryMixins to be used when constructing rdf primitives.\n */\n astFactory: AstFactory;\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\nexport interface SparqlGeneratorContext {\n astFactory: AstFactory;\n indentInc: number;\n origSource: string;\n [traqulaIndentation]: number;\n}\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 extends any[] = [],\n> = SparqlGrammarRule<NameType, ReturnType, ParamType>\n & SparqlGeneratorRule<NameType, GenInputType, ParamType>;\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 extends any[] = [],\n> = GeneratorRule<SparqlGeneratorContext, NameType, ReturnType, ParamType>;\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 extends any[] = [],\n> = ParserRule<SparqlContext, NameType, ReturnType, ParamType>;\n"]}
1
+ {"version":3,"file":"sparql11HelperTypes.js","sourceRoot":"","sources":["../../../lib/sparql11HelperTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { GeneratorRule, ParserRule, traqulaIndentation, traqulaNewlineAlternative } from '@traqula/core';\nimport type { AstFactory } from './astFactory.js';\n\nexport interface SparqlContext {\n /**\n * Data-factoryMixins to be used when constructing rdf primitives.\n */\n astFactory: AstFactory;\n /**\n * Current scoped prefixes. Only used to validate parsed prefixes are known.\n */\n prefixes: Record<string, string>;\n /**\n * Currently scoped base IRI. Only used to validate a base is set when parsing.\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\nexport interface SparqlGeneratorContext {\n astFactory: AstFactory;\n indentInc: number;\n origSource: string;\n [traqulaIndentation]: number;\n [traqulaNewlineAlternative]: string;\n}\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 extends any[] = [],\n> = SparqlGrammarRule<NameType, ReturnType, ParamType>\n & SparqlGeneratorRule<NameType, GenInputType, ParamType>;\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 extends any[] = [],\n> = GeneratorRule<SparqlGeneratorContext, NameType, ReturnType, ParamType>;\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 extends any[] = [],\n> = ParserRule<SparqlContext, NameType, ReturnType, ParamType>;\n"]}
@@ -1,4 +1,4 @@
1
- import { TransformerObject, traqulaIndentation } from '@traqula/core';
1
+ import { traqulaNewlineAlternative, TransformerObject, traqulaIndentation } from '@traqula/core';
2
2
  import { AstFactory } from './astFactory.js';
3
3
  export function completeParseContext(context) {
4
4
  return {
@@ -15,6 +15,7 @@ export function completeGeneratorContext(context) {
15
15
  origSource: context.origSource ?? '',
16
16
  offset: context.offset,
17
17
  [traqulaIndentation]: context[traqulaIndentation] ?? 0,
18
+ [traqulaNewlineAlternative]: context[traqulaNewlineAlternative] ?? ' ',
18
19
  indentInc: context.indentInc ?? 2,
19
20
  };
20
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MinimalSparqlParser.js","sourceRoot":"","sources":["../../../lib/MinimalSparqlParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAS7C,MAAM,UAAU,oB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Ac,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,KAAa,EAAE,UAAkC,EAAE;QAC9D,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,gBAAgB,CAAC,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC;QACvG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,2BAA2B,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjH,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,KAAa,EAAE,UAAkC,EAAE;QAElE,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC;QAC9F,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,2BAA2B,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjH,IAAI,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACnD,OAAO;gBACL,GAAG,GAAG;gBACN,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["import type { Localized } from '@traqula/core';\nimport { TransformerObject, 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>,\n): SparqlContext {\n return {\n astFactory: context.astFactory ?? new AstFactory({ tracksSourceLocation: false }),\n baseIRI: context.baseIRI,\n prefixes: { ...context.prefixes },\n parseMode: context.parseMode ? new Set(context.parseMode) : new Set([ 'canParseVars', 'canCreateBlankNodes' ]),\n skipValidation: context.skipValidation ?? false,\n };\n}\n\nexport function completeGeneratorContext(\n context: Partial<SparqlGeneratorContext & { offset?: number }>,\n): SparqlGeneratorContext & { offset?: number } {\n return {\n astFactory: context.astFactory ?? new AstFactory(),\n origSource: context.origSource ?? '',\n offset: context.offset,\n [traqulaIndentation]: context[traqulaIndentation] ?? 0,\n indentInc: context.indentInc ?? 2,\n };\n}\n\nexport function copyParseContext<T extends\nPartial<SparqlContext & SparqlGeneratorContext & { origSource: string; offset?: number }>>(\n context: T,\n): T {\n return {\n ...context,\n prefixes: { ...context.prefixes },\n parseMode: new Set(context.parseMode),\n };\n}\n\nexport class MinimalSparqlParser<ParseRet extends Localized> {\n protected readonly defaultContext: SparqlContext;\n protected readonly coreTransformer = new TransformerObject();\n\n public constructor(protected readonly parser: Parser<ParseRet>, defaultContext: Partial<SparqlContext> = {}) {\n this.defaultContext = completeParseContext(defaultContext);\n }\n\n /**\n * Parse a query string starting from the\n * [QueryUnit](https://www.w3.org/TR/sparql11-query/#rQueryUnit)\n * or [QueryUpdate](https://www.w3.org/TR/sparql11-query/#rUpdateUnit) rules.\n * @param query\n * @param context\n */\n public parse(query: string, context: Partial<SparqlContext> = {}): ParseRet {\n const ast = this.parser.queryOrUpdate(query, copyParseContext({ ...this.defaultContext, ...context }));\n ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);\n return ast;\n }\n\n /**\n * Parse a query string starting from the [Path](https://www.w3.org/TR/sparql11-query/#rPath) grammar rule.\n * @param query\n * @param context\n */\n public parsePath(query: string, context: Partial<SparqlContext> = {}):\n (Path & { prefixes: object }) | TermIri {\n const ast = this.parser.path(query, copyParseContext({ ...this.defaultContext, ...context }));\n ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);\n if (this.defaultContext.astFactory.isPathPure(ast)) {\n return {\n ...ast,\n prefixes: {},\n };\n }\n return ast;\n }\n}\n"]}
1
+ {"version":3,"file":"MinimalSparqlParser.js","sourceRoot":"","sources":["../../../lib/MinimalSparqlParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAS7C,MAAM,UAAU,oBAAoB,CAClC,OAA+B;IAE/B,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI,UAAU,CAAC,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;QACjF,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE;QACjC,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,UAAU,wBAAwB,CACtC,OAA8D;IAE9D,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI,UAAU,EAAE;QAClD,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,IAAI,C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C;QAC9F,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,2BAA2B,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjH,IAAI,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACnD,OAAO;gBACL,GAAG,GAAG;gBACN,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["import type { Localized } from '@traqula/core';\nimport { traqulaNewlineAlternative, TransformerObject, 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>,\n): SparqlContext {\n return {\n astFactory: context.astFactory ?? new AstFactory({ tracksSourceLocation: false }),\n baseIRI: context.baseIRI,\n prefixes: { ...context.prefixes },\n parseMode: context.parseMode ? new Set(context.parseMode) : new Set([ 'canParseVars', 'canCreateBlankNodes' ]),\n skipValidation: context.skipValidation ?? false,\n };\n}\n\nexport function completeGeneratorContext(\n context: Partial<SparqlGeneratorContext & { offset?: number }>,\n): SparqlGeneratorContext & { offset?: number } {\n return {\n astFactory: context.astFactory ?? new AstFactory(),\n origSource: context.origSource ?? '',\n offset: context.offset,\n [traqulaIndentation]: context[traqulaIndentation] ?? 0,\n [traqulaNewlineAlternative]: context[traqulaNewlineAlternative] ?? ' ',\n indentInc: context.indentInc ?? 2,\n };\n}\n\nexport function copyParseContext<T extends\nPartial<SparqlContext & SparqlGeneratorContext & { origSource: string; offset?: number }>>(\n context: T,\n): T {\n return {\n ...context,\n prefixes: { ...context.prefixes },\n parseMode: new Set(context.parseMode),\n };\n}\n\nexport class MinimalSparqlParser<ParseRet extends Localized> {\n protected readonly defaultContext: SparqlContext;\n protected readonly coreTransformer = new TransformerObject();\n\n public constructor(protected readonly parser: Parser<ParseRet>, defaultContext: Partial<SparqlContext> = {}) {\n this.defaultContext = completeParseContext(defaultContext);\n }\n\n /**\n * Parse a query string starting from the\n * [QueryUnit](https://www.w3.org/TR/sparql11-query/#rQueryUnit)\n * or [QueryUpdate](https://www.w3.org/TR/sparql11-query/#rUpdateUnit) rules.\n * @param query\n * @param context\n */\n public parse(query: string, context: Partial<SparqlContext> = {}): ParseRet {\n const ast = this.parser.queryOrUpdate(query, copyParseContext({ ...this.defaultContext, ...context }));\n ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);\n return ast;\n }\n\n /**\n * Parse a query string starting from the [Path](https://www.w3.org/TR/sparql11-query/#rPath) grammar rule.\n * @param query\n * @param context\n */\n public parsePath(query: string, context: Partial<SparqlContext> = {}):\n (Path & { prefixes: object }) | TermIri {\n const ast = this.parser.path(query, copyParseContext({ ...this.defaultContext, ...context }));\n ast.loc = this.defaultContext.astFactory.sourceLocationInlinedSource(query, ast.loc, 0, Number.MAX_SAFE_INTEGER);\n if (this.defaultContext.astFactory.isPathPure(ast)) {\n return {\n ...ast,\n prefixes: {},\n };\n }\n return ast;\n }\n}\n"]}
@@ -9,7 +9,7 @@ export declare const builtInDatatype: import("../expressionHelpers.js").RuleDefE
9
9
  export declare const builtInBound: import("../expressionHelpers.js").RuleDefExpressionFunctionX<"builtInBound", [import("../Sparql11types.js").TermVariable]>;
10
10
  export declare const builtInIri: import("../expressionHelpers.js").RuleDefExpressionFunctionX<"builtInIri", [Expression]>;
11
11
  export declare const builtInUri: import("../expressionHelpers.js").RuleDefExpressionFunctionX<"builtInUri", [Expression]>;
12
- export declare const builtInBnodeSparqlJs: import("../expressionHelpers.js").RuleDefExpressionFunctionX<"builtInBnode", [Expression] | []>;
12
+ export declare const builtInBnodeSparqlJs: import("../expressionHelpers.js").RuleDefExpressionFunctionX<"builtInBnode", [] | [Expression]>;
13
13
  export declare const builtInRand: import("../expressionHelpers.js").RuleDefExpressionFunctionX<"builtInRand", []>;
14
14
  export declare const builtInAbs: import("../expressionHelpers.js").RuleDefExpressionFunctionX<"builtInAbs", [Expression]>;
15
15
  export declare const builtInCeil: import("../expressionHelpers.js").RuleDefExpressionFunctionX<"builtInCeil", [Expression]>;
@@ -32,5 +32,5 @@ export declare const triplesNode: SparqlRule<"triplesNode", TripleCollection>;
32
32
  export declare const triplesNodePath: SparqlRule<"triplesNodePath", TripleCollection>;
33
33
  export declare const blankNodePropertyList: SparqlRule<"blankNodePropertyList", TripleCollectionBlankNodeProperties>;
34
34
  export declare const blankNodePropertyListPath: SparqlRule<"blankNodePropertyListPath", TripleCollectionBlankNodeProperties>;
35
- export declare const graphNode: SparqlRule<"graphNode", TripleCollection | Term>;
36
- export declare const graphNodePath: SparqlRule<"graphNodePath", TripleCollection | Term>;
35
+ export declare const graphNode: SparqlRule<"graphNode", Term | TripleCollection>;
36
+ export declare const graphNodePath: SparqlRule<"graphNodePath", Term | TripleCollection>;
@@ -123,4 +123,4 @@ export declare const max: import("@traqula/core").NamedToken<"BuiltInMax">;
123
123
  export declare const avg: import("@traqula/core").NamedToken<"BuiltInAvg">;
124
124
  export declare const sample: import("@traqula/core").NamedToken<"BuiltInSample">;
125
125
  export declare const groupConcat: import("@traqula/core").NamedToken<"BuiltInGroup_concat">;
126
- export declare const allBuiltInCalls: LexerBuilder<"BuiltInStr" | "BuiltInLang" | "BuiltInLangmatches" | "BuiltInDatatype" | "BuiltInBound" | "BuiltInIri" | "BuiltInUri" | "BuiltInBnode" | "BuiltInRand" | "BuiltInAbs" | "BuiltInCeil" | "BuiltInFloor" | "BuiltInRound" | "BuiltInConcat" | "BuiltInStrlen" | "BuiltInUcase" | "BuiltInLcase" | "BuiltInEncode_for_uri" | "BuiltInContains" | "BuiltInStrstarts" | "BuiltInStrends" | "BuiltInStrbefore" | "BuiltInStrafter" | "BuiltInYear" | "BuiltInMonth" | "BuiltInDay" | "BuiltInHours" | "BuiltInMinutes" | "BuiltInSeconds" | "BuiltInTimezone" | "BuiltInTz" | "BuiltInNow" | "BuiltInUuid" | "BuiltInStruuid" | "BuiltInMd5" | "BuiltInSha1" | "BuiltInSha256" | "BuiltInSha384" | "BuiltInSha512" | "BuiltInCoalesce" | "BuiltInIf" | "BuiltInStrlang" | "BuiltInStrdt" | "BuiltInSameterm" | "BuiltInIsiri" | "BuiltInIsuri" | "BuiltInIsblank" | "BuiltInIsliteral" | "BuiltInIsnumeric" | "BuiltInSubstr" | "BuiltInReplace" | "BuiltInRegex" | "BuiltInExists" | "BuiltInNotexists" | "BuiltInCount" | "BuiltInSum" | "BuiltInMin" | "BuiltInMax" | "BuiltInAvg" | "BuiltInSample" | "BuiltInGroup_concat">;
126
+ export declare const allBuiltInCalls: LexerBuilder<"BuiltInStr" | "BuiltInLang" | "BuiltInLangmatches" | "BuiltInDatatype" | "BuiltInBound" | "BuiltInIri" | "BuiltInUri" | "BuiltInBnode" | "BuiltInRand" | "BuiltInAbs" | "BuiltInCeil" | "BuiltInFloor" | "BuiltInRound" | "BuiltInConcat" | "BuiltInStrlen" | "BuiltInUcase" | "BuiltInLcase" | "BuiltInEncode_for_uri" | "BuiltInContains" | "BuiltInStrstarts" | "BuiltInStrends" | "BuiltInStrbefore" | "BuiltInStrafter" | "BuiltInYear" | "BuiltInMonth" | "BuiltInDay" | "BuiltInHours" | "BuiltInMinutes" | "BuiltInSeconds" | "BuiltInTimezone" | "BuiltInTz" | "BuiltInNow" | "BuiltInUuid" | "BuiltInStruuid" | "BuiltInMd5" | "BuiltInSha1" | "BuiltInSha256" | "BuiltInSha384" | "BuiltInSha512" | "BuiltInCoalesce" | "BuiltInIf" | "BuiltInStrlang" | "BuiltInStrdt" | "BuiltInSameterm" | "BuiltInIsiri" | "BuiltInIsuri" | "BuiltInIsblank" | "BuiltInIsliteral" | "BuiltInIsnumeric" | "BuiltInRegex" | "BuiltInSubstr" | "BuiltInReplace" | "BuiltInExists" | "BuiltInNotexists" | "BuiltInCount" | "BuiltInSum" | "BuiltInMin" | "BuiltInMax" | "BuiltInAvg" | "BuiltInSample" | "BuiltInGroup_concat">;
@@ -49,8 +49,8 @@ export declare const false_: import("@traqula/core").NamedToken<"False">;
49
49
  export declare const in_: import("@traqula/core").NamedToken<"In">;
50
50
  export declare const notIn: import("@traqula/core").NamedToken<"NotIn">;
51
51
  export declare const separator: import("@traqula/core").NamedToken<"Separator">;
52
- export declare const allBaseTokens: LexerBuilder<"BaseDecl" | "PrefixDecl" | "True" | "False" | "a" | "Distinct" | "Separator" | "Select" | "Reduced" | "Construct" | "Describe" | "Ask" | "From" | "Where" | "Having" | "GroupByGroup" | "By" | "Order" | "OrderAsc" | "OrderDesc" | "Limit" | "Offset" | "Values" | "Load" | "Silent" | "LoadInto" | "Clear" | "Drop" | "Create" | "Add" | "To" | "Move" | "Copy" | "ModifyWith" | "DeleteWhereClause" | "DeleteDataClause" | "DeleteClause" | "InsertDataClause" | "InsertClause" | "UsingClause" | "Optional" | "Service" | "Bind" | "Undef" | "Minus" | "Union" | "Filter" | "As" | "In" | "NotIn">;
52
+ export declare const allBaseTokens: LexerBuilder<"BaseDecl" | "PrefixDecl" | "Select" | "Distinct" | "Reduced" | "As" | "Construct" | "Describe" | "Ask" | "From" | "Where" | "GroupByGroup" | "By" | "Having" | "Order" | "OrderAsc" | "OrderDesc" | "Limit" | "Offset" | "Values" | "Load" | "Silent" | "LoadInto" | "Clear" | "Drop" | "Create" | "Add" | "To" | "Move" | "Copy" | "ModifyWith" | "DeleteDataClause" | "DeleteWhereClause" | "DeleteClause" | "InsertDataClause" | "InsertClause" | "UsingClause" | "Optional" | "Service" | "Bind" | "Undef" | "Minus" | "Union" | "Filter" | "a" | "True" | "False" | "In" | "NotIn" | "Separator">;
53
53
  /**
54
54
  * [!!!ORDER MATTERS!!!](https://chevrotain.io/docs/tutorial/step1_lexing.html#creating-the-lexer)
55
55
  */
56
- export declare const sparql11LexerBuilder: LexerBuilder<"PNameNs" | "PNameLn" | "Var1" | "Var2" | "BaseDecl" | "PrefixDecl" | "Nil" | "Integer" | "Decimal" | "Double" | "IntegerPositive" | "DecimalPositive" | "DoublePositive" | "IntegerNegative" | "DecimalNegative" | "DoubleNegative" | "True" | "False" | "LangTag" | "Hathat" | "StringLiteral1" | "StringLiteral2" | "StringLiteralLong1" | "StringLiteralLong2" | "IriRef" | "BlankNodeLabel" | "Anon" | "a" | "BuiltInStr" | "BuiltInLang" | "BuiltInLangmatches" | "BuiltInDatatype" | "BuiltInBound" | "BuiltInIri" | "BuiltInUri" | "BuiltInBnode" | "BuiltInRand" | "BuiltInAbs" | "BuiltInCeil" | "BuiltInFloor" | "BuiltInRound" | "BuiltInConcat" | "BuiltInStrlen" | "BuiltInUcase" | "BuiltInLcase" | "BuiltInEncode_for_uri" | "BuiltInContains" | "BuiltInStrstarts" | "BuiltInStrends" | "BuiltInStrbefore" | "BuiltInStrafter" | "BuiltInYear" | "BuiltInMonth" | "BuiltInDay" | "BuiltInHours" | "BuiltInMinutes" | "BuiltInSeconds" | "BuiltInTimezone" | "BuiltInTz" | "BuiltInNow" | "BuiltInUuid" | "BuiltInStruuid" | "BuiltInMd5" | "BuiltInSha1" | "BuiltInSha256" | "BuiltInSha384" | "BuiltInSha512" | "BuiltInCoalesce" | "BuiltInIf" | "BuiltInStrlang" | "BuiltInStrdt" | "BuiltInSameterm" | "BuiltInIsiri" | "BuiltInIsuri" | "BuiltInIsblank" | "BuiltInIsliteral" | "BuiltInIsnumeric" | "BuiltInSubstr" | "BuiltInReplace" | "BuiltInRegex" | "BuiltInExists" | "BuiltInNotexists" | "BuiltInCount" | "Distinct" | "BuiltInSum" | "BuiltInMin" | "BuiltInMax" | "BuiltInAvg" | "BuiltInSample" | "BuiltInGroup_concat" | "LParen" | "RParen" | "Star" | "Semi" | "Separator" | "Equal" | "Ws" | "Comment" | "Select" | "Reduced" | "Construct" | "Describe" | "Ask" | "From" | "Where" | "Having" | "GroupByGroup" | "By" | "Order" | "OrderAsc" | "OrderDesc" | "Limit" | "Offset" | "Values" | "Load" | "Silent" | "LoadInto" | "Clear" | "Drop" | "Create" | "Add" | "To" | "Move" | "Copy" | "ModifyWith" | "DeleteWhereClause" | "DeleteDataClause" | "DeleteClause" | "InsertDataClause" | "InsertClause" | "UsingClause" | "Optional" | "Service" | "Bind" | "Undef" | "Minus" | "Union" | "Filter" | "As" | "In" | "NotIn" | "NamedGraph" | "DefaultGraph" | "Graph" | "GraphAll" | "LogicAnd" | "LogicOr" | "NotEqual" | "LessThanEqual" | "GreaterThanEqual" | "LCurly" | "RCurly" | "Dot" | "Comma" | "LSquare" | "RSquare" | "Pipe" | "Slash" | "Hat" | "Question" | "OpPlus" | "OpMinus" | "Exclamation" | "LessThan" | "GreaterThan">;
56
+ export declare const sparql11LexerBuilder: LexerBuilder<"BuiltInStr" | "BuiltInLang" | "BuiltInLangmatches" | "BuiltInDatatype" | "BuiltInBound" | "BuiltInIri" | "BuiltInUri" | "BuiltInBnode" | "BuiltInRand" | "BuiltInAbs" | "BuiltInCeil" | "BuiltInFloor" | "BuiltInRound" | "BuiltInConcat" | "BuiltInStrlen" | "BuiltInUcase" | "BuiltInLcase" | "BuiltInEncode_for_uri" | "BuiltInContains" | "BuiltInStrstarts" | "BuiltInStrends" | "BuiltInStrbefore" | "BuiltInStrafter" | "BuiltInYear" | "BuiltInMonth" | "BuiltInDay" | "BuiltInHours" | "BuiltInMinutes" | "BuiltInSeconds" | "BuiltInTimezone" | "BuiltInTz" | "BuiltInNow" | "BuiltInUuid" | "BuiltInStruuid" | "BuiltInMd5" | "BuiltInSha1" | "BuiltInSha256" | "BuiltInSha384" | "BuiltInSha512" | "BuiltInCoalesce" | "BuiltInIf" | "BuiltInStrlang" | "BuiltInStrdt" | "BuiltInSameterm" | "BuiltInIsiri" | "BuiltInIsuri" | "BuiltInIsblank" | "BuiltInIsliteral" | "BuiltInIsnumeric" | "BuiltInRegex" | "BuiltInSubstr" | "BuiltInReplace" | "BuiltInExists" | "BuiltInNotexists" | "BuiltInCount" | "BuiltInSum" | "BuiltInMin" | "BuiltInMax" | "BuiltInAvg" | "BuiltInSample" | "BuiltInGroup_concat" | "NamedGraph" | "DefaultGraph" | "Graph" | "GraphAll" | "LCurly" | "RCurly" | "Dot" | "Comma" | "Semi" | "LParen" | "RParen" | "LSquare" | "RSquare" | "Pipe" | "Slash" | "Hat" | "Question" | "Star" | "OpPlus" | "OpMinus" | "Exclamation" | "LogicAnd" | "LogicOr" | "Equal" | "NotEqual" | "LessThan" | "GreaterThan" | "LessThanEqual" | "GreaterThanEqual" | "Hathat" | "IriRef" | "PNameLn" | "PNameNs" | "BlankNodeLabel" | "Var1" | "Var2" | "LangTag" | "Integer" | "Decimal" | "Double" | "IntegerPositive" | "DecimalPositive" | "DoublePositive" | "IntegerNegative" | "DecimalNegative" | "DoubleNegative" | "StringLiteral1" | "StringLiteral2" | "StringLiteralLong1" | "StringLiteralLong2" | "Ws" | "Comment" | "Nil" | "Anon" | "BaseDecl" | "PrefixDecl" | "Select" | "Distinct" | "Reduced" | "As" | "Construct" | "Describe" | "Ask" | "From" | "Where" | "GroupByGroup" | "By" | "Having" | "Order" | "OrderAsc" | "OrderDesc" | "Limit" | "Offset" | "Values" | "Load" | "Silent" | "LoadInto" | "Clear" | "Drop" | "Create" | "Add" | "To" | "Move" | "Copy" | "ModifyWith" | "DeleteDataClause" | "DeleteWhereClause" | "DeleteClause" | "InsertDataClause" | "InsertClause" | "UsingClause" | "Optional" | "Service" | "Bind" | "Undef" | "Minus" | "Union" | "Filter" | "a" | "True" | "False" | "In" | "NotIn" | "Separator">;
@@ -25,4 +25,4 @@ export declare const greaterThan: import("@traqula/core").NamedToken<"GreaterTha
25
25
  export declare const lessThanEqual: import("@traqula/core").NamedToken<"LessThanEqual">;
26
26
  export declare const greaterThanEqual: import("@traqula/core").NamedToken<"GreaterThanEqual">;
27
27
  export declare const hathat: import("@traqula/core").NamedToken<"Hathat">;
28
- export declare const allSymbols: LexerBuilder<"Hathat" | "LParen" | "RParen" | "Star" | "Semi" | "Equal" | "LogicAnd" | "LogicOr" | "NotEqual" | "LessThanEqual" | "GreaterThanEqual" | "LCurly" | "RCurly" | "Dot" | "Comma" | "LSquare" | "RSquare" | "Pipe" | "Slash" | "Hat" | "Question" | "OpPlus" | "OpMinus" | "Exclamation" | "LessThan" | "GreaterThan">;
28
+ export declare const allSymbols: LexerBuilder<"LCurly" | "RCurly" | "Dot" | "Comma" | "Semi" | "LParen" | "RParen" | "LSquare" | "RSquare" | "Pipe" | "Slash" | "Hat" | "Question" | "Star" | "OpPlus" | "OpMinus" | "Exclamation" | "LogicAnd" | "LogicOr" | "Equal" | "NotEqual" | "LessThan" | "GreaterThan" | "LessThanEqual" | "GreaterThanEqual" | "Hathat">;
@@ -92,4 +92,4 @@ export declare const nil: import("@traqula/core").NamedToken<"Nil">;
92
92
  * [[163]](https://www.w3.org/TR/sparql11-query/#rANON)
93
93
  */
94
94
  export declare const anon: import("@traqula/core").NamedToken<"Anon">;
95
- export declare const allTerminals: LexerBuilder<"PNameNs" | "PNameLn" | "Var1" | "Var2" | "Nil" | "Integer" | "Decimal" | "Double" | "IntegerPositive" | "DecimalPositive" | "DoublePositive" | "IntegerNegative" | "DecimalNegative" | "DoubleNegative" | "LangTag" | "StringLiteral1" | "StringLiteral2" | "StringLiteralLong1" | "StringLiteralLong2" | "IriRef" | "BlankNodeLabel" | "Anon" | "Ws" | "Comment">;
95
+ export declare const allTerminals: LexerBuilder<"IriRef" | "PNameLn" | "PNameNs" | "BlankNodeLabel" | "Var1" | "Var2" | "LangTag" | "Integer" | "Decimal" | "Double" | "IntegerPositive" | "DecimalPositive" | "DoublePositive" | "IntegerNegative" | "DecimalNegative" | "DoubleNegative" | "StringLiteral1" | "StringLiteral2" | "StringLiteralLong1" | "StringLiteralLong2" | "Ws" | "Comment" | "Nil" | "Anon">;
@@ -1,4 +1,4 @@
1
- import type { GeneratorRule, ParserRule, traqulaIndentation } from '@traqula/core';
1
+ import type { GeneratorRule, ParserRule, traqulaIndentation, traqulaNewlineAlternative } from '@traqula/core';
2
2
  import type { AstFactory } from './astFactory.js';
3
3
  export interface SparqlContext {
4
4
  /**
@@ -6,11 +6,11 @@ export interface SparqlContext {
6
6
  */
7
7
  astFactory: AstFactory;
8
8
  /**
9
- * Current scoped prefixes. Used for resolving prefixed names.
9
+ * Current scoped prefixes. Only used to validate parsed prefixes are known.
10
10
  */
11
11
  prefixes: Record<string, string>;
12
12
  /**
13
- * The base IRI for the query. Used for resolving relative IRIs.
13
+ * Currently scoped base IRI. Only used to validate a base is set when parsing.
14
14
  */
15
15
  baseIRI: string | undefined;
16
16
  /**
@@ -27,6 +27,7 @@ export interface SparqlGeneratorContext {
27
27
  indentInc: number;
28
28
  origSource: string;
29
29
  [traqulaIndentation]: number;
30
+ [traqulaNewlineAlternative]: string;
30
31
  }
31
32
  export type SparqlRule<
32
33
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sparql11HelperTypes.js","sourceRoot":"","sources":["../../../lib/sparql11HelperTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { GeneratorRule, ParserRule, traqulaIndentation } from '@traqula/core';\nimport type { AstFactory } from './astFactory.js';\n\nexport interface SparqlContext {\n /**\n * Data-factoryMixins to be used when constructing rdf primitives.\n */\n astFactory: AstFactory;\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\nexport interface SparqlGeneratorContext {\n astFactory: AstFactory;\n indentInc: number;\n origSource: string;\n [traqulaIndentation]: number;\n}\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 extends any[] = [],\n> = SparqlGrammarRule<NameType, ReturnType, ParamType>\n & SparqlGeneratorRule<NameType, GenInputType, ParamType>;\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 extends any[] = [],\n> = GeneratorRule<SparqlGeneratorContext, NameType, ReturnType, ParamType>;\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 extends any[] = [],\n> = ParserRule<SparqlContext, NameType, ReturnType, ParamType>;\n"]}
1
+ {"version":3,"file":"sparql11HelperTypes.js","sourceRoot":"","sources":["../../../lib/sparql11HelperTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { GeneratorRule, ParserRule, traqulaIndentation, traqulaNewlineAlternative } from '@traqula/core';\nimport type { AstFactory } from './astFactory.js';\n\nexport interface SparqlContext {\n /**\n * Data-factoryMixins to be used when constructing rdf primitives.\n */\n astFactory: AstFactory;\n /**\n * Current scoped prefixes. Only used to validate parsed prefixes are known.\n */\n prefixes: Record<string, string>;\n /**\n * Currently scoped base IRI. Only used to validate a base is set when parsing.\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\nexport interface SparqlGeneratorContext {\n astFactory: AstFactory;\n indentInc: number;\n origSource: string;\n [traqulaIndentation]: number;\n [traqulaNewlineAlternative]: string;\n}\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 extends any[] = [],\n> = SparqlGrammarRule<NameType, ReturnType, ParamType>\n & SparqlGeneratorRule<NameType, GenInputType, ParamType>;\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 extends any[] = [],\n> = GeneratorRule<SparqlGeneratorContext, NameType, ReturnType, ParamType>;\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 extends any[] = [],\n> = ParserRule<SparqlContext, NameType, ReturnType, ParamType>;\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@traqula/rules-sparql-1-1",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "description": "TRAQULA Lexer and Grammar Rules for sparql 1.1",
6
6
  "lsd:module": true,
7
7
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@traqula/chevrotain": "^1.0.0",
45
- "@traqula/core": "^1.0.0"
45
+ "@traqula/core": "^1.0.3"
46
46
  },
47
- "gitHead": "4ddd9d5a4b86f7e08d651411f2fbd668899d63fe"
47
+ "gitHead": "100f8110af8ae3288390f37652e516c8d4d5d124"
48
48
  }