@tabnas/parser 0.2.0
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/LICENSE +20 -0
- package/README.md +75 -0
- package/dist/builtins.d.ts +4 -0
- package/dist/builtins.js +202 -0
- package/dist/builtins.js.map +1 -0
- package/dist/context.d.ts +64 -0
- package/dist/context.js +138 -0
- package/dist/context.js.map +1 -0
- package/dist/defaults.d.ts +3 -0
- package/dist/defaults.js +301 -0
- package/dist/defaults.js.map +1 -0
- package/dist/error.d.ts +51 -0
- package/dist/error.js +362 -0
- package/dist/error.js.map +1 -0
- package/dist/lexer.d.ts +85 -0
- package/dist/lexer.js +1202 -0
- package/dist/lexer.js.map +1 -0
- package/dist/parser.d.ts +15 -0
- package/dist/parser.js +141 -0
- package/dist/parser.js.map +1 -0
- package/dist/rules.d.ts +100 -0
- package/dist/rules.js +923 -0
- package/dist/rules.js.map +1 -0
- package/dist/tabnas.d.ts +103 -0
- package/dist/tabnas.js +387 -0
- package/dist/tabnas.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +527 -0
- package/dist/types.js +24 -0
- package/dist/types.js.map +1 -0
- package/dist/utility.d.ts +80 -0
- package/dist/utility.js +868 -0
- package/dist/utility.js.map +1 -0
- package/package.json +59 -0
package/dist/defaults.js
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Copyright (c) 2013-2026 Richard Rodger, MIT License */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.defaults = void 0;
|
|
5
|
+
// Functions that create token matching lexers.
|
|
6
|
+
// The `make*Matcher` functions may optionally initialise
|
|
7
|
+
// and validate Config properties specific to their lexing.
|
|
8
|
+
const lexer_1 = require("./lexer");
|
|
9
|
+
const defaults = {
|
|
10
|
+
// Prevent prototype pollution
|
|
11
|
+
safe: {
|
|
12
|
+
key: true,
|
|
13
|
+
},
|
|
14
|
+
// Default tag - set your own!
|
|
15
|
+
tag: '-',
|
|
16
|
+
// Fixed token lexing.
|
|
17
|
+
fixed: {
|
|
18
|
+
// Recognize fixed tokens in the Lexer.
|
|
19
|
+
lex: true,
|
|
20
|
+
// Token names.
|
|
21
|
+
token: {
|
|
22
|
+
'#OB': '{',
|
|
23
|
+
'#CB': '}',
|
|
24
|
+
'#OS': '[',
|
|
25
|
+
'#CS': ']',
|
|
26
|
+
'#CL': ':',
|
|
27
|
+
'#CA': ',',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
match: {
|
|
31
|
+
lex: true,
|
|
32
|
+
token: {},
|
|
33
|
+
},
|
|
34
|
+
// Token sets.
|
|
35
|
+
tokenSet: {
|
|
36
|
+
IGNORE: ['#SP', '#LN', '#CM'],
|
|
37
|
+
VAL: ['#TX', '#NR', '#ST', '#VL'],
|
|
38
|
+
KEY: ['#TX', '#NR', '#ST', '#VL'],
|
|
39
|
+
},
|
|
40
|
+
// Recognize space characters in the lexer.
|
|
41
|
+
space: {
|
|
42
|
+
// Recognize space in the Lexer.
|
|
43
|
+
lex: true,
|
|
44
|
+
// Space characters are kept to a minimal set.
|
|
45
|
+
// Add more from https://en.wikipedia.org/wiki/Whitespace_character as needed.
|
|
46
|
+
chars: ' \t',
|
|
47
|
+
},
|
|
48
|
+
// Line lexing.
|
|
49
|
+
line: {
|
|
50
|
+
// Recognize lines in the Lexer.
|
|
51
|
+
lex: true,
|
|
52
|
+
// Line characters.
|
|
53
|
+
chars: '\r\n',
|
|
54
|
+
// Increments row (aka line) counter.
|
|
55
|
+
rowChars: '\n',
|
|
56
|
+
// Generate separate lexer tokens for each newline.
|
|
57
|
+
// Note: '\r\n' counts as one newline.
|
|
58
|
+
single: false,
|
|
59
|
+
},
|
|
60
|
+
// Text formats.
|
|
61
|
+
text: {
|
|
62
|
+
// Recognize text (non-quoted strings) in the Lexer.
|
|
63
|
+
lex: true,
|
|
64
|
+
},
|
|
65
|
+
// Control number formats.
|
|
66
|
+
number: {
|
|
67
|
+
// Recognize numbers in the Lexer.
|
|
68
|
+
lex: true,
|
|
69
|
+
// Recognize hex numbers (eg. 10 === 0x0a).
|
|
70
|
+
hex: true,
|
|
71
|
+
// Recognize octal numbers (eg. 10 === 0o12).
|
|
72
|
+
oct: true,
|
|
73
|
+
// Recognize binary numbers (eg. 10 === 0b1010).
|
|
74
|
+
bin: true,
|
|
75
|
+
// All possible number chars. |+-|0|xob|0-9a-fA-F|.e|+-|0-9a-fA-F|
|
|
76
|
+
// digital: '-1023456789._xoeEaAbBcCdDfF+',
|
|
77
|
+
// Allow embedded separator. `null` to disable.
|
|
78
|
+
sep: '_',
|
|
79
|
+
// Exclude number strings matching this RegExp
|
|
80
|
+
exclude: undefined,
|
|
81
|
+
},
|
|
82
|
+
// Comment markers.
|
|
83
|
+
// <mark-char>: true -> single line comments
|
|
84
|
+
// <mark-start>: <mark-end> -> multiline comments
|
|
85
|
+
comment: {
|
|
86
|
+
// Recognize comments in the Lexer.
|
|
87
|
+
lex: true,
|
|
88
|
+
// TODO: plugin
|
|
89
|
+
// Balance multiline comments.
|
|
90
|
+
// balance: true,
|
|
91
|
+
// Comment markers.
|
|
92
|
+
def: {
|
|
93
|
+
hash: { line: true, start: '#', lex: true, eatline: false },
|
|
94
|
+
slash: { line: true, start: '//', lex: true, eatline: false },
|
|
95
|
+
multi: {
|
|
96
|
+
line: false,
|
|
97
|
+
start: '/' + '*',
|
|
98
|
+
end: '*' + '/',
|
|
99
|
+
lex: true,
|
|
100
|
+
eatline: false,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
// String formats.
|
|
105
|
+
string: {
|
|
106
|
+
// Recognize strings in the Lexer.
|
|
107
|
+
lex: true,
|
|
108
|
+
// Quote characters
|
|
109
|
+
chars: '\'"`',
|
|
110
|
+
// Multiline quote chars.
|
|
111
|
+
multiChars: '`',
|
|
112
|
+
// Escape character.
|
|
113
|
+
escapeChar: '\\',
|
|
114
|
+
// String escape chars.
|
|
115
|
+
// Denoting char (follows escape char) => actual char.
|
|
116
|
+
escape: {
|
|
117
|
+
b: '\b',
|
|
118
|
+
f: '\f',
|
|
119
|
+
n: '\n',
|
|
120
|
+
r: '\r',
|
|
121
|
+
t: '\t',
|
|
122
|
+
v: '\v',
|
|
123
|
+
// These preserve standard escapes when allowUnknown=false.
|
|
124
|
+
'"': '"',
|
|
125
|
+
"'": "'",
|
|
126
|
+
'`': '`',
|
|
127
|
+
'\\': '\\',
|
|
128
|
+
'/': '/',
|
|
129
|
+
},
|
|
130
|
+
// Allow unknown escape characters - they are copied to output: '\w' -> 'w'.
|
|
131
|
+
allowUnknown: true,
|
|
132
|
+
// Restrict escapes to the standard set: disable the non-standard
|
|
133
|
+
// structural escapes \xHH and \u{...} (plain \uXXXX stays).
|
|
134
|
+
escapeStrict: false,
|
|
135
|
+
// If string lexing fails, instead of error, allow other matchers to try.
|
|
136
|
+
abandon: false,
|
|
137
|
+
},
|
|
138
|
+
// Object formats.
|
|
139
|
+
map: {
|
|
140
|
+
// TODO: or trigger error?
|
|
141
|
+
// Later duplicates extend earlier ones, rather than replacing them.
|
|
142
|
+
extend: true,
|
|
143
|
+
// Custom merge function for duplicates (optional).
|
|
144
|
+
// TODO: needs function signature
|
|
145
|
+
merge: undefined,
|
|
146
|
+
// Allow bare colon `:value` in maps, stored as `child$` property.
|
|
147
|
+
child: false,
|
|
148
|
+
},
|
|
149
|
+
// Array formats.
|
|
150
|
+
list: {
|
|
151
|
+
// Allow arrays to have properties: `[a:9,0,1]`
|
|
152
|
+
property: true,
|
|
153
|
+
// Parse pairs as object elements: `[a:1]` -> `[{"a":1}]`
|
|
154
|
+
// Takes precedence over list.property when true.
|
|
155
|
+
pair: false,
|
|
156
|
+
// Parse bare colon as child$ property: `[:1]` -> [] with child$=1
|
|
157
|
+
// Multiple child values merge.
|
|
158
|
+
child: false,
|
|
159
|
+
},
|
|
160
|
+
// Metadata info markers. When enabled, a non-enumerable marker property
|
|
161
|
+
// is attached to parsed nodes with metadata (implicit flag, meta bag, etc.).
|
|
162
|
+
info: {
|
|
163
|
+
// Attach marker to map nodes.
|
|
164
|
+
map: false,
|
|
165
|
+
// Attach marker to list nodes.
|
|
166
|
+
list: false,
|
|
167
|
+
// Wrap string values as String objects with marker (quote info).
|
|
168
|
+
text: false,
|
|
169
|
+
// Property name for the marker.
|
|
170
|
+
marker: '__info__',
|
|
171
|
+
},
|
|
172
|
+
// Keyword values.
|
|
173
|
+
value: {
|
|
174
|
+
lex: true,
|
|
175
|
+
def: {
|
|
176
|
+
true: { val: true },
|
|
177
|
+
false: { val: false },
|
|
178
|
+
null: { val: null },
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
// Additional text ending characters
|
|
182
|
+
ender: [],
|
|
183
|
+
// Plugin custom options, (namespace by plugin name).
|
|
184
|
+
plugin: {},
|
|
185
|
+
// Debug settings
|
|
186
|
+
debug: {
|
|
187
|
+
// Default console for logging.
|
|
188
|
+
get_console: () => console,
|
|
189
|
+
// Max length of parse value to print.
|
|
190
|
+
maxlen: 99,
|
|
191
|
+
// Print internal structures
|
|
192
|
+
print: {
|
|
193
|
+
// Print config built from options.
|
|
194
|
+
config: false,
|
|
195
|
+
// Custom string formatter for src and node values.
|
|
196
|
+
src: undefined,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
// Error messages.
|
|
200
|
+
error: {
|
|
201
|
+
unknown: 'unknown error: {code}',
|
|
202
|
+
unexpected: 'unexpected character(s): {src}',
|
|
203
|
+
invalid_unicode: 'invalid unicode escape: {src}',
|
|
204
|
+
invalid_ascii: 'invalid ascii escape: {src}',
|
|
205
|
+
unprintable: 'unprintable character: {src}',
|
|
206
|
+
unterminated_string: 'unterminated string: {src}',
|
|
207
|
+
unterminated_comment: 'unterminated comment: {src}',
|
|
208
|
+
unknown_rule: 'unknown rule: {rulename}',
|
|
209
|
+
end_of_source: 'unexpected end of source',
|
|
210
|
+
},
|
|
211
|
+
errmsg: {
|
|
212
|
+
name: 'tabnas',
|
|
213
|
+
suffix: true
|
|
214
|
+
},
|
|
215
|
+
// Error hints: {error-code: hint-text}.
|
|
216
|
+
hint: {
|
|
217
|
+
unknown: `
|
|
218
|
+
Unknown error code: {code}
|
|
219
|
+
Details:
|
|
220
|
+
{details}`,
|
|
221
|
+
unexpected: `
|
|
222
|
+
The character(s) {src} do not match any rule alternative active at
|
|
223
|
+
this position.`,
|
|
224
|
+
invalid_unicode: `
|
|
225
|
+
The escape sequence {src} does not encode a valid unicode code point.`,
|
|
226
|
+
invalid_ascii: `
|
|
227
|
+
The escape sequence {src} does not encode a valid ASCII character.`,
|
|
228
|
+
unprintable: `
|
|
229
|
+
The character {src} (code point below 32) is not allowed inside a
|
|
230
|
+
string literal.`,
|
|
231
|
+
unterminated_string: `
|
|
232
|
+
This string has no end quote.`,
|
|
233
|
+
unterminated_comment: `
|
|
234
|
+
This comment is never closed.`,
|
|
235
|
+
unknown_rule: `
|
|
236
|
+
No rule named $rulename is defined.`,
|
|
237
|
+
end_of_source: `
|
|
238
|
+
Unexpected end of source.`,
|
|
239
|
+
},
|
|
240
|
+
// Lexer
|
|
241
|
+
lex: {
|
|
242
|
+
match: {
|
|
243
|
+
match: { order: 1e6, make: lexer_1.makeMatchMatcher },
|
|
244
|
+
fixed: { order: 2e6, make: lexer_1.makeFixedMatcher },
|
|
245
|
+
space: { order: 3e6, make: lexer_1.makeSpaceMatcher },
|
|
246
|
+
line: { order: 4e6, make: lexer_1.makeLineMatcher },
|
|
247
|
+
string: { order: 5e6, make: lexer_1.makeStringMatcher },
|
|
248
|
+
comment: { order: 6e6, make: lexer_1.makeCommentMatcher },
|
|
249
|
+
number: { order: 7e6, make: lexer_1.makeNumberMatcher },
|
|
250
|
+
text: { order: 8e6, make: lexer_1.makeTextMatcher },
|
|
251
|
+
},
|
|
252
|
+
// Empty string is allowed and returns undefined
|
|
253
|
+
empty: true,
|
|
254
|
+
emptyResult: undefined,
|
|
255
|
+
},
|
|
256
|
+
// Parser
|
|
257
|
+
parse: {
|
|
258
|
+
// Plugin custom functions to prepare parser context.
|
|
259
|
+
prepare: {},
|
|
260
|
+
},
|
|
261
|
+
// Parser rule options.
|
|
262
|
+
rule: {
|
|
263
|
+
// Name of the starting rule.
|
|
264
|
+
start: 'val',
|
|
265
|
+
// Automatically close remaining structures at EOF.
|
|
266
|
+
finish: true,
|
|
267
|
+
// Multiplier to increase the maximum number of rule occurrences.
|
|
268
|
+
maxmul: 3,
|
|
269
|
+
// Include only those alts with matching group tags (comma sep).
|
|
270
|
+
// NOTE: applies universally, thus also for subsequent rules.
|
|
271
|
+
include: '',
|
|
272
|
+
// Exclude alts with matching group tags (comma sep).
|
|
273
|
+
// NOTE: applies universally, thus also for subsequent rules.
|
|
274
|
+
exclude: '',
|
|
275
|
+
},
|
|
276
|
+
// Result value options.
|
|
277
|
+
result: {
|
|
278
|
+
// Fail if result matches any of these.
|
|
279
|
+
fail: [],
|
|
280
|
+
},
|
|
281
|
+
// Token-rewind options. `history` bounds how many consumed tokens
|
|
282
|
+
// are retained on ctx.v for ctx.rewind(). The default of 64 keeps
|
|
283
|
+
// parse-time memory bounded for large inputs; raise it if a
|
|
284
|
+
// grammar needs to rewind further, or set to Infinity to retain
|
|
285
|
+
// every consumed token. ctx.rewind(mark) throws if `mark` falls
|
|
286
|
+
// outside the retained window.
|
|
287
|
+
rewind: {
|
|
288
|
+
history: 64,
|
|
289
|
+
},
|
|
290
|
+
// Configuration options.
|
|
291
|
+
config: {
|
|
292
|
+
// Configuration modifiers.
|
|
293
|
+
modify: {},
|
|
294
|
+
},
|
|
295
|
+
// Provide a custom parser.
|
|
296
|
+
parser: {
|
|
297
|
+
start: undefined,
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
exports.defaults = defaults;
|
|
301
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"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AkB,EAAE;YACjD,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,yBAAiB,EAAE;YAC/C,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,uBAAe,EAAE;SAC5C;QAED,gDAAgD;QAChD,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,SAAS;KACvB;IAED,SAAS;IACT,KAAK,EAAE;QACL,qDAAqD;QACrD,OAAO,EAAE,EAAE;KACZ;IAED,uBAAuB;IACvB,IAAI,EAAE;QACJ,6BAA6B;QAC7B,KAAK,EAAE,KAAK;QAEZ,mDAAmD;QACnD,MAAM,EAAE,IAAI;QAEZ,iEAAiE;QACjE,MAAM,EAAE,CAAC;QAET,gEAAgE;QAChE,6DAA6D;QAC7D,OAAO,EAAE,EAAE;QAEX,qDAAqD;QACrD,6DAA6D;QAC7D,OAAO,EAAE,EAAE;KACZ;IAED,wBAAwB;IACxB,MAAM,EAAE;QACN,uCAAuC;QACvC,IAAI,EAAE,EAAE;KACT;IAED,kEAAkE;IAClE,kEAAkE;IAClE,4DAA4D;IAC5D,gEAAgE;IAChE,gEAAgE;IAChE,+BAA+B;IAC/B,MAAM,EAAE;QACN,OAAO,EAAE,EAAE;KACZ;IAED,yBAAyB;IACzB,MAAM,EAAE;QACN,2BAA2B;QAC3B,MAAM,EAAE,EAAE;KACX;IAED,2BAA2B;IAC3B,MAAM,EAAE;QACN,KAAK,EAAE,SAAS;KACjB;CACF,CAAA;AAEQ,4BAAQ"}
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Context, Rule, Token } from './types';
|
|
2
|
+
declare class TabnasError extends SyntaxError {
|
|
3
|
+
constructor(code: string, details: Record<string, any>, token: Token, rule: Rule, ctx: Context);
|
|
4
|
+
}
|
|
5
|
+
declare function errinject<T extends string | string[] | {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
}>(s: T, code: string, details: Record<string, any>, token: Token, rule: Rule, ctx: Context): T;
|
|
8
|
+
declare function trimstk(err: Error): void;
|
|
9
|
+
declare function errsite(spec: {
|
|
10
|
+
src: string;
|
|
11
|
+
sub?: string;
|
|
12
|
+
msg?: string;
|
|
13
|
+
row?: number;
|
|
14
|
+
col?: number;
|
|
15
|
+
pos?: number;
|
|
16
|
+
cline?: string;
|
|
17
|
+
}): string;
|
|
18
|
+
declare function errmsg(spec: {
|
|
19
|
+
code?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
txts?: {
|
|
22
|
+
msg?: string;
|
|
23
|
+
hint?: string;
|
|
24
|
+
site?: string;
|
|
25
|
+
};
|
|
26
|
+
smsg?: string;
|
|
27
|
+
src?: string;
|
|
28
|
+
file?: string;
|
|
29
|
+
row?: number;
|
|
30
|
+
col?: number;
|
|
31
|
+
pos?: number;
|
|
32
|
+
site?: string;
|
|
33
|
+
sub?: string;
|
|
34
|
+
prefix?: string | Function;
|
|
35
|
+
suffix?: string | Function;
|
|
36
|
+
color?: {
|
|
37
|
+
active?: boolean;
|
|
38
|
+
reset?: string;
|
|
39
|
+
hi?: string;
|
|
40
|
+
lo?: string;
|
|
41
|
+
line?: string;
|
|
42
|
+
};
|
|
43
|
+
}): string;
|
|
44
|
+
declare function errdesc(code: string, details: Record<string, any>, token: Token, rule: Rule, ctx: Context): Record<string, any>;
|
|
45
|
+
declare function strinject<T extends string | string[] | {
|
|
46
|
+
[key: string]: string;
|
|
47
|
+
}>(s: T, m: Record<string, any>, f?: {
|
|
48
|
+
indent?: string;
|
|
49
|
+
}): T;
|
|
50
|
+
declare function prop(obj: any, path: string, val?: any): any;
|
|
51
|
+
export { TabnasError, errdesc, errinject, errsite, errmsg, trimstk, strinject, prop, };
|