eyeling 1.6.20 → 1.6.21
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/eyeling.js +82 -8
- package/package.json +1 -1
package/eyeling.js
CHANGED
|
@@ -559,6 +559,67 @@ function lex(inputText) {
|
|
|
559
559
|
continue;
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
+
// String literal: short '...' or long '''...'''
|
|
563
|
+
if (c === "'") {
|
|
564
|
+
// Long string literal ''' ... '''
|
|
565
|
+
if (peek(1) === "'" && peek(2) === "'") {
|
|
566
|
+
i += 3; // consume opening '''
|
|
567
|
+
const sChars = [];
|
|
568
|
+
let closed = false;
|
|
569
|
+
while (i < n) {
|
|
570
|
+
// closing delimiter?
|
|
571
|
+
if (peek() === "'" && peek(1) === "'" && peek(2) === "'") {
|
|
572
|
+
i += 3; // consume closing '''
|
|
573
|
+
closed = true;
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
let cc = chars[i];
|
|
577
|
+
i++;
|
|
578
|
+
if (cc === '\\') {
|
|
579
|
+
// Preserve escapes verbatim (same behavior as short strings)
|
|
580
|
+
if (i < n) {
|
|
581
|
+
const esc = chars[i];
|
|
582
|
+
i++;
|
|
583
|
+
sChars.push('\\');
|
|
584
|
+
sChars.push(esc);
|
|
585
|
+
}
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
sChars.push(cc);
|
|
589
|
+
}
|
|
590
|
+
if (!closed) throw new Error("Unterminated long string literal '''...'''");
|
|
591
|
+
const raw = "'''" + sChars.join('') + "'''";
|
|
592
|
+
const decoded = decodeN3StringEscapes(stripQuotes(raw));
|
|
593
|
+
const s = JSON.stringify(decoded); // canonical short quoted form
|
|
594
|
+
tokens.push(new Token('Literal', s));
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// Short string literal ' ... '
|
|
599
|
+
i++; // consume opening '
|
|
600
|
+
const sChars = [];
|
|
601
|
+
while (i < n) {
|
|
602
|
+
let cc = chars[i];
|
|
603
|
+
i++;
|
|
604
|
+
if (cc === '\\') {
|
|
605
|
+
if (i < n) {
|
|
606
|
+
const esc = chars[i];
|
|
607
|
+
i++;
|
|
608
|
+
sChars.push('\\');
|
|
609
|
+
sChars.push(esc);
|
|
610
|
+
}
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
if (cc === "'") break;
|
|
614
|
+
sChars.push(cc);
|
|
615
|
+
}
|
|
616
|
+
const raw = "'" + sChars.join('') + "'";
|
|
617
|
+
const decoded = decodeN3StringEscapes(stripQuotes(raw));
|
|
618
|
+
const s = JSON.stringify(decoded); // canonical short quoted form
|
|
619
|
+
tokens.push(new Token('Literal', s));
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
|
|
562
623
|
// Variable ?name
|
|
563
624
|
if (c === '?') {
|
|
564
625
|
i++;
|
|
@@ -2371,11 +2432,16 @@ function normalizeLiteralForFastKey(lit) {
|
|
|
2371
2432
|
}
|
|
2372
2433
|
|
|
2373
2434
|
function stripQuotes(lex) {
|
|
2374
|
-
if (lex
|
|
2375
|
-
|
|
2435
|
+
if (typeof lex !== 'string') return lex;
|
|
2436
|
+
// Handle both short ('...' / "...") and long ('''...''' / """...""") forms.
|
|
2437
|
+
if (lex.length >= 6) {
|
|
2438
|
+
if (lex.startsWith('"""') && lex.endsWith('"""')) return lex.slice(3, -3);
|
|
2439
|
+
if (lex.startsWith("'''") && lex.endsWith("'''")) return lex.slice(3, -3);
|
|
2376
2440
|
}
|
|
2377
|
-
if (lex.length >= 2
|
|
2378
|
-
|
|
2441
|
+
if (lex.length >= 2) {
|
|
2442
|
+
const a = lex[0];
|
|
2443
|
+
const b = lex[lex.length - 1];
|
|
2444
|
+
if ((a === '"' && b === '"') || (a === "'" && b === "'")) return lex.slice(1, -1);
|
|
2379
2445
|
}
|
|
2380
2446
|
return lex;
|
|
2381
2447
|
}
|
|
@@ -2628,10 +2694,18 @@ function formatXsdFloatSpecialLex(n) {
|
|
|
2628
2694
|
}
|
|
2629
2695
|
|
|
2630
2696
|
function isQuotedLexical(lex) {
|
|
2631
|
-
//
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
);
|
|
2697
|
+
// Accept both Turtle/N3 quoting styles:
|
|
2698
|
+
// short: "..." or '...'
|
|
2699
|
+
// long: """...""" or '''...'''
|
|
2700
|
+
if (typeof lex !== 'string') return false;
|
|
2701
|
+
const n = lex.length;
|
|
2702
|
+
if (n >= 6 && ((lex.startsWith('"""') && lex.endsWith('"""')) || (lex.startsWith("'''") && lex.endsWith("'''")))) return true;
|
|
2703
|
+
if (n >= 2) {
|
|
2704
|
+
const a = lex[0];
|
|
2705
|
+
const b = lex[n - 1];
|
|
2706
|
+
return (a === '"' && b === '"') || (a === "'" && b === "'");
|
|
2707
|
+
}
|
|
2708
|
+
return false;
|
|
2635
2709
|
}
|
|
2636
2710
|
|
|
2637
2711
|
function isXsdNumericDatatype(dt) {
|