@canopycanopycanopy/b-ber-validator 1.2.13-react-reader.5 → 1.2.13-react-reader.71
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/dist/combinators/close.js +4 -3
- package/dist/combinators/constrained.js +2 -1
- package/dist/combinators/eol.js +2 -2
- package/dist/combinators/eos.js +2 -2
- package/dist/combinators/many.js +1 -1
- package/dist/combinators/map.js +1 -1
- package/dist/combinators/not.js +2 -2
- package/dist/combinators/optional.js +1 -1
- package/dist/combinators/regex.js +2 -2
- package/dist/combinators/required.js +2 -1
- package/dist/combinators/sequence.js +1 -1
- package/dist/combinators/string.js +2 -2
- package/dist/validator.js +53 -53
- package/package.json +5 -5
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.close = void 0;
|
|
4
4
|
const failure_1 = require("../lib/failure");
|
|
5
5
|
const success_1 = require("../lib/success");
|
|
6
|
-
|
|
6
|
+
const close = (parser, matchIndex) => (ctx) => {
|
|
7
7
|
const res = parser(ctx);
|
|
8
8
|
if (!res.success)
|
|
9
9
|
return res;
|
|
@@ -15,7 +15,8 @@ exports.close = (parser, matchIndex) => (ctx) => {
|
|
|
15
15
|
openingRe.lastIndex = nextCtx.index;
|
|
16
16
|
const closingMatch = openingRe.exec(nextCtx.text);
|
|
17
17
|
if ((closingMatch === null || closingMatch === void 0 ? void 0 : closingMatch.index) === nextCtx.index) {
|
|
18
|
-
return success_1.success(Object.assign(Object.assign({}, ctx), { index: endIdx }), nextValue);
|
|
18
|
+
return (0, success_1.success)(Object.assign(Object.assign({}, ctx), { index: endIdx }), nextValue);
|
|
19
19
|
}
|
|
20
|
-
return failure_1.failure(Object.assign(Object.assign({}, ctx), { index: endIdx }), `Closing identifier to match opening identifier ${openingIdent.trim()}`, true);
|
|
20
|
+
return (0, failure_1.failure)(Object.assign(Object.assign({}, ctx), { index: endIdx }), `Closing identifier to match opening identifier ${openingIdent.trim()}`, true);
|
|
21
21
|
};
|
|
22
|
+
exports.close = close;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.constrained = void 0;
|
|
4
4
|
// Value *must* match first parser, and can match second
|
|
5
|
-
|
|
5
|
+
const constrained = (parser1, parser2, expected = 'Valid constraint') => {
|
|
6
6
|
return (ctx) => {
|
|
7
7
|
const res1 = parser1(ctx);
|
|
8
8
|
const res2 = parser2(ctx);
|
|
@@ -14,3 +14,4 @@ exports.constrained = (parser1, parser2, expected = 'Valid constraint') => {
|
|
|
14
14
|
return res2;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
+
exports.constrained = constrained;
|
package/dist/combinators/eol.js
CHANGED
|
@@ -12,9 +12,9 @@ function eol() {
|
|
|
12
12
|
const endIdx = ctx.index + match.length;
|
|
13
13
|
if (ctx.index === ctx.text.length ||
|
|
14
14
|
ctx.text.substring(ctx.index, endIdx) === match) {
|
|
15
|
-
return success_1.success(ctx, new EOL());
|
|
15
|
+
return (0, success_1.success)(ctx, new EOL());
|
|
16
16
|
}
|
|
17
|
-
return failure_1.failure(ctx, 'End of line', true);
|
|
17
|
+
return (0, failure_1.failure)(ctx, 'End of line', true);
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
exports.eol = eol;
|
package/dist/combinators/eos.js
CHANGED
|
@@ -7,7 +7,7 @@ class EOS {
|
|
|
7
7
|
}
|
|
8
8
|
function eos() {
|
|
9
9
|
return (ctx) => ctx.index === ctx.text.length
|
|
10
|
-
? success_1.success(ctx, new EOS())
|
|
11
|
-
: failure_1.failure(ctx, 'End of string');
|
|
10
|
+
? (0, success_1.success)(ctx, new EOS())
|
|
11
|
+
: (0, failure_1.failure)(ctx, 'End of string');
|
|
12
12
|
}
|
|
13
13
|
exports.eos = eos;
|
package/dist/combinators/many.js
CHANGED
package/dist/combinators/map.js
CHANGED
|
@@ -7,7 +7,7 @@ const success_1 = require("../lib/success");
|
|
|
7
7
|
function map(parser, fn) {
|
|
8
8
|
return (ctx) => {
|
|
9
9
|
const res = parser(ctx);
|
|
10
|
-
return res.success ? success_1.success(res.ctx, fn(res.value)) : res;
|
|
10
|
+
return res.success ? (0, success_1.success)(res.ctx, fn(res.value)) : res;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
exports.map = map;
|
package/dist/combinators/not.js
CHANGED
|
@@ -9,10 +9,10 @@ function not(parser) {
|
|
|
9
9
|
while (nextCtx.index < nextCtx.text.length) {
|
|
10
10
|
const res = parser(nextCtx);
|
|
11
11
|
if (res.success)
|
|
12
|
-
return success_1.success(nextCtx, null);
|
|
12
|
+
return (0, success_1.success)(nextCtx, null);
|
|
13
13
|
nextCtx.index += 1;
|
|
14
14
|
}
|
|
15
|
-
return success_1.success(nextCtx, values);
|
|
15
|
+
return (0, success_1.success)(nextCtx, values);
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
exports.not = not;
|
|
@@ -5,6 +5,6 @@ const success_1 = require("../lib/success");
|
|
|
5
5
|
const oneOf_1 = require("./oneOf");
|
|
6
6
|
// Match a parser, or succeed with null
|
|
7
7
|
function optional(parser) {
|
|
8
|
-
return oneOf_1.oneOf([parser, (ctx) => success_1.success(ctx, null)]);
|
|
8
|
+
return (0, oneOf_1.oneOf)([parser, (ctx) => (0, success_1.success)(ctx, null)]);
|
|
9
9
|
}
|
|
10
10
|
exports.optional = optional;
|
|
@@ -9,9 +9,9 @@ function regex(re, expected) {
|
|
|
9
9
|
re.lastIndex = ctx.index;
|
|
10
10
|
const res = re.exec(ctx.text);
|
|
11
11
|
if (res && res.index === ctx.index) {
|
|
12
|
-
return success_1.success(Object.assign(Object.assign({}, ctx), { index: ctx.index + res[0].length }), res[0]);
|
|
12
|
+
return (0, success_1.success)(Object.assign(Object.assign({}, ctx), { index: ctx.index + res[0].length }), res[0]);
|
|
13
13
|
}
|
|
14
|
-
return failure_1.failure(ctx, expected);
|
|
14
|
+
return (0, failure_1.failure)(ctx, expected);
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
exports.regex = regex;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.required = void 0;
|
|
4
4
|
// Returns fatal error to halt parser in case of failure
|
|
5
|
-
|
|
5
|
+
const required = (parser) => {
|
|
6
6
|
return (ctx) => {
|
|
7
7
|
const res = parser(ctx);
|
|
8
8
|
if (!res.success)
|
|
@@ -10,3 +10,4 @@ exports.required = (parser) => {
|
|
|
10
10
|
return res;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
+
exports.required = required;
|
|
@@ -7,9 +7,9 @@ function string(match, expected = '') {
|
|
|
7
7
|
return (ctx) => {
|
|
8
8
|
const endIdx = ctx.index + match.length;
|
|
9
9
|
if (ctx.text.substring(ctx.index, endIdx) === match) {
|
|
10
|
-
return success_1.success(Object.assign(Object.assign({}, ctx), { index: endIdx }), match);
|
|
10
|
+
return (0, success_1.success)(Object.assign(Object.assign({}, ctx), { index: endIdx }), match);
|
|
11
11
|
}
|
|
12
|
-
return failure_1.failure(ctx, expected || match);
|
|
12
|
+
return (0, failure_1.failure)(ctx, expected || match);
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
exports.string = string;
|
package/dist/validator.js
CHANGED
|
@@ -16,94 +16,94 @@ const close_1 = require("./combinators/close");
|
|
|
16
16
|
const required_1 = require("./combinators/required");
|
|
17
17
|
const constrained_1 = require("./combinators/constrained");
|
|
18
18
|
const flat_1 = require("./lib/flat");
|
|
19
|
-
const space = string_1.string(' ', 'Space');
|
|
20
|
-
const spaces = many_1.many(space);
|
|
21
|
-
const newLine = string_1.string('\n', 'Newline');
|
|
22
|
-
const ascii = regex_1.regex(/[\x21\x23-\x26\x28-\x39\x3B-\x7F]+/g, 'ASCII characters'); // ASCII without whitespace, colon, or quotes
|
|
23
|
-
const words = regex_1.regex(/[^'"]+/g, 'Words'); // TODO should be 'not opening character' (i.e., `'` or `"`)
|
|
24
|
-
const quote = oneOf_1.oneOf([string_1.string('"'), string_1.string("'")]);
|
|
19
|
+
const space = (0, string_1.string)(' ', 'Space');
|
|
20
|
+
const spaces = (0, many_1.many)(space);
|
|
21
|
+
const newLine = (0, string_1.string)('\n', 'Newline');
|
|
22
|
+
const ascii = (0, regex_1.regex)(/[\x21\x23-\x26\x28-\x39\x3B-\x7F]+/g, 'ASCII characters'); // ASCII without whitespace, colon, or quotes
|
|
23
|
+
const words = (0, regex_1.regex)(/[^'"]+/g, 'Words'); // TODO should be 'not opening character' (i.e., `'` or `"`)
|
|
24
|
+
const quote = (0, oneOf_1.oneOf)([(0, string_1.string)('"'), (0, string_1.string)("'")]);
|
|
25
25
|
// Strings/RegExps instead of sequences to return complete value in error messages
|
|
26
|
-
const sep = string_1.string(':');
|
|
27
|
-
const delimInline = regex_1.regex(/::(?!:)/g, '::');
|
|
28
|
-
const fenceInline = sequence_1.sequence([regex_1.regex(/\n::(?!:)/g, '::'), required_1.required(space)]);
|
|
29
|
-
const fenceBlock = sequence_1.sequence([regex_1.regex(/\n:::(?!:)/g, ':::'), required_1.required(space)]);
|
|
30
|
-
const body = not_1.not(sequence_1.sequence([newLine, sep, sep]));
|
|
31
|
-
const ident = regex_1.regex(/[a-zA-Z0-9_-]+/g, 'Identifier');
|
|
32
|
-
const exit = regex_1.regex(/exit\b/g, 'Exit');
|
|
26
|
+
const sep = (0, string_1.string)(':');
|
|
27
|
+
const delimInline = (0, regex_1.regex)(/::(?!:)/g, '::');
|
|
28
|
+
const fenceInline = (0, sequence_1.sequence)([(0, regex_1.regex)(/\n::(?!:)/g, '::'), (0, required_1.required)(space)]);
|
|
29
|
+
const fenceBlock = (0, sequence_1.sequence)([(0, regex_1.regex)(/\n:::(?!:)/g, ':::'), (0, required_1.required)(space)]);
|
|
30
|
+
const body = (0, not_1.not)((0, sequence_1.sequence)([newLine, sep, sep]));
|
|
31
|
+
const ident = (0, regex_1.regex)(/[a-zA-Z0-9_-]+/g, 'Identifier');
|
|
32
|
+
const exit = (0, regex_1.regex)(/exit\b/g, 'Exit');
|
|
33
33
|
// Directive attributes
|
|
34
34
|
function attr() {
|
|
35
35
|
const quoteIndex = 3;
|
|
36
|
-
return oneOf_1.oneOf([
|
|
37
|
-
sequence_1.sequence([space, ascii, sep, ascii]),
|
|
38
|
-
close_1.close(map_1.map(sequence_1.sequence([space, ascii, sep, quote, words]), (...args) => flat_1.flat(args)), quoteIndex),
|
|
36
|
+
return (0, oneOf_1.oneOf)([
|
|
37
|
+
(0, sequence_1.sequence)([space, ascii, sep, ascii]),
|
|
38
|
+
(0, close_1.close)((0, map_1.map)((0, sequence_1.sequence)([space, ascii, sep, quote, words]), (...args) => (0, flat_1.flat)(args)), quoteIndex),
|
|
39
39
|
]);
|
|
40
40
|
}
|
|
41
|
-
const attrs = sequence_1.sequence([many_1.many(attr()), optional_1.optional(spaces), eol_1.eol()]);
|
|
41
|
+
const attrs = (0, sequence_1.sequence)([(0, many_1.many)(attr()), (0, optional_1.optional)(spaces), (0, eol_1.eol)()]);
|
|
42
42
|
// Directive RegExp is a directive name followed by a word boundry,
|
|
43
43
|
// that is not followed by a hyphen. This is done to prevent false
|
|
44
44
|
// matches e.g., matching `figure` for `figure-inline`. All directive
|
|
45
45
|
// names are made up of latin a-z and hyphen. `g` flag is set to
|
|
46
46
|
// allow `lastIndex` to be used in the `regex` combinator.
|
|
47
47
|
const directiveRegExp = (s) => new RegExp(`${s}\\b(?!-)`, 'g');
|
|
48
|
-
const inlineNames = Array.from(b_ber_shapes_directives_1.INLINE_DIRECTIVES).map(s => regex_1.regex(directiveRegExp(s), s));
|
|
48
|
+
const inlineNames = Array.from(b_ber_shapes_directives_1.INLINE_DIRECTIVES).map(s => (0, regex_1.regex)(directiveRegExp(s), s));
|
|
49
49
|
const blockNames = Array.from(b_ber_shapes_directives_1.BLOCK_DIRECTIVES)
|
|
50
50
|
.concat(Array.from(b_ber_shapes_directives_1.MISC_DIRECTIVES))
|
|
51
51
|
.concat(Array.from(b_ber_shapes_directives_1.DRAFT_DIRECTIVES))
|
|
52
52
|
.concat(Array.from(b_ber_shapes_directives_1.DEPRECATED_DIRECTIVES))
|
|
53
|
-
.map(s => regex_1.regex(directiveRegExp(s), s));
|
|
54
|
-
const inlineDirectiveName = oneOf_1.oneOf(inlineNames);
|
|
55
|
-
const blockDirectiveName = oneOf_1.oneOf(blockNames);
|
|
56
|
-
const name = oneOf_1.oneOf(inlineNames.concat(blockNames).concat(exit));
|
|
57
|
-
const caption = sequence_1.sequence([
|
|
53
|
+
.map(s => (0, regex_1.regex)(directiveRegExp(s), s));
|
|
54
|
+
const inlineDirectiveName = (0, oneOf_1.oneOf)(inlineNames);
|
|
55
|
+
const blockDirectiveName = (0, oneOf_1.oneOf)(blockNames);
|
|
56
|
+
const name = (0, oneOf_1.oneOf)(inlineNames.concat(blockNames).concat(exit));
|
|
57
|
+
const caption = (0, sequence_1.sequence)([
|
|
58
58
|
fenceInline,
|
|
59
|
-
not_1.not(eol_1.eol()),
|
|
60
|
-
eol_1.eol(),
|
|
61
|
-
required_1.required(newLine),
|
|
62
|
-
required_1.required(delimInline),
|
|
63
|
-
optional_1.optional(spaces),
|
|
64
|
-
eol_1.eol(),
|
|
59
|
+
(0, not_1.not)((0, eol_1.eol)()),
|
|
60
|
+
(0, eol_1.eol)(),
|
|
61
|
+
(0, required_1.required)(newLine),
|
|
62
|
+
(0, required_1.required)(delimInline),
|
|
63
|
+
(0, optional_1.optional)(spaces),
|
|
64
|
+
(0, eol_1.eol)(),
|
|
65
65
|
]);
|
|
66
66
|
function inline() {
|
|
67
|
-
return sequence_1.sequence([
|
|
67
|
+
return (0, sequence_1.sequence)([
|
|
68
68
|
fenceBlock,
|
|
69
|
-
constrained_1.constrained(name, inlineDirectiveName, 'Valid directive name'),
|
|
70
|
-
required_1.required(sep),
|
|
71
|
-
required_1.required(ident),
|
|
69
|
+
(0, constrained_1.constrained)(name, inlineDirectiveName, 'Valid directive name'),
|
|
70
|
+
(0, required_1.required)(sep),
|
|
71
|
+
(0, required_1.required)(ident),
|
|
72
72
|
attrs,
|
|
73
|
-
optional_1.optional(caption),
|
|
73
|
+
(0, optional_1.optional)(caption),
|
|
74
74
|
]);
|
|
75
75
|
}
|
|
76
76
|
function speaker() {
|
|
77
|
-
return sequence_1.sequence([
|
|
77
|
+
return (0, sequence_1.sequence)([
|
|
78
78
|
fenceInline,
|
|
79
|
-
many_1.many(sequence_1.sequence([regex_1.regex(/[^\s:]+/g, 'Word'), space])),
|
|
80
|
-
regex_1.regex(/::(?!:)/g, '::'),
|
|
81
|
-
regex_1.regex(/[^\n]+/g, 'Not newline'),
|
|
82
|
-
eol_1.eol(),
|
|
79
|
+
(0, many_1.many)((0, sequence_1.sequence)([(0, regex_1.regex)(/[^\s:]+/g, 'Word'), space])),
|
|
80
|
+
(0, regex_1.regex)(/::(?!:)/g, '::'),
|
|
81
|
+
(0, regex_1.regex)(/[^\n]+/g, 'Not newline'),
|
|
82
|
+
(0, eol_1.eol)(),
|
|
83
83
|
]);
|
|
84
84
|
}
|
|
85
85
|
function block() {
|
|
86
86
|
const identIndex = 3;
|
|
87
|
-
return close_1.close(map_1.map(sequence_1.sequence([
|
|
87
|
+
return (0, close_1.close)((0, map_1.map)((0, sequence_1.sequence)([
|
|
88
88
|
fenceBlock,
|
|
89
|
-
constrained_1.constrained(name, blockDirectiveName, 'Valid directive name'),
|
|
90
|
-
required_1.required(sep),
|
|
91
|
-
required_1.required(ident),
|
|
89
|
+
(0, constrained_1.constrained)(name, blockDirectiveName, 'Valid directive name'),
|
|
90
|
+
(0, required_1.required)(sep),
|
|
91
|
+
(0, required_1.required)(ident),
|
|
92
92
|
attrs,
|
|
93
|
-
optional_1.optional(body),
|
|
94
|
-
optional_1.optional(lazy_1.lazy(directives)),
|
|
95
|
-
optional_1.optional(body),
|
|
93
|
+
(0, optional_1.optional)(body),
|
|
94
|
+
(0, optional_1.optional)((0, lazy_1.lazy)(directives)),
|
|
95
|
+
(0, optional_1.optional)(body),
|
|
96
96
|
fenceBlock,
|
|
97
97
|
exit,
|
|
98
|
-
required_1.required(sep),
|
|
99
|
-
]), (...args) => flat_1.flat(args)), identIndex);
|
|
98
|
+
(0, required_1.required)(sep),
|
|
99
|
+
]), (...args) => (0, flat_1.flat)(args)), identIndex);
|
|
100
100
|
}
|
|
101
101
|
function directives() {
|
|
102
|
-
return many_1.many(oneOf_1.oneOf([
|
|
103
|
-
sequence_1.sequence([optional_1.optional(body), speaker(), optional_1.optional(body)]),
|
|
104
|
-
sequence_1.sequence([optional_1.optional(body), inline(), optional_1.optional(body)]),
|
|
105
|
-
sequence_1.sequence([optional_1.optional(body), block(), optional_1.optional(body)]),
|
|
102
|
+
return (0, many_1.many)((0, oneOf_1.oneOf)([
|
|
103
|
+
(0, sequence_1.sequence)([(0, optional_1.optional)(body), speaker(), (0, optional_1.optional)(body)]),
|
|
104
|
+
(0, sequence_1.sequence)([(0, optional_1.optional)(body), inline(), (0, optional_1.optional)(body)]),
|
|
105
|
+
(0, sequence_1.sequence)([(0, optional_1.optional)(body), block(), (0, optional_1.optional)(body)]),
|
|
106
106
|
]));
|
|
107
107
|
}
|
|
108
|
-
const parser = sequence_1.sequence([optional_1.optional(body), directives(), optional_1.optional(body), eos_1.eos()]);
|
|
108
|
+
const parser = (0, sequence_1.sequence)([(0, optional_1.optional)(body), directives(), (0, optional_1.optional)(body), (0, eos_1.eos)()]);
|
|
109
109
|
exports.default = parser;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canopycanopycanopy/b-ber-validator",
|
|
3
|
-
"version": "1.2.13-react-reader.
|
|
3
|
+
"version": "1.2.13-react-reader.71+e04d2b4b",
|
|
4
4
|
"description": "A b-ber syntax validator",
|
|
5
5
|
"author": "Triple Canopy <b-ber@canopycanopycanopy.com> (https://triplecanopy.github.io/)",
|
|
6
6
|
"contributors": [
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"url": "https://github.com/triplecanopy/b-ber/issues"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@canopycanopycanopy/b-ber-shapes-directives": "1.
|
|
39
|
+
"@canopycanopycanopy/b-ber-shapes-directives": "1.2.13-react-reader.71+e04d2b4b",
|
|
40
40
|
"@types/node": "^14.14.7",
|
|
41
41
|
"@typescript-eslint/eslint-plugin": "^4.8.1",
|
|
42
42
|
"@typescript-eslint/parser": "^4.8.1",
|
|
43
43
|
"babel-cli": "^6.26.0",
|
|
44
|
-
"eslint": "^7.
|
|
44
|
+
"eslint": "^7.32.0",
|
|
45
45
|
"eslint-config-prettier": "^6.15.0",
|
|
46
46
|
"eslint-plugin-prettier": "^3.1.4",
|
|
47
47
|
"jest": "^26.6.3",
|
|
48
|
-
"rimraf": "^
|
|
48
|
+
"rimraf": "^2.7.1",
|
|
49
49
|
"ts-jest": "^26.4.4",
|
|
50
50
|
"typescript": "^4.0.5"
|
|
51
51
|
},
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"lodash": "^4.17.21",
|
|
54
54
|
"tar": "^6.1.11"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "e04d2b4bfe7d4553e6c2fc90128ae4ae91715d4d"
|
|
57
57
|
}
|