@traqula/rules-sparql-1-2 1.1.2 → 1.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"lexer.js","sourceRoot":"","sources":["../../../lib/lexer.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAEvD,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC,CAAC;AAC1G,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,CAAC;AACnH,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,CAAC;AACrH,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,CAAC;AACrH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC,CAAC;AACxH,MAAM,CAAC,MAAM,cAAc,GA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,CAAC,CAAC;AAC7G,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;AACrH,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEzG,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC;IAClC,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,qCAAqC;IAC9C,KAAK,EAAE,UAAU;CAClB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY;KAC7C,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;KAChC,SAAS,CACR,GAAG,CAAC,OAAO,CAAC,QAAQ,EACpB,KAAK,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,OAAO,CACR;KACA,SAAS,CACR,GAAG,CAAC,OAAO,CAAC,WAAW,EACvB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,aAAa,CACd;KACA,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC;KAC1C,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC","sourcesContent":["/* eslint-disable require-unicode-regexp */\nimport { LexerBuilder, createToken } from '@traqula/core';\nimport { lex as l11 } from '@traqula/rules-sparql-1-1';\n\nexport const version = createToken({ name: 'Version', pattern: /version/i, label: 'version identifier' });\nexport const tilde = createToken({ name: 'Tilde', pattern: '~', label: '~' });\nexport const annotationOpen = createToken({ name: 'AnnotationOpen', pattern: '{|', label: `Annotation Open: {|` });\nexport const annotationClose = createToken({ name: 'AnnotationClose', pattern: '|}', label: 'Annotation Close |}' });\nexport const reificationOpen = createToken({ name: 'ReificationOpen', pattern: '<<', label: 'Reification open <<' });\nexport const reificationClose = createToken({ name: 'ReificationClose', pattern: '>>', label: 'Reification close >>' });\nexport const tripleTermOpen = createToken({ name: 'TripleTermOpen', pattern: '<<(', label: 'Triple Term Open <<(' });\nexport const tripleTermClose = createToken({ name: 'TripleTermClose', pattern: ')>>', label: 'Triple Term Close )>>' });\n\nexport const buildInLangDir = createToken({ name: 'BuiltInLangdir', pattern: /langdir/i, label: 'LANGDIR' });\nexport const buildInStrLangDir = createToken({\n name: 'BuiltInStrLangdir',\n pattern: /strlangdir/i,\n label: 'STRLANGDIR',\n});\nexport const buildInHasLang = createToken({ name: 'BuiltInHasLang', pattern: /haslang/i, label: 'hasLANG' });\nexport const buildInHasLangDir = createToken({\n name: 'BuiltInHasLangdir',\n pattern: /haslangdir/i,\n label: 'hasLANGDIR',\n});\nexport const buildInIsTRIPLE = createToken({ name: 'BuiltInIsTriple', pattern: /istriple/i, label: 'isTRIPLE' });\nexport const buildInTRIPLE = createToken({ name: 'BuiltInTriple', pattern: /triple/i, label: 'TRIPLE' });\nexport const buildInSUBJECT = createToken({ name: 'BuiltInSubject', pattern: /subject/i, label: 'SUBJECT' });\nexport const buildInPREDICATE = createToken({ name: 'BuiltInPredicate', pattern: /predicate/i, label: 'PREDICATE' });\nexport const buildInOBJECT = createToken({ name: 'BuiltInObject', pattern: /object/i, label: 'OBJECT' });\n\nexport const LANG_DIR = createToken({\n name: 'LANG_DIR',\n pattern: /@[a-z]+(?:-[\\da-z]+)*(?:--[a-z]+)?/i,\n label: 'LANG_DIR',\n});\n\nexport const sparql12LexerBuilder = LexerBuilder\n .create(l11.sparql11LexerBuilder)\n .addBefore(\n l11.symbols.logicAnd,\n tilde,\n annotationOpen,\n annotationClose,\n tripleTermOpen,\n tripleTermClose,\n reificationOpen,\n reificationClose,\n version,\n )\n .addBefore(\n l11.builtIn.langmatches,\n buildInLangDir,\n buildInStrLangDir,\n buildInHasLangDir,\n buildInHasLang,\n buildInIsTRIPLE,\n buildInTRIPLE,\n buildInSUBJECT,\n buildInPREDICATE,\n buildInOBJECT,\n )\n .addBefore(l11.terminals.langTag, LANG_DIR)\n .delete(l11.terminals.langTag);\n"]}
1
+ {"version":3,"file":"lexer.js","sourceRoot":"","sources":["../../../lib/lexer.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAEvD,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC,CAAC;AAC1G,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,CAAC;AACnH,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,CAAC;AACrH,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,CAAC;AACrH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EA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;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;IAC5C,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,IAAI,MAAM,CAAC,2BAA2B,WAAW,MAAM,WAAW,SAAS,CAAC;CACtF,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;IAC5C,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,IAAI,MAAM,CAAC,2BAA2B,WAAW,MAAM,WAAW,SAAS,CAAC;CACtF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY;KAC7C,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;KAChC,SAAS,CACR,GAAG,CAAC,OAAO,CAAC,QAAQ,EACpB,KAAK,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,OAAO,CACR;KACA,SAAS,CACR,GAAG,CAAC,OAAO,CAAC,WAAW,EACvB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,aAAa,CACd;KACA,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC;KAC1C,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;IACxC,0EAA0E;KACzE,OAAO,CAAC,MAAM,CAAC;KACf,OAAO,CAAC,cAAc,CAAC;KACvB,OAAO,CAAC,cAAc,CAAC;KACvB,OAAO,CAAC,kBAAkB,CAAC;KAC3B,OAAO,CAAC,kBAAkB,CAAC,CAAC","sourcesContent":["/* eslint-disable require-unicode-regexp,no-control-regex */\nimport { LexerBuilder, createToken } from '@traqula/core';\nimport { lex as l11 } from '@traqula/rules-sparql-1-1';\n\nexport const version = createToken({ name: 'Version', pattern: /version/i, label: 'version identifier' });\nexport const tilde = createToken({ name: 'Tilde', pattern: '~', label: '~' });\nexport const annotationOpen = createToken({ name: 'AnnotationOpen', pattern: '{|', label: `Annotation Open: {|` });\nexport const annotationClose = createToken({ name: 'AnnotationClose', pattern: '|}', label: 'Annotation Close |}' });\nexport const reificationOpen = createToken({ name: 'ReificationOpen', pattern: '<<', label: 'Reification open <<' });\nexport const reificationClose = createToken({ name: 'ReificationClose', pattern: '>>', label: 'Reification close >>' });\nexport const tripleTermOpen = createToken({ name: 'TripleTermOpen', pattern: '<<(', label: 'Triple Term Open <<(' });\nexport const tripleTermClose = createToken({ name: 'TripleTermClose', pattern: ')>>', label: 'Triple Term Close )>>' });\n\nexport const buildInLangDir = createToken({ name: 'BuiltInLangdir', pattern: /langdir/i, label: 'LANGDIR' });\nexport const buildInStrLangDir = createToken({\n name: 'BuiltInStrLangdir',\n pattern: /strlangdir/i,\n label: 'STRLANGDIR',\n});\nexport const buildInHasLang = createToken({ name: 'BuiltInHasLang', pattern: /haslang/i, label: 'hasLANG' });\nexport const buildInHasLangDir = createToken({\n name: 'BuiltInHasLangdir',\n pattern: /haslangdir/i,\n label: 'hasLANGDIR',\n});\nexport const buildInIsTRIPLE = createToken({ name: 'BuiltInIsTriple', pattern: /istriple/i, label: 'isTRIPLE' });\nexport const buildInTRIPLE = createToken({ name: 'BuiltInTriple', pattern: /triple/i, label: 'TRIPLE' });\nexport const buildInSUBJECT = createToken({ name: 'BuiltInSubject', pattern: /subject/i, label: 'SUBJECT' });\nexport const buildInPREDICATE = createToken({ name: 'BuiltInPredicate', pattern: /predicate/i, label: 'PREDICATE' });\nexport const buildInOBJECT = createToken({ name: 'BuiltInObject', pattern: /object/i, label: 'OBJECT' });\n\nexport const LANG_DIR = createToken({\n name: 'LANG_DIR',\n pattern: /@[a-z]+(?:-[\\da-z]+)*(?:--[a-z]+)?/i,\n label: 'LANG_DIR',\n});\n\n/**\n * UCHAR: \\uXXXX or \\UXXXXXXXX (SPARQL 1.2 §19.2)\n * Used inside IRI references and string literals only.\n */\nconst ucharSource = /\\\\u[\\dA-Fa-f]{4}|\\\\U[\\dA-Fa-f]{8}/.source;\n/**\n * ECHAR source !(same as sparql-1-1 echarPattern)\n */\nconst echarSource = /\\\\[\"'\\\\bfnrt]/.source;\n/**\n * Character class for valid IRI characters (excluding backslash to allow UCHAR alternation)\n * Same as SPARQL 1.1\n */\nconst iriCharSource = /[^\\u0000-\\u0020\"<>\\\\^`{|}]/.source;\n\n/**\n * [[161]](https://www.w3.org/TR/sparql12-query/#rIRIREF)\n * Extends the SPARQL 1.1 IRI token to allow UCHAR codepoint escapes inside angle-bracket IRIs.\n */\nexport const iriRef = createToken({\n name: 'IriRef',\n pattern: new RegExp(`<((${iriCharSource})|(${ucharSource}))*>`),\n});\n\n/**\n * [[163]](https://www.w3.org/TR/sparql12-query/#rSTRING_LITERAL1)\n * Extends the SPARQL 1.1 string token to allow UCHAR codepoint escapes.\n */\nexport const stringLiteral1 = createToken({\n name: 'StringLiteral1',\n pattern: new RegExp(`'(([^\\\\u0027\\\\u005C\\\\u000A\\u000D])|(${echarSource})|(${ucharSource}))*'`),\n});\n\n/**\n * [[164]](https://www.w3.org/TR/sparql12-query/#rSTRING_LITERAL2)\n * Extends the SPARQL 1.1 string token to allow UCHAR codepoint escapes.\n */\nexport const stringLiteral2 = createToken({\n name: 'StringLiteral2',\n pattern: new RegExp(`\"(([^\\\\u0022\\\\u005C\\\\u000A\\\\u000D])|(${echarSource})|(${ucharSource}))*\"`),\n});\n\n/**\n * [[165]](https://www.w3.org/TR/sparql12-query/#rSTRING_LITERAL_LONG1)\n * Extends the SPARQL 1.1 string token to allow UCHAR codepoint escapes.\n */\nexport const stringLiteralLong1 = createToken({\n name: 'StringLiteralLong1',\n pattern: new RegExp(`'''(('|(''))?([^'\\\\\\\\]|(${echarSource})|(${ucharSource})))*'''`),\n});\n\n/**\n * [[166]](https://www.w3.org/TR/sparql12-query/#rSTRING_LITERAL_LONG2)\n * Extends the SPARQL 1.1 string token to allow UCHAR codepoint escapes.\n */\nexport const stringLiteralLong2 = createToken({\n name: 'StringLiteralLong2',\n pattern: new RegExp(`\"\"\"((\"|(\"\"))?([^\"\\\\\\\\]|(${echarSource})|(${ucharSource})))*\"\"\"`),\n});\n\nexport const sparql12LexerBuilder = LexerBuilder\n .create(l11.sparql11LexerBuilder)\n .addBefore(\n l11.symbols.logicAnd,\n tilde,\n annotationOpen,\n annotationClose,\n tripleTermOpen,\n tripleTermClose,\n reificationOpen,\n reificationClose,\n version,\n )\n .addBefore(\n l11.builtIn.langmatches,\n buildInLangDir,\n buildInStrLangDir,\n buildInHasLangDir,\n buildInHasLang,\n buildInIsTRIPLE,\n buildInTRIPLE,\n buildInSUBJECT,\n buildInPREDICATE,\n buildInOBJECT,\n )\n .addBefore(l11.terminals.langTag, LANG_DIR)\n .deleteToken(l11.terminals.langTag.name)\n // Replace IRI and string tokens with UCHAR-aware versions for SPARQL 1.2.\n .replace(iriRef)\n .replace(stringLiteral1)\n .replace(stringLiteral2)\n .replace(stringLiteralLong1)\n .replace(stringLiteralLong2);\n"]}
@@ -1,6 +1,14 @@
1
1
  import { TransformerSubTyped } from '@traqula/core';
2
2
  import type { SparqlContext, SparqlGeneratorContext } from './sparql12HelperTypes.js';
3
3
  import type { Sparql12Nodes } from './sparql12Types.js';
4
+ /**
5
+ * Decode UCHAR codepoint escapes (\\uXXXX / \\UXXXXXXXX) within a string according to
6
+ * [SPARQL 1.2 §19.2](https://www.w3.org/TR/sparql12-query/#sec-escapes).
7
+ *
8
+ * Unlike the SPARQL 1.1 variant, this function rejects surrogate code points (U+D800–U+DFFF)
9
+ * even when they would form a valid surrogate pair.
10
+ */
11
+ export declare function sparql12CodepointEscape(input: string): string;
4
12
  export declare function completeParseContext(context: Partial<SparqlContext>): SparqlContext;
5
13
  export declare function completeGeneratorContext(context: Partial<SparqlGeneratorContext & {
6
14
  offset?: number;
@@ -1,5 +1,22 @@
1
1
  import { TransformerSubTyped, traqulaIndentation, traqulaNewlineAlternative } from '@traqula/core';
2
2
  import { AstFactory } from './AstFactory.js';
3
+ /**
4
+ * Decode UCHAR codepoint escapes (\\uXXXX / \\UXXXXXXXX) within a string according to
5
+ * [SPARQL 1.2 §19.2](https://www.w3.org/TR/sparql12-query/#sec-escapes).
6
+ *
7
+ * Unlike the SPARQL 1.1 variant, this function rejects surrogate code points (U+D800–U+DFFF)
8
+ * even when they would form a valid surrogate pair.
9
+ */
10
+ export function sparql12CodepointEscape(input) {
11
+ return input.replaceAll(/\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{8})/gu, (_, unicode4, unicode8) => {
12
+ const hex = (unicode4 ?? unicode8);
13
+ const codePoint = Number.parseInt(hex, 16);
14
+ if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
15
+ throw new Error(`Illegal codepoint escape: surrogate code point U+${hex.toUpperCase()}`);
16
+ }
17
+ return String.fromCodePoint(codePoint);
18
+ });
19
+ }
3
20
  export function completeParseContext(context) {
4
21
  return {
5
22
  astFactory: context.astFactory ?? new AstFactory({ tracksSourceLocation: false }),
@@ -7,6 +24,7 @@ export function completeParseContext(context) {
7
24
  prefixes: { ...context.prefixes },
8
25
  parseMode: context.parseMode ? new Set(context.parseMode) : new Set(['canParseVars', 'canCreateBlankNodes']),
9
26
  skipValidation: context.skipValidation ?? false,
27
+ codepointEscape: context.codepointEscape ?? sparql12CodepointEscape,
10
28
  };
11
29
  }
12
30
  export function completeGeneratorContext(context) {
@@ -1 +1 @@
1
- {"version":3,"file":"parserUtils.js","sourceRoot":"","sources":["../../../lib/parserUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,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,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC;QACjC,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC;QACtD,CAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,IAAI,GAAG;KACvE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAE9B,OAAU;IAEV,OAAO;QACL,GAAG,OAAO;QACV,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE;QACjC,SAAS,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC;KACtC,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,cAAe,SAAQ,mBAAkC;CAAG","sourcesContent":["import { TransformerSubTyped, traqulaIndentation, traqulaNewlineAlternative } from '@traqula/core';\nimport { AstFactory } from './AstFactory.js';\nimport type { SparqlContext, SparqlGeneratorContext } from './sparql12HelperTypes.js';\nimport type { Sparql12Nodes } from './sparql12Types.js';\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 indentInc: context.indentInc ?? 2,\n [traqulaIndentation]: context[traqulaIndentation] ?? 0,\n [traqulaNewlineAlternative]: context[traqulaNewlineAlternative] ?? ' ',\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 AstTransformer extends TransformerSubTyped<Sparql12Nodes> {}\n"]}
1
+ {"version":3,"file":"parserUtils.js","sourceRoot":"","sources":["../../../lib/parserUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAa;IACnD,OAAO,KAAK,CAAC,UAAU,CACrB,2CAA2C,EAC3C,CAAC,CAAC,EAAE,QAA4B,EAAE,QAA4B,EAAE,EAAE;QAChE,MAAM,GAAG,GAAG,CAAC,QAAQ,IAAI,QAAQ,CAAE,CAAC;QACpC,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC3C,IAAI,SAAS,IAAI,MAAM,IAAI,SAAS,IAAI,MAAM,EAAE,CAA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AO,CAAC,QAAQ,EAAE;QACjC,SAAS,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC;KACtC,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,cAAe,SAAQ,mBAAkC;CAAG","sourcesContent":["import { TransformerSubTyped, traqulaIndentation, traqulaNewlineAlternative } from '@traqula/core';\nimport { AstFactory } from './AstFactory.js';\nimport type { SparqlContext, SparqlGeneratorContext } from './sparql12HelperTypes.js';\nimport type { Sparql12Nodes } from './sparql12Types.js';\n\n/**\n * Decode UCHAR codepoint escapes (\\\\uXXXX / \\\\UXXXXXXXX) within a string according to\n * [SPARQL 1.2 §19.2](https://www.w3.org/TR/sparql12-query/#sec-escapes).\n *\n * Unlike the SPARQL 1.1 variant, this function rejects surrogate code points (U+D800–U+DFFF)\n * even when they would form a valid surrogate pair.\n */\nexport function sparql12CodepointEscape(input: string): string {\n return input.replaceAll(\n /\\\\u([0-9a-fA-F]{4})|\\\\U([0-9a-fA-F]{8})/gu,\n (_, unicode4: string | undefined, unicode8: string | undefined) => {\n const hex = (unicode4 ?? unicode8)!;\n const codePoint = Number.parseInt(hex, 16);\n if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {\n throw new Error(`Illegal codepoint escape: surrogate code point U+${hex.toUpperCase()}`);\n }\n return String.fromCodePoint(codePoint);\n },\n );\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 codepointEscape: context.codepointEscape ?? sparql12CodepointEscape,\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 indentInc: context.indentInc ?? 2,\n [traqulaIndentation]: context[traqulaIndentation] ?? 0,\n [traqulaNewlineAlternative]: context[traqulaNewlineAlternative] ?? ' ',\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 AstTransformer extends TransformerSubTyped<Sparql12Nodes> {}\n"]}
@@ -45,6 +45,11 @@ ReturnType = unknown,
45
45
  ParamType extends any[] = []> = ParserRule<SparqlContext, NameType, ReturnType, ParamType>;
46
46
  export type SparqlContext = T11.SparqlContext & {
47
47
  astFactory: AstFactory;
48
+ /**
49
+ * Function that decodes UCHAR codepoint escapes (\\uXXXX / \\UXXXXXXXX) within a string.
50
+ * In SPARQL 1.2 this is applied per-rule rather than as a query pre-processor.
51
+ */
52
+ codepointEscape: (input: string) => string;
48
53
  };
49
54
  export type SparqlGeneratorContext = T11.SparqlGeneratorContext & {
50
55
  astFactory: AstFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"sparql12HelperTypes.js","sourceRoot":"","sources":["../../../lib/sparql12HelperTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { GeneratorRule, ParserRule } from '@traqula/core';\nimport type * as T11 from '@traqula/rules-sparql-1-1';\nimport type { AstFactory } from './AstFactory.js';\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>;\n\nexport type SparqlGeneratorRule<\n /**\n * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.\n */\n NameType extends string = string,\n /**\n * Type that will be returned after a correct parse of this rule.\n * This type will be the return type of calling SUBRULE with this grammar rule.\n */\n ReturnType = unknown,\n /**\n * Function arguments that can be given to convey the state of the current parse operation.\n */\n ParamType extends any [] = [],\n> = GeneratorRule<SparqlGeneratorContext, NameType, ReturnType, ParamType>;\n\nexport type SparqlGrammarRule<\n /**\n * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.\n */\n NameType extends string = string,\n /**\n * Type that will be returned after a correct parse of this rule.\n * This type will be the return type of calling SUBRULE with this grammar rule.\n */\n ReturnType = unknown,\n /**\n * Function arguments that can be given to convey the state of the current parse operation.\n */\n ParamType extends any[] = [],\n> = ParserRule<SparqlContext, NameType, ReturnType, ParamType>;\n\nexport type SparqlContext = T11.SparqlContext & { astFactory: AstFactory };\nexport type SparqlGeneratorContext = T11.SparqlGeneratorContext & { astFactory: AstFactory };\n"]}
1
+ {"version":3,"file":"sparql12HelperTypes.js","sourceRoot":"","sources":["../../../lib/sparql12HelperTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { GeneratorRule, ParserRule } from '@traqula/core';\nimport type * as T11 from '@traqula/rules-sparql-1-1';\nimport type { AstFactory } from './AstFactory.js';\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>;\n\nexport type SparqlGeneratorRule<\n /**\n * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.\n */\n NameType extends string = string,\n /**\n * Type that will be returned after a correct parse of this rule.\n * This type will be the return type of calling SUBRULE with this grammar rule.\n */\n ReturnType = unknown,\n /**\n * Function arguments that can be given to convey the state of the current parse operation.\n */\n ParamType extends any [] = [],\n> = GeneratorRule<SparqlGeneratorContext, NameType, ReturnType, ParamType>;\n\nexport type SparqlGrammarRule<\n /**\n * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.\n */\n NameType extends string = string,\n /**\n * Type that will be returned after a correct parse of this rule.\n * This type will be the return type of calling SUBRULE with this grammar rule.\n */\n ReturnType = unknown,\n /**\n * Function arguments that can be given to convey the state of the current parse operation.\n */\n ParamType extends any[] = [],\n> = ParserRule<SparqlContext, NameType, ReturnType, ParamType>;\n\nexport type SparqlContext = T11.SparqlContext & {\n astFactory: AstFactory;\n /**\n * Function that decodes UCHAR codepoint escapes (\\\\uXXXX / \\\\UXXXXXXXX) within a string.\n * In SPARQL 1.2 this is applied per-rule rather than as a query pre-processor.\n */\n codepointEscape: (input: string) => string;\n};\nexport type SparqlGeneratorContext = T11.SparqlGeneratorContext & { astFactory: AstFactory };\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@traqula/rules-sparql-1-2",
3
3
  "type": "module",
4
- "version": "1.1.2",
4
+ "version": "1.1.3",
5
5
  "description": "Traqula Lexer and Grammar Rules for sparql 1.2",
6
6
  "lsd:module": true,
7
7
  "license": "MIT",
@@ -41,8 +41,8 @@
41
41
  "build:cjs": "node \"../../node_modules/typescript/bin/tsc\" -b tsconfig.cjs.json"
42
42
  },
43
43
  "dependencies": {
44
- "@traqula/core": "^1.1.1",
45
- "@traqula/rules-sparql-1-1": "^1.1.2"
44
+ "@traqula/core": "^1.1.3",
45
+ "@traqula/rules-sparql-1-1": "^1.1.3"
46
46
  },
47
- "gitHead": "4a8a40e902755a39eab0d9f4f144e2e46d44b4d2"
47
+ "gitHead": "9f3269bc699a2990f2948c78883dabdac6908f26"
48
48
  }