eyeling 1.24.4 → 1.24.6
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/HANDBOOK.md +2 -101
- package/README.md +2 -2
- package/dist/browser/eyeling.browser.js +256 -4
- package/examples/annotation.n3 +3 -4
- package/{see/examples/n3/backward_recursion.n3 → examples/backward-recursion.n3} +0 -2
- package/examples/collection.n3 +1 -2
- package/examples/context-association.n3 +56 -30
- package/{see/examples/n3/dijkstra_risk_path.n3 → examples/dijkstra-risk-path.n3} +3 -18
- package/{see/examples/n3/eco_route_insight.n3 → examples/eco-route-insight.n3} +2 -47
- package/{see/examples/n3/genetic_knapsack_selection.n3 → examples/genetic-knapsack-selection.n3} +2 -24
- package/{see/examples → examples}/input/annotation.trig +3 -3
- package/{see/examples/input/backward_recursion.trig → examples/input/backward-recursion.trig} +2 -2
- package/{see/examples/input/builtin_coverage.trig → examples/input/builtin-coverage.trig} +2 -2
- package/{see/examples → examples}/input/collection.trig +3 -3
- package/{see/examples/input/dijkstra_risk_path.trig → examples/input/dijkstra-risk-path.trig} +4 -4
- package/{see/examples/input/eco_route_insight.trig → examples/input/eco-route-insight.trig} +4 -4
- package/{see/examples/input/genetic_knapsack_selection.trig → examples/input/genetic-knapsack-selection.trig} +4 -4
- package/{see/examples/input/rc_discharge_envelope.trig → examples/input/rc-discharge-envelope.trig} +4 -4
- package/{see/examples/input/rdf_dataset.trig → examples/input/rdf-dataset.trig} +4 -4
- package/{see/examples/input/rdf_message_flow.trig → examples/input/rdf-message-flow.trig} +3 -3
- package/{see/examples/input/rdf_messages.trig → examples/input/rdf-messages.trig} +4 -4
- package/{see/examples/input/school_placement_audit.trig → examples/input/school-placement-audit.trig} +4 -4
- package/{see/examples/input/smoke_arithmetic.trig → examples/input/smoke-arithmetic.trig} +3 -3
- package/{see/examples/input/triple_terms.trig → examples/input/triple-terms.trig} +3 -3
- package/examples/output/backward-recursion.n3 +4 -0
- package/examples/output/context-association.n3 +9 -0
- package/examples/output/dijkstra-risk-path.n3 +3 -0
- package/examples/output/eco-route-insight.n3 +3 -0
- package/examples/output/genetic-knapsack-selection.n3 +3 -0
- package/examples/output/rc-discharge-envelope.n3 +9 -0
- package/examples/output/rc-discharge-envelope.txt +9 -0
- package/examples/output/rdf-dataset.n3 +5 -0
- package/examples/output/rdf-message-flow.n3 +7 -0
- package/examples/output/rdf-messages.n3 +7 -0
- package/examples/output/school-placement-audit.n3 +3 -0
- package/examples/output/smoke-arithmetic.n3 +5 -0
- package/examples/output/smoke-arithmetic.txt +5 -0
- package/examples/output/triple-terms.n3 +5 -0
- package/{see/examples/n3/rc_discharge_envelope.n3 → examples/rc-discharge-envelope.n3} +2 -15
- package/{see/examples/n3/rdf_dataset.n3 → examples/rdf-dataset.n3} +2 -11
- package/{see/examples/n3/rdf_message_flow.n3 → examples/rdf-message-flow.n3} +9 -75
- package/{see/examples/n3/rdf_messages.n3 → examples/rdf-messages.n3} +6 -43
- package/{see/examples/n3/school_placement_audit.n3 → examples/school-placement-audit.n3} +2 -14
- package/{see/examples/n3/smoke_arithmetic.n3 → examples/smoke-arithmetic.n3} +3 -5
- package/{see/examples/n3/triple_terms.n3 → examples/triple-terms.n3} +1 -4
- package/eyeling.js +256 -4
- package/lib/builtins.js +6 -0
- package/lib/lexer.js +250 -4
- package/package.json +4 -7
- package/test/api.test.js +65 -8
- package/test/examples.test.js +22 -2
- package/test/package.test.js +16 -2
- package/examples/arcling/README.md +0 -11
- package/examples/input/annotation.ttl +0 -6
- package/examples/input/collection.ttl +0 -13
- package/examples/input/reifies.ttl +0 -10
- package/examples/input/triple-term.ttl +0 -8
- package/examples/output/triple-term.n3 +0 -0
- package/examples/reifies.n3 +0 -8
- package/examples/triple-term.n3 +0 -7
- package/see/README.md +0 -149
- package/see/examples/_see.js +0 -249
- package/see/examples/age.js +0 -1459
- package/see/examples/annotation.js +0 -1320
- package/see/examples/backward.js +0 -1405
- package/see/examples/backward_recursion.js +0 -1504
- package/see/examples/bayes_diagnosis.js +0 -2883
- package/see/examples/bayes_therapy.js +0 -4152
- package/see/examples/bmi.js +0 -3038
- package/see/examples/builtin_coverage.js +0 -2524
- package/see/examples/collection.js +0 -1320
- package/see/examples/complex.js +0 -3762
- package/see/examples/complex_matrix_stability.js +0 -2973
- package/see/examples/composition_of_injective_functions_is_injective.js +0 -2170
- package/see/examples/control_system.js +0 -1918
- package/see/examples/crypto_builtins_tests.js +0 -1489
- package/see/examples/delfour.js +0 -3174
- package/see/examples/digital_product_passport.js +0 -2856
- package/see/examples/dijkstra.js +0 -2070
- package/see/examples/dijkstra_risk_path.js +0 -1874
- package/see/examples/doc/age.md +0 -27
- package/see/examples/doc/annotation.md +0 -24
- package/see/examples/doc/backward.md +0 -26
- package/see/examples/doc/backward_recursion.md +0 -26
- package/see/examples/doc/bayes_diagnosis.md +0 -41
- package/see/examples/doc/bayes_therapy.md +0 -40
- package/see/examples/doc/bmi.md +0 -38
- package/see/examples/doc/builtin_coverage.md +0 -53
- package/see/examples/doc/collection.md +0 -24
- package/see/examples/doc/complex.md +0 -38
- package/see/examples/doc/complex_matrix_stability.md +0 -35
- package/see/examples/doc/composition_of_injective_functions_is_injective.md +0 -24
- package/see/examples/doc/control_system.md +0 -32
- package/see/examples/doc/crypto_builtins_tests.md +0 -27
- package/see/examples/doc/delfour.md +0 -37
- package/see/examples/doc/digital_product_passport.md +0 -36
- package/see/examples/doc/dijkstra.md +0 -28
- package/see/examples/doc/dijkstra_risk_path.md +0 -30
- package/see/examples/doc/dog.md +0 -28
- package/see/examples/doc/eco_route_insight.md +0 -33
- package/see/examples/doc/equals.md +0 -26
- package/see/examples/doc/equivalence_classes_overlap_implies_same_class.md +0 -24
- package/see/examples/doc/euler_identity.md +0 -39
- package/see/examples/doc/ev_roundtrip_planner.md +0 -32
- package/see/examples/doc/existential_rule.md +0 -24
- package/see/examples/doc/expression_eval.md +0 -26
- package/see/examples/doc/family_cousins.md +0 -24
- package/see/examples/doc/fastpow.md +0 -29
- package/see/examples/doc/fibonacci.md +0 -28
- package/see/examples/doc/french_cities.md +0 -28
- package/see/examples/doc/fundamental_theorem_arithmetic.md +0 -36
- package/see/examples/doc/genetic_knapsack_selection.md +0 -29
- package/see/examples/doc/goldbach_1000.md +0 -31
- package/see/examples/doc/good_cobbler.md +0 -27
- package/see/examples/doc/gps.md +0 -35
- package/see/examples/doc/gray_code_counter.md +0 -31
- package/see/examples/doc/greatest_lower_bound_uniqueness.md +0 -24
- package/see/examples/doc/group_inverse_uniqueness.md +0 -24
- package/see/examples/doc/hadamard_approx.md +0 -32
- package/see/examples/doc/hanoi.md +0 -26
- package/see/examples/doc/odrl_dpv_risk_ranked.md +0 -57
- package/see/examples/doc/path_discovery.md +0 -33
- package/see/examples/doc/rc_discharge_envelope.md +0 -33
- package/see/examples/doc/rdf_dataset.md +0 -26
- package/see/examples/doc/rdf_message_flow.md +0 -35
- package/see/examples/doc/rdf_messages.md +0 -37
- package/see/examples/doc/school_placement_audit.md +0 -31
- package/see/examples/doc/smoke_arithmetic.md +0 -31
- package/see/examples/doc/socrates.md +0 -24
- package/see/examples/doc/triple_terms.md +0 -26
- package/see/examples/doc/wind_turbine.md +0 -37
- package/see/examples/doc/witch.md +0 -28
- package/see/examples/dog.js +0 -1436
- package/see/examples/eco_route_insight.js +0 -2110
- package/see/examples/equals.js +0 -1363
- package/see/examples/equivalence_classes_overlap_implies_same_class.js +0 -1792
- package/see/examples/euler_identity.js +0 -2038
- package/see/examples/ev_roundtrip_planner.js +0 -2562
- package/see/examples/existential_rule.js +0 -1363
- package/see/examples/expression_eval.js +0 -1798
- package/see/examples/family_cousins.js +0 -1586
- package/see/examples/fastpow.js +0 -2207
- package/see/examples/fibonacci.js +0 -1594
- package/see/examples/french_cities.js +0 -1492
- package/see/examples/fundamental_theorem_arithmetic.js +0 -2106
- package/see/examples/genetic_knapsack_selection.js +0 -1743
- package/see/examples/goldbach_1000.js +0 -1798
- package/see/examples/good_cobbler.js +0 -1396
- package/see/examples/gps.js +0 -2813
- package/see/examples/gray_code_counter.js +0 -1641
- package/see/examples/greatest_lower_bound_uniqueness.js +0 -1918
- package/see/examples/group_inverse_uniqueness.js +0 -1897
- package/see/examples/hadamard_approx.js +0 -4417
- package/see/examples/hanoi.js +0 -1625
- package/see/examples/input/age.trig +0 -27
- package/see/examples/input/backward.trig +0 -25
- package/see/examples/input/bayes_diagnosis.trig +0 -111
- package/see/examples/input/bayes_therapy.trig +0 -130
- package/see/examples/input/bmi.trig +0 -28
- package/see/examples/input/complex.trig +0 -26
- package/see/examples/input/complex_matrix_stability.trig +0 -65
- package/see/examples/input/composition_of_injective_functions_is_injective.trig +0 -35
- package/see/examples/input/control_system.trig +0 -31
- package/see/examples/input/crypto_builtins_tests.trig +0 -25
- package/see/examples/input/delfour.trig +0 -90
- package/see/examples/input/digital_product_passport.trig +0 -116
- package/see/examples/input/dijkstra.trig +0 -34
- package/see/examples/input/dog.trig +0 -31
- package/see/examples/input/equals.trig +0 -25
- package/see/examples/input/equivalence_classes_overlap_implies_same_class.trig +0 -28
- package/see/examples/input/euler_identity.trig +0 -34
- package/see/examples/input/ev_roundtrip_planner.trig +0 -90
- package/see/examples/input/existential_rule.trig +0 -26
- package/see/examples/input/expression_eval.trig +0 -41
- package/see/examples/input/family_cousins.trig +0 -39
- package/see/examples/input/fastpow.trig +0 -25
- package/see/examples/input/fibonacci.trig +0 -51
- package/see/examples/input/french_cities.trig +0 -38
- package/see/examples/input/fundamental_theorem_arithmetic.trig +0 -42
- package/see/examples/input/goldbach_1000.trig +0 -53
- package/see/examples/input/good_cobbler.trig +0 -24
- package/see/examples/input/gps.trig +0 -35
- package/see/examples/input/gray_code_counter.trig +0 -33
- package/see/examples/input/greatest_lower_bound_uniqueness.trig +0 -29
- package/see/examples/input/group_inverse_uniqueness.trig +0 -29
- package/see/examples/input/hadamard_approx.trig +0 -32
- package/see/examples/input/hanoi.trig +0 -26
- package/see/examples/input/odrl_dpv_risk_ranked.trig +0 -107
- package/see/examples/input/path-discovery.trig +0 -96448
- package/see/examples/input/path_discovery.trig +0 -29
- package/see/examples/input/socrates.trig +0 -26
- package/see/examples/input/wind_turbine.trig +0 -48
- package/see/examples/input/witch.trig +0 -26
- package/see/examples/n3/age.n3 +0 -28
- package/see/examples/n3/annotation.n3 +0 -7
- package/see/examples/n3/backward.n3 +0 -22
- package/see/examples/n3/bayes_diagnosis.n3 +0 -122
- package/see/examples/n3/bayes_therapy.n3 +0 -149
- package/see/examples/n3/bmi.n3 +0 -145
- package/see/examples/n3/collection.n3 +0 -3
- package/see/examples/n3/complex.n3 +0 -140
- package/see/examples/n3/complex_matrix_stability.n3 +0 -113
- package/see/examples/n3/composition_of_injective_functions_is_injective.n3 +0 -27
- package/see/examples/n3/control_system.n3 +0 -59
- package/see/examples/n3/crypto_builtins_tests.n3 +0 -18
- package/see/examples/n3/delfour.n3 +0 -167
- package/see/examples/n3/digital_product_passport.n3 +0 -156
- package/see/examples/n3/dijkstra.n3 +0 -46
- package/see/examples/n3/dog.n3 +0 -20
- package/see/examples/n3/equals.n3 +0 -11
- package/see/examples/n3/equivalence_classes_overlap_implies_same_class.n3 +0 -19
- package/see/examples/n3/euler_identity.n3 +0 -41
- package/see/examples/n3/ev_roundtrip_planner.n3 +0 -82
- package/see/examples/n3/existential_rule.n3 +0 -10
- package/see/examples/n3/expression_eval.n3 +0 -21
- package/see/examples/n3/family_cousins.n3 +0 -62
- package/see/examples/n3/fastpow.n3 +0 -56
- package/see/examples/n3/fibonacci.n3 +0 -44
- package/see/examples/n3/french_cities.n3 +0 -28
- package/see/examples/n3/fundamental_theorem_arithmetic.n3 +0 -84
- package/see/examples/n3/goldbach_1000.n3 +0 -66
- package/see/examples/n3/good_cobbler.n3 +0 -10
- package/see/examples/n3/gps.n3 +0 -70
- package/see/examples/n3/gray_code_counter.n3 +0 -53
- package/see/examples/n3/greatest_lower_bound_uniqueness.n3 +0 -20
- package/see/examples/n3/group_inverse_uniqueness.n3 +0 -19
- package/see/examples/n3/hadamard_approx.n3 +0 -43
- package/see/examples/n3/hanoi.n3 +0 -16
- package/see/examples/n3/odrl_dpv_risk_ranked.n3 +0 -460
- package/see/examples/n3/path_discovery.n3 +0 -43
- package/see/examples/n3/socrates.n3 +0 -21
- package/see/examples/n3/wind_turbine.n3 +0 -85
- package/see/examples/n3/witch.n3 +0 -30
- package/see/examples/odrl_dpv_risk_ranked.js +0 -5128
- package/see/examples/output/age.md +0 -48
- package/see/examples/output/annotation.md +0 -43
- package/see/examples/output/backward.md +0 -50
- package/see/examples/output/backward_recursion.md +0 -54
- package/see/examples/output/bayes_diagnosis.md +0 -103
- package/see/examples/output/bayes_therapy.md +0 -84
- package/see/examples/output/bmi.md +0 -164
- package/see/examples/output/builtin_coverage.md +0 -99
- package/see/examples/output/collection.md +0 -44
- package/see/examples/output/complex.md +0 -61
- package/see/examples/output/complex_matrix_stability.md +0 -55
- package/see/examples/output/composition_of_injective_functions_is_injective.md +0 -62
- package/see/examples/output/control_system.md +0 -61
- package/see/examples/output/crypto_builtins_tests.md +0 -68
- package/see/examples/output/delfour.md +0 -100
- package/see/examples/output/digital_product_passport.md +0 -100
- package/see/examples/output/dijkstra.md +0 -74
- package/see/examples/output/dijkstra_risk_path.md +0 -76
- package/see/examples/output/dog.md +0 -50
- package/see/examples/output/eco_route_insight.md +0 -88
- package/see/examples/output/equals.md +0 -50
- package/see/examples/output/equivalence_classes_overlap_implies_same_class.md +0 -86
- package/see/examples/output/euler_identity.md +0 -73
- package/see/examples/output/ev_roundtrip_planner.md +0 -79
- package/see/examples/output/existential_rule.md +0 -54
- package/see/examples/output/expression_eval.md +0 -50
- package/see/examples/output/family_cousins.md +0 -187
- package/see/examples/output/fastpow.md +0 -36
- package/see/examples/output/fibonacci.md +0 -53
- package/see/examples/output/french_cities.md +0 -70
- package/see/examples/output/fundamental_theorem_arithmetic.md +0 -101
- package/see/examples/output/genetic_knapsack_selection.md +0 -66
- package/see/examples/output/goldbach_1000.md +0 -58
- package/see/examples/output/good_cobbler.md +0 -54
- package/see/examples/output/gps.md +0 -102
- package/see/examples/output/gray_code_counter.md +0 -68
- package/see/examples/output/greatest_lower_bound_uniqueness.md +0 -60
- package/see/examples/output/group_inverse_uniqueness.md +0 -60
- package/see/examples/output/hadamard_approx.md +0 -510
- package/see/examples/output/hanoi.md +0 -51
- package/see/examples/output/odrl_dpv_risk_ranked.md +0 -139
- package/see/examples/output/path_discovery.md +0 -65
- package/see/examples/output/rc_discharge_envelope.md +0 -102
- package/see/examples/output/rdf_dataset.md +0 -54
- package/see/examples/output/rdf_message_flow.md +0 -198
- package/see/examples/output/rdf_messages.md +0 -134
- package/see/examples/output/school_placement_audit.md +0 -99
- package/see/examples/output/smoke_arithmetic.md +0 -54
- package/see/examples/output/socrates.md +0 -55
- package/see/examples/output/triple_terms.md +0 -53
- package/see/examples/output/wind_turbine.md +0 -108
- package/see/examples/output/witch.md +0 -87
- package/see/examples/path_discovery.js +0 -1774
- package/see/examples/rc_discharge_envelope.js +0 -1993
- package/see/examples/rdf_dataset.js +0 -1512
- package/see/examples/rdf_message_flow.js +0 -2580
- package/see/examples/rdf_messages.js +0 -2176
- package/see/examples/school_placement_audit.js +0 -1867
- package/see/examples/smoke_arithmetic.js +0 -1483
- package/see/examples/socrates.js +0 -1420
- package/see/examples/triple_terms.js +0 -1442
- package/see/examples/wind_turbine.js +0 -2853
- package/see/examples/witch.js +0 -1519
- package/see/see.js +0 -2179
- package/test/see.test.js +0 -159
- /package/{see/examples/n3/builtin_coverage.n3 → examples/builtin-coverage.n3} +0 -0
- /package/examples/output/{reifies.n3 → builtin-coverage.n3} +0 -0
package/lib/lexer.js
CHANGED
|
@@ -355,6 +355,7 @@ function stripQuotes(lex) {
|
|
|
355
355
|
// - A top-level default graph block { ... } is unwrapped into ordinary triples.
|
|
356
356
|
// This keeps all downstream parsing/reasoning N3-only.
|
|
357
357
|
const LOG_NAME_OF_IRI = '<http://www.w3.org/2000/10/swap/log#nameOf>';
|
|
358
|
+
const RDF_REIFIES_IRI = '<http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies>';
|
|
358
359
|
|
|
359
360
|
function normalizeRdfCompatibility(inputText) {
|
|
360
361
|
let text = String(inputText ?? '');
|
|
@@ -363,11 +364,12 @@ function normalizeRdfCompatibility(inputText) {
|
|
|
363
364
|
// surface-syntax normalization. Avoid scanning large files character-by-character
|
|
364
365
|
// unless they actually contain RDF 1.2 triple terms, VERSION directives, or a
|
|
365
366
|
// plausible top-level TriG named graph block.
|
|
366
|
-
const hasTripleTerms = text.includes('<<
|
|
367
|
+
const hasTripleTerms = text.includes('<<');
|
|
367
368
|
const hasVersionDirective = /^\s*(?:@version|VERSION)\s+(["'])1\.2\1\s*\.?\s*(?:#.*)?$/im.test(text);
|
|
368
369
|
const hasNamedGraphCandidate = /(?:^|[.\r\n])\s*(?:GRAPH\s+)?(?:<[^>\r\n]*>|_:[A-Za-z][A-Za-z0-9_-]*|[A-Za-z][A-Za-z0-9_-]*:[^\s{};,.()[\]]*)\s*\{/m.test(text);
|
|
370
|
+
const hasAnnotationSyntax = /(?:^|\s)~\s*(?:<|_:[A-Za-z]|[A-Za-z][A-Za-z0-9_-]*:|\{\|)|\{\|/.test(text);
|
|
369
371
|
|
|
370
|
-
if (!hasTripleTerms && !hasVersionDirective && !hasNamedGraphCandidate) return text;
|
|
372
|
+
if (!hasTripleTerms && !hasVersionDirective && !hasNamedGraphCandidate && !hasAnnotationSyntax) return text;
|
|
371
373
|
|
|
372
374
|
function isWordChar(ch) {
|
|
373
375
|
return ch != null && /[A-Za-z0-9_:-]/.test(ch);
|
|
@@ -429,11 +431,67 @@ function normalizeRdfCompatibility(inputText) {
|
|
|
429
431
|
|
|
430
432
|
function convertTripleTerms(s) {
|
|
431
433
|
let i = 0;
|
|
434
|
+
const reifierTriples = [];
|
|
432
435
|
|
|
433
436
|
function startsAt(needle, at = i) {
|
|
434
437
|
return s.startsWith(needle, at);
|
|
435
438
|
}
|
|
436
439
|
|
|
440
|
+
function splitTopLevelReifier(body) {
|
|
441
|
+
let depthBrace = 0;
|
|
442
|
+
let depthBracket = 0;
|
|
443
|
+
let depthParen = 0;
|
|
444
|
+
for (let j = 0; j < body.length; j++) {
|
|
445
|
+
const ch = body[j];
|
|
446
|
+
if (ch === '"' || ch === "'") {
|
|
447
|
+
const str = readStringAt(body, j);
|
|
448
|
+
j = str.end - 1;
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
if (ch === '<') {
|
|
452
|
+
const iri = readIriAt(body, j);
|
|
453
|
+
j = iri.end - 1;
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
if (ch === '#') {
|
|
457
|
+
while (j < body.length && body[j] !== '\n' && body[j] !== '\r') j += 1;
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
if (ch === '{') depthBrace += 1;
|
|
461
|
+
else if (ch === '}' && depthBrace > 0) depthBrace -= 1;
|
|
462
|
+
else if (ch === '[') depthBracket += 1;
|
|
463
|
+
else if (ch === ']' && depthBracket > 0) depthBracket -= 1;
|
|
464
|
+
else if (ch === '(') depthParen += 1;
|
|
465
|
+
else if (ch === ')' && depthParen > 0) depthParen -= 1;
|
|
466
|
+
else if (ch === '~' && depthBrace === 0 && depthBracket === 0 && depthParen === 0) {
|
|
467
|
+
return { triple: body.slice(0, j).trim(), reifier: body.slice(j + 1).trim() };
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return { triple: body.trim(), reifier: '' };
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function firstTerm(text) {
|
|
474
|
+
const at = skipWsAndComments(text, 0);
|
|
475
|
+
if (at >= text.length) return '';
|
|
476
|
+
if (text[at] === '<') return readIriAt(text, at).text;
|
|
477
|
+
let j = at;
|
|
478
|
+
while (j < text.length && !/\s/.test(text[j]) && !'{}[](),;.'.includes(text[j])) j += 1;
|
|
479
|
+
return text.slice(at, j);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function graphTermFromTripleBody(rawBody, parenthesized) {
|
|
483
|
+
let body = rawBody.trim();
|
|
484
|
+
if (parenthesized && body.startsWith('(') && body.endsWith(')')) body = body.slice(1, -1).trim();
|
|
485
|
+
const split = splitTopLevelReifier(body);
|
|
486
|
+
const triple = split.triple;
|
|
487
|
+
const graph = '{ ' + triple + ' }';
|
|
488
|
+
if (split.reifier) {
|
|
489
|
+
const reifier = firstTerm(split.reifier);
|
|
490
|
+
if (reifier) reifierTriples.push(`${reifier} ${RDF_REIFIES_IRI} ${graph} .`);
|
|
491
|
+
}
|
|
492
|
+
return graph;
|
|
493
|
+
}
|
|
494
|
+
|
|
437
495
|
function convertUntil(stopToken) {
|
|
438
496
|
let out = '';
|
|
439
497
|
while (i < s.length) {
|
|
@@ -443,7 +501,12 @@ function normalizeRdfCompatibility(inputText) {
|
|
|
443
501
|
}
|
|
444
502
|
if (startsAt('<<(')) {
|
|
445
503
|
i += 3;
|
|
446
|
-
out +=
|
|
504
|
+
out += graphTermFromTripleBody(convertUntil(')>>'), false);
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
if (startsAt('<<')) {
|
|
508
|
+
i += 2;
|
|
509
|
+
out += graphTermFromTripleBody(convertUntil('>>'), false);
|
|
447
510
|
continue;
|
|
448
511
|
}
|
|
449
512
|
const ch = s[i];
|
|
@@ -474,7 +537,189 @@ function normalizeRdfCompatibility(inputText) {
|
|
|
474
537
|
return out;
|
|
475
538
|
}
|
|
476
539
|
|
|
477
|
-
|
|
540
|
+
const converted = convertUntil(null);
|
|
541
|
+
if (reifierTriples.length === 0) return converted;
|
|
542
|
+
return converted + (converted.endsWith('\n') ? '' : '\n') + reifierTriples.join('\n') + '\n';
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
function convertAnnotations(s) {
|
|
547
|
+
let out = '';
|
|
548
|
+
let i = 0;
|
|
549
|
+
let statementStart = true;
|
|
550
|
+
let generatedBlank = 0;
|
|
551
|
+
|
|
552
|
+
function readBalancedDelimited(s, at, open, close) {
|
|
553
|
+
if (!s.startsWith(open, at)) return null;
|
|
554
|
+
let j = at + open.length;
|
|
555
|
+
let depth = 1;
|
|
556
|
+
while (j < s.length) {
|
|
557
|
+
const ch = s[j];
|
|
558
|
+
if (ch === '"' || ch === "'") {
|
|
559
|
+
j = readStringAt(s, j).end;
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
if (ch === '<' && !s.startsWith('<<', j)) {
|
|
563
|
+
j = readIriAt(s, j).end;
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
if (ch === '#') {
|
|
567
|
+
while (j < s.length && s[j] !== '\n' && s[j] !== '\r') j += 1;
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
if (s.startsWith(open, j)) {
|
|
571
|
+
depth += 1;
|
|
572
|
+
j += open.length;
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
if (s.startsWith(close, j)) {
|
|
576
|
+
depth -= 1;
|
|
577
|
+
j += close.length;
|
|
578
|
+
if (depth === 0) return { text: s.slice(at, j), inner: s.slice(at + open.length, j - close.length), end: j };
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
j += 1;
|
|
582
|
+
}
|
|
583
|
+
throw new N3SyntaxError(`Unterminated RDF annotation block, expected ${close}`);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function readTermLikeAt(s, at) {
|
|
587
|
+
const j = skipWsAndComments(s, at);
|
|
588
|
+
if (j >= s.length) return null;
|
|
589
|
+
if (s[j] === '<') return readIriAt(s, j);
|
|
590
|
+
if (s[j] === '"' || s[j] === "'") {
|
|
591
|
+
const str = readStringAt(s, j);
|
|
592
|
+
let end = str.end;
|
|
593
|
+
let text = str.text;
|
|
594
|
+
if (s.startsWith('^^', end)) {
|
|
595
|
+
const dt = readTermAt(s, end + 2);
|
|
596
|
+
if (dt) {
|
|
597
|
+
text += '^^' + dt.text;
|
|
598
|
+
end = dt.end;
|
|
599
|
+
}
|
|
600
|
+
} else if (s[end] === '@') {
|
|
601
|
+
let k = end + 1;
|
|
602
|
+
if (/[A-Za-z]/.test(s[k] || '')) {
|
|
603
|
+
while (k < s.length && /[A-Za-z0-9-]/.test(s[k])) k += 1;
|
|
604
|
+
text += s.slice(end, k);
|
|
605
|
+
end = k;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return { text, end };
|
|
609
|
+
}
|
|
610
|
+
if (s[j] === '{') return readBalancedBlock(s, j);
|
|
611
|
+
if (s[j] === '[') return readBalancedDelimited(s, j, '[', ']');
|
|
612
|
+
if (s[j] === '(') return readBalancedDelimited(s, j, '(', ')');
|
|
613
|
+
return readTermAt(s, j);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function readAnnotationBlockAt(s, at) {
|
|
617
|
+
if (!s.startsWith('{|', at)) return null;
|
|
618
|
+
return readBalancedDelimited(s, at, '{|', '|}');
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function tryReadAnnotatedTriple(at) {
|
|
622
|
+
const start = skipWsAndComments(s, at);
|
|
623
|
+
if (start >= s.length) return null;
|
|
624
|
+
if (s[start] === '@') return null;
|
|
625
|
+
if (startsWordAt(s, 'PREFIX', start) || startsWordAt(s, 'BASE', start) || startsWordAt(s, 'VERSION', start)) return null;
|
|
626
|
+
if (startsWordAt(s, 'GRAPH', start)) return null;
|
|
627
|
+
|
|
628
|
+
const subj = readTermLikeAt(s, start);
|
|
629
|
+
if (!subj) return null;
|
|
630
|
+
let j = skipWsAndComments(s, subj.end);
|
|
631
|
+
const pred = readTermLikeAt(s, j);
|
|
632
|
+
if (!pred) return null;
|
|
633
|
+
j = skipWsAndComments(s, pred.end);
|
|
634
|
+
const obj = readTermLikeAt(s, j);
|
|
635
|
+
if (!obj) return null;
|
|
636
|
+
j = skipWsAndComments(s, obj.end);
|
|
637
|
+
if (s[j] !== '~' && !s.startsWith('{|', j)) return null;
|
|
638
|
+
|
|
639
|
+
let reifier = '';
|
|
640
|
+
const annotationBlocks = [];
|
|
641
|
+
while (j < s.length) {
|
|
642
|
+
j = skipWsAndComments(s, j);
|
|
643
|
+
if (s[j] === '~') {
|
|
644
|
+
j += 1;
|
|
645
|
+
j = skipWsAndComments(s, j);
|
|
646
|
+
const term = readTermAt(s, j);
|
|
647
|
+
if (term) {
|
|
648
|
+
reifier = term.text;
|
|
649
|
+
j = term.end;
|
|
650
|
+
} else if (!reifier) {
|
|
651
|
+
reifier = `_:rdfAnnotation${++generatedBlank}`;
|
|
652
|
+
}
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
if (s.startsWith('{|', j)) {
|
|
656
|
+
const block = readAnnotationBlockAt(s, j);
|
|
657
|
+
if (!reifier) reifier = `_:rdfAnnotation${++generatedBlank}`;
|
|
658
|
+
annotationBlocks.push(block.inner.trim());
|
|
659
|
+
j = block.end;
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
break;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
const after = skipWsAndComments(s, j);
|
|
666
|
+
if (s[after] !== '.') return null;
|
|
667
|
+
if (!reifier && annotationBlocks.length === 0) return null;
|
|
668
|
+
|
|
669
|
+
const baseTriple = `${subj.text} ${pred.text} ${obj.text}`;
|
|
670
|
+
const graph = `{ ${baseTriple} }`;
|
|
671
|
+
const extra = [];
|
|
672
|
+
if (reifier) extra.push(`${reifier} ${RDF_REIFIES_IRI} ${graph} .`);
|
|
673
|
+
for (const inner of annotationBlocks) {
|
|
674
|
+
if (inner) extra.push(`${reifier} ${inner} .`);
|
|
675
|
+
}
|
|
676
|
+
return {
|
|
677
|
+
start,
|
|
678
|
+
end: after + 1,
|
|
679
|
+
text: `${baseTriple} .${extra.length ? '\n' + extra.join('\n') : ''}`,
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
while (i < s.length) {
|
|
684
|
+
if (statementStart) {
|
|
685
|
+
const converted = tryReadAnnotatedTriple(i);
|
|
686
|
+
if (converted) {
|
|
687
|
+
out += s.slice(i, converted.start) + converted.text;
|
|
688
|
+
i = converted.end;
|
|
689
|
+
statementStart = true;
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
const ch = s[i];
|
|
695
|
+
if (ch === '"' || ch === "'") {
|
|
696
|
+
const str = readStringAt(s, i);
|
|
697
|
+
out += str.text;
|
|
698
|
+
i = str.end;
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
if (ch === '<' && !s.startsWith('<<', i)) {
|
|
702
|
+
const iri = readIriAt(s, i);
|
|
703
|
+
out += iri.text;
|
|
704
|
+
i = iri.end;
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
if (ch === '#') {
|
|
708
|
+
while (i < s.length) {
|
|
709
|
+
const c = s[i++];
|
|
710
|
+
out += c;
|
|
711
|
+
if (c === '\n' || c === '\r') break;
|
|
712
|
+
}
|
|
713
|
+
statementStart = true;
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
out += ch;
|
|
717
|
+
if (ch === '.' || ch === '{' || ch === '}' || ch === '\n' || ch === '\r') statementStart = true;
|
|
718
|
+
else if (!/\s/.test(ch)) statementStart = false;
|
|
719
|
+
i += 1;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
return out;
|
|
478
723
|
}
|
|
479
724
|
|
|
480
725
|
function stripVersionDirectives(s) {
|
|
@@ -633,6 +878,7 @@ function normalizeRdfCompatibility(inputText) {
|
|
|
633
878
|
}
|
|
634
879
|
|
|
635
880
|
if (hasTripleTerms) text = convertTripleTerms(text);
|
|
881
|
+
if (hasAnnotationSyntax) text = convertAnnotations(text);
|
|
636
882
|
if (hasVersionDirective) text = stripVersionDirectives(text);
|
|
637
883
|
if (hasVersionDirective || hasNamedGraphCandidate) text = normalizeNamedGraphs(text);
|
|
638
884
|
return text;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eyeling",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.6",
|
|
4
4
|
"description": "A minimal Notation3 (N3) reasoner in JavaScript.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -31,26 +31,23 @@
|
|
|
31
31
|
"lib",
|
|
32
32
|
"test",
|
|
33
33
|
"tools",
|
|
34
|
-
"examples"
|
|
35
|
-
"see"
|
|
34
|
+
"examples"
|
|
36
35
|
],
|
|
37
36
|
"engines": {
|
|
38
37
|
"node": ">=18"
|
|
39
38
|
},
|
|
40
39
|
"scripts": {
|
|
41
40
|
"prebuild": "eslint . --fix",
|
|
42
|
-
"
|
|
43
|
-
"build": "npm run generate && node tools/bundle.js",
|
|
41
|
+
"build": "node tools/bundle.js",
|
|
44
42
|
"test:packlist": "node test/packlist.test.js",
|
|
45
43
|
"test:api": "node test/api.test.js",
|
|
46
44
|
"test:builtins": "node test/builtins.test.js",
|
|
47
45
|
"test:examples": "node test/examples.test.js",
|
|
48
|
-
"test:see": "node test/see.test.js",
|
|
49
46
|
"test:manifest": "node test/manifest.test.js",
|
|
50
47
|
"test:playground": "node test/playground.test.js",
|
|
51
48
|
"test:package": "node test/package.test.js",
|
|
52
49
|
"pretest": "npm run build && npm run test:packlist",
|
|
53
|
-
"test": "npm run test:api && npm run test:builtins && npm run test:examples && npm run test:
|
|
50
|
+
"test": "npm run test:api && npm run test:builtins && npm run test:examples && npm run test:manifest && npm run test:playground",
|
|
54
51
|
"posttest": "npm run test:package",
|
|
55
52
|
"preversion": "npm test",
|
|
56
53
|
"postversion": "git push origin HEAD --follow-tags"
|
package/test/api.test.js
CHANGED
|
@@ -81,6 +81,14 @@ function fail(msg) {
|
|
|
81
81
|
console.error(`${C.r}FAIL${C.n} ${msg}`);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
function unnumberedName(name) {
|
|
85
|
+
return String(name).replace(/^\d+[a-z]*\s+/i, '');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function numberedName(index, name) {
|
|
89
|
+
return `${String(index + 1).padStart(3, '0')} ${unnumberedName(name)}`;
|
|
90
|
+
}
|
|
91
|
+
|
|
84
92
|
function msNow() {
|
|
85
93
|
return Date.now();
|
|
86
94
|
}
|
|
@@ -2572,6 +2580,46 @@ _:b a ex:Person ; ex:name "B" .
|
|
|
2572
2580
|
expect: [/:observation\s+:entails\s+<<\(\s+:sensor\s+:needs\s+:inspection\s*\)>>\s*\./m],
|
|
2573
2581
|
},
|
|
2574
2582
|
|
|
2583
|
+
{
|
|
2584
|
+
name: 'RDF mode accepts PREFIX and reified triple terms with reifiers',
|
|
2585
|
+
opt: { proofComments: false, rdf: true },
|
|
2586
|
+
input: `VERSION "1.2"
|
|
2587
|
+
|
|
2588
|
+
PREFIX : <http://www.example.org/>
|
|
2589
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
|
2590
|
+
|
|
2591
|
+
<<:employee38 :jobTitle "Assistant Designer" ~ _:id>> :accordingTo :employee22 .
|
|
2592
|
+
|
|
2593
|
+
{ ?S ?P ?O } log:query { ?S ?P ?O } .
|
|
2594
|
+
`,
|
|
2595
|
+
expect: [
|
|
2596
|
+
/<<\(\s*:employee38\s+:jobTitle\s+"Assistant Designer"\s*\)>>\s+:accordingTo\s+:employee22\s*\./m,
|
|
2597
|
+
/_:id\s+(?:rdf:reifies|<http:\/\/www\.w3\.org\/1999\/02\/22-rdf-syntax-ns#reifies>)\s+<<\(\s*:employee38\s+:jobTitle\s+"Assistant Designer"\s*\)>>\s*\./m,
|
|
2598
|
+
],
|
|
2599
|
+
},
|
|
2600
|
+
|
|
2601
|
+
{
|
|
2602
|
+
name: 'RDF mode accepts RDF 1.2 annotation syntax after objects',
|
|
2603
|
+
opt: { proofComments: false, rdf: true },
|
|
2604
|
+
input: `VERSION "1.2"
|
|
2605
|
+
|
|
2606
|
+
PREFIX : <http://example.com/>
|
|
2607
|
+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
|
2608
|
+
|
|
2609
|
+
:a :name "Alice" ~ :t {| :statedBy :bob ; :recorded "2021-07-07"^^xsd:date |} .
|
|
2610
|
+
|
|
2611
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
2612
|
+
|
|
2613
|
+
{ ?S ?P ?O } log:query { ?S ?P ?O }.
|
|
2614
|
+
`,
|
|
2615
|
+
expect: [
|
|
2616
|
+
/:a\s+:name\s+"Alice"\s*\./m,
|
|
2617
|
+
/:t\s+(?:rdf:reifies|<http:\/\/www\.w3\.org\/1999\/02\/22-rdf-syntax-ns#reifies>)\s+<<\(\s*:a\s+:name\s+"Alice"\s*\)>>\s*\./m,
|
|
2618
|
+
/:t\s+:statedBy\s+:bob\s*\./m,
|
|
2619
|
+
/:t\s+:recorded\s+"2021-07-07"\^\^xsd:date\s*\./m,
|
|
2620
|
+
],
|
|
2621
|
+
},
|
|
2622
|
+
|
|
2575
2623
|
{
|
|
2576
2624
|
name: 'RDF mode serializes only valid triple terms as RDF 1.2 triple terms',
|
|
2577
2625
|
opt: { proofComments: false, rdf: true },
|
|
@@ -2624,6 +2672,14 @@ _:b a ex:Person ; ex:name "B" .
|
|
|
2624
2672
|
/:audit\s+\{[\s\S]*:workOrder\s+:basedOn\s+:factoryDataset\s*\.[\s\S]*\}/m,
|
|
2625
2673
|
],
|
|
2626
2674
|
},
|
|
2675
|
+
{
|
|
2676
|
+
name: 'API empty input returns empty output',
|
|
2677
|
+
opt: { proofComments: false },
|
|
2678
|
+
input: '',
|
|
2679
|
+
check(out) {
|
|
2680
|
+
assert.equal(out, '');
|
|
2681
|
+
},
|
|
2682
|
+
},
|
|
2627
2683
|
];
|
|
2628
2684
|
|
|
2629
2685
|
|
|
@@ -2634,7 +2690,8 @@ let failed = 0;
|
|
|
2634
2690
|
const suiteStart = Date.now();
|
|
2635
2691
|
info(`Running ${cases.length} API tests (independent of examples/)`);
|
|
2636
2692
|
|
|
2637
|
-
for (const tc of cases) {
|
|
2693
|
+
for (const [index, tc] of cases.entries()) {
|
|
2694
|
+
const testName = numberedName(index, tc.name);
|
|
2638
2695
|
const start = msNow();
|
|
2639
2696
|
try {
|
|
2640
2697
|
const out = typeof tc.run === 'function' ? await tc.run() : reasonQuiet(tc.opt, tc.input);
|
|
@@ -2643,24 +2700,24 @@ let failed = 0;
|
|
|
2643
2700
|
throw new Error(`Expected an error, but reason() returned output:\n${out}`);
|
|
2644
2701
|
}
|
|
2645
2702
|
|
|
2646
|
-
for (const re of tc.expect || []) mustMatch(out, re, `${
|
|
2647
|
-
for (const re of tc.notExpect || []) mustNotMatch(out, re, `${
|
|
2703
|
+
for (const re of tc.expect || []) mustMatch(out, re, `${testName}: missing expected pattern ${re}`);
|
|
2704
|
+
for (const re of tc.notExpect || []) mustNotMatch(out, re, `${testName}: unexpected pattern ${re}`);
|
|
2648
2705
|
|
|
2649
2706
|
if (typeof tc.check === 'function') tc.check(out, tc);
|
|
2650
2707
|
|
|
2651
2708
|
const dur = msNow() - start;
|
|
2652
|
-
ok(`${
|
|
2709
|
+
ok(`${testName} ${C.dim}(${dur} ms)${C.n}`);
|
|
2653
2710
|
passed++;
|
|
2654
2711
|
} catch (e) {
|
|
2655
2712
|
const dur = msNow() - start;
|
|
2656
2713
|
|
|
2657
2714
|
if (tc.expectErrorCode != null) {
|
|
2658
2715
|
if (e && typeof e === 'object' && 'code' in e && e.code === tc.expectErrorCode) {
|
|
2659
|
-
ok(`${
|
|
2716
|
+
ok(`${testName} ${C.dim}(expected exit ${tc.expectErrorCode}, ${dur} ms)${C.n}`);
|
|
2660
2717
|
passed++;
|
|
2661
2718
|
continue;
|
|
2662
2719
|
}
|
|
2663
|
-
fail(`${
|
|
2720
|
+
fail(`${testName} ${C.dim}(${dur} ms)${C.n}`);
|
|
2664
2721
|
fail(
|
|
2665
2722
|
`Expected exit code ${tc.expectErrorCode}, got: ${e && e.code != null ? e.code : 'unknown'}\n${
|
|
2666
2723
|
e && e.stderr ? e.stderr : e && e.stack ? e.stack : String(e)
|
|
@@ -2671,12 +2728,12 @@ let failed = 0;
|
|
|
2671
2728
|
}
|
|
2672
2729
|
|
|
2673
2730
|
if (tc.expectError) {
|
|
2674
|
-
ok(`${
|
|
2731
|
+
ok(`${testName} ${C.dim}(expected error, ${dur} ms)${C.n}`);
|
|
2675
2732
|
passed++;
|
|
2676
2733
|
continue;
|
|
2677
2734
|
}
|
|
2678
2735
|
|
|
2679
|
-
fail(`${
|
|
2736
|
+
fail(`${testName} ${C.dim}(${dur} ms)${C.n}`);
|
|
2680
2737
|
fail(e && e.stack ? e.stack : String(e));
|
|
2681
2738
|
failed++;
|
|
2682
2739
|
}
|
package/test/examples.test.js
CHANGED
|
@@ -96,6 +96,14 @@ function resolveExpectedPath(outputDir, inputFile) {
|
|
|
96
96
|
return path.join(outputDir, candidates[0]);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
function resolveExampleTrigInput(root, inputFile) {
|
|
100
|
+
const stem = path.basename(inputFile, path.extname(inputFile));
|
|
101
|
+
const rel = path.join('input', `${stem}.trig`);
|
|
102
|
+
const abs = path.join(root, 'examples', rel);
|
|
103
|
+
if (!fs.existsSync(abs)) return null;
|
|
104
|
+
return { abs, rel };
|
|
105
|
+
}
|
|
106
|
+
|
|
99
107
|
function resolveExampleBuiltinPath(root, inputFile) {
|
|
100
108
|
const stem = path.basename(inputFile, path.extname(inputFile));
|
|
101
109
|
const rel = path.join('examples', 'builtin', `${stem}.js`);
|
|
@@ -182,19 +190,31 @@ function main() {
|
|
|
182
190
|
// load it for the matching examples/<stem>.n3 file. Builtin-backed examples
|
|
183
191
|
// run from the repository root so the command shape matches documented usage:
|
|
184
192
|
// node eyeling.js --builtin examples/builtin/foo.js examples/foo.n3
|
|
193
|
+
// A matching examples/input/<stem>.trig sidecar is external RDF/TriG
|
|
194
|
+
// evidence for this example, so include it and run in -r mode automatically.
|
|
185
195
|
const builtin = resolveExampleBuiltinPath(root, file);
|
|
196
|
+
const trigInput = resolveExampleTrigInput(root, file);
|
|
197
|
+
const rdfMode = !!trigInput;
|
|
186
198
|
const outFd = fs.openSync(generatedPath, 'w');
|
|
187
199
|
let r;
|
|
188
200
|
try {
|
|
189
201
|
if (builtin) {
|
|
190
|
-
|
|
202
|
+
const args = [eyelingJsPath, '-d'];
|
|
203
|
+
if (rdfMode) args.push('-r');
|
|
204
|
+
args.push('--builtin', builtin.rel, path.join('examples', file));
|
|
205
|
+
if (trigInput) args.push(path.join('examples', trigInput.rel));
|
|
206
|
+
r = cp.spawnSync(nodePath, args, {
|
|
191
207
|
cwd: root,
|
|
192
208
|
stdio: ['ignore', outFd, 'pipe'], // stdout -> file, stderr captured
|
|
193
209
|
maxBuffer: 200 * 1024 * 1024,
|
|
194
210
|
encoding: 'utf8',
|
|
195
211
|
});
|
|
196
212
|
} else {
|
|
197
|
-
|
|
213
|
+
const args = [eyelingJsPath, '-d'];
|
|
214
|
+
if (rdfMode) args.push('-r');
|
|
215
|
+
args.push(file);
|
|
216
|
+
if (trigInput) args.push(trigInput.rel);
|
|
217
|
+
r = cp.spawnSync(nodePath, args, {
|
|
198
218
|
cwd: examplesDir,
|
|
199
219
|
stdio: ['ignore', outFd, 'pipe'], // stdout -> file, stderr captured
|
|
200
220
|
maxBuffer: 200 * 1024 * 1024,
|
package/test/package.test.js
CHANGED
|
@@ -73,6 +73,14 @@ function expectedExitCode(n3Text) {
|
|
|
73
73
|
return 0;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
function resolveExampleTrigInput(examplesDir, inputFile) {
|
|
77
|
+
const stem = path.basename(inputFile, path.extname(inputFile));
|
|
78
|
+
const rel = path.join('input', `${stem}.trig`);
|
|
79
|
+
const abs = path.join(examplesDir, rel);
|
|
80
|
+
if (!fs.existsSync(abs)) return null;
|
|
81
|
+
return { abs, rel };
|
|
82
|
+
}
|
|
83
|
+
|
|
76
84
|
function hasGit() {
|
|
77
85
|
const r = run('git', ['--version']);
|
|
78
86
|
return r.status === 0;
|
|
@@ -174,7 +182,7 @@ function main() {
|
|
|
174
182
|
if (!fs.existsSync(eyelingJsPath)) throw new Error(`Missing eyeling.js in installed package: ${eyelingJsPath}`);
|
|
175
183
|
|
|
176
184
|
// Keep this fast: package.test.js is a smoke test. The full matrix is covered by test/examples.test.js in-repo.
|
|
177
|
-
const SMOKE_EXAMPLES = ['age.n3', 'basic-monadic.n3', '
|
|
185
|
+
const SMOKE_EXAMPLES = ['age.n3', 'basic-monadic.n3', 'family-cousins.n3', 'backward.n3', 'context-association.n3'];
|
|
178
186
|
|
|
179
187
|
const tmpExamplesOut = fs.mkdtempSync(path.join(os.tmpdir(), 'eyeling-pkg-examples-'));
|
|
180
188
|
let smokeIdx = 1;
|
|
@@ -192,7 +200,13 @@ function main() {
|
|
|
192
200
|
const n3Text = fs.readFileSync(inputPath, 'utf8');
|
|
193
201
|
const expectedRc = expectedExitCode(n3Text);
|
|
194
202
|
|
|
195
|
-
const
|
|
203
|
+
const trigInput = resolveExampleTrigInput(examplesDir, file);
|
|
204
|
+
const args = [eyelingJsPath, '-d'];
|
|
205
|
+
if (trigInput) args.push('-r');
|
|
206
|
+
args.push(file);
|
|
207
|
+
if (trigInput) args.push(trigInput.rel);
|
|
208
|
+
|
|
209
|
+
const r = cp.spawnSync(process.execPath, args, {
|
|
196
210
|
cwd: examplesDir,
|
|
197
211
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
198
212
|
maxBuffer: 200 * 1024 * 1024,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# ARC-style examples in Eyeling
|
|
2
|
-
|
|
3
|
-
This content is now integrated into the handbook:
|
|
4
|
-
|
|
5
|
-
- [Appendix F — The ARC approach: Answer • Reason Why • Check](../../HANDBOOK.md#app-f)
|
|
6
|
-
|
|
7
|
-
That appendix now includes:
|
|
8
|
-
|
|
9
|
-
- a brief explanation of ARC,
|
|
10
|
-
- a brief explanation of the Insight Economy,
|
|
11
|
-
- and links to the ARC-style examples in `examples/` together with their outputs in `examples/output/`.
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|
2
|
-
PREFIX : <http://example.org/stuff/1.0/>
|
|
3
|
-
|
|
4
|
-
_:b0 :p2 :q2 .
|
|
5
|
-
_:b0 rdf:first 1 ;
|
|
6
|
-
rdf:rest _:b1 .
|
|
7
|
-
_:b1 rdf:first _:b2 .
|
|
8
|
-
_:b2 :p :q .
|
|
9
|
-
_:b1 rdf:rest _:b3 .
|
|
10
|
-
_:b3 rdf:first _:b4 .
|
|
11
|
-
_:b4 rdf:first 2 ;
|
|
12
|
-
rdf:rest rdf:nil .
|
|
13
|
-
_:b3 rdf:rest rdf:nil .
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
VERSION "1.2"
|
|
2
|
-
|
|
3
|
-
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|
4
|
-
PREFIX : <http://www.example.org/>
|
|
5
|
-
|
|
6
|
-
_:b rdf:reifies <<(:Socrates a :Human)>> .
|
|
7
|
-
_:b :is true .
|
|
8
|
-
|
|
9
|
-
:employee38 :familyName "Smith" .
|
|
10
|
-
<<:employee38 :jobTitle "Assistant Designer" ~ _:id>> :accordingTo :employee22 .
|
|
File without changes
|
package/examples/reifies.n3
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
@prefix : <http://www.example.org/> .
|
|
2
|
-
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
|
3
|
-
|
|
4
|
-
_:b log:nameOf { :Socrates a :Human . } .
|
|
5
|
-
_:b :is true .
|
|
6
|
-
:employee38 :familyName "Smith" .
|
|
7
|
-
_:id log:nameOf { :employee38 :jobTitle "Assistant Designer" . } .
|
|
8
|
-
_:id :accordingTo :employee22 .
|
package/examples/triple-term.n3
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
@prefix : <http://www.example.org/> .
|
|
2
|
-
@prefix skolem: <https://eyereasoner.github.io/.well-known/genid/3ce038d5-ea5f-5c1e-8635-dcdabec19d5f#> .
|
|
3
|
-
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
|
4
|
-
|
|
5
|
-
skolem:e38 :familyName "Smith" .
|
|
6
|
-
_:anno log:nameOf { skolem:e38 :jobTitle "Designer" . } .
|
|
7
|
-
_:anno :accordingTo _:e22 .
|