stringent 0.0.2 → 0.0.4
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/README.md +61 -73
- package/dist/context.d.ts +20 -2
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +1 -0
- package/dist/context.js.map +1 -0
- package/dist/createParser.d.ts +109 -26
- package/dist/createParser.d.ts.map +1 -0
- package/dist/createParser.js +80 -19
- package/dist/createParser.js.map +1 -0
- package/dist/errors.d.ts +121 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +186 -0
- package/dist/errors.js.map +1 -0
- package/dist/grammar/index.d.ts +19 -14
- package/dist/grammar/index.d.ts.map +1 -0
- package/dist/grammar/index.js +4 -3
- package/dist/grammar/index.js.map +1 -0
- package/dist/index.d.ts +19 -11
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -0
- package/dist/parse/index.d.ts +101 -27
- package/dist/parse/index.d.ts.map +1 -0
- package/dist/parse/index.js +1 -0
- package/dist/parse/index.js.map +1 -0
- package/dist/performance.bench.d.ts +10 -0
- package/dist/performance.bench.d.ts.map +1 -0
- package/dist/performance.bench.js +379 -0
- package/dist/performance.bench.js.map +1 -0
- package/dist/primitive/index.d.ts +27 -35
- package/dist/primitive/index.d.ts.map +1 -0
- package/dist/primitive/index.js +22 -17
- package/dist/primitive/index.js.map +1 -0
- package/dist/runtime/eval.d.ts +157 -0
- package/dist/runtime/eval.d.ts.map +1 -0
- package/dist/runtime/eval.js +206 -0
- package/dist/runtime/eval.js.map +1 -0
- package/dist/runtime/infer.d.ts +2 -1
- package/dist/runtime/infer.d.ts.map +1 -0
- package/dist/runtime/infer.js +3 -2
- package/dist/runtime/infer.js.map +1 -0
- package/dist/runtime/parser.d.ts +92 -11
- package/dist/runtime/parser.d.ts.map +1 -0
- package/dist/runtime/parser.js +522 -47
- package/dist/runtime/parser.js.map +1 -0
- package/dist/schema/index.d.ts +230 -27
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +54 -28
- package/dist/schema/index.js.map +1 -0
- package/dist/static/infer.d.ts +4 -3
- package/dist/static/infer.d.ts.map +1 -0
- package/dist/static/infer.js +1 -0
- package/dist/static/infer.js.map +1 -0
- package/package.json +35 -4
- package/dist/combinators/index.d.ts +0 -57
- package/dist/combinators/index.js +0 -104
- package/dist/static/parser.d.ts +0 -7
- package/dist/static/parser.js +0 -6
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Types and Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides rich error information for parse failures including:
|
|
5
|
+
* - Position tracking (offset, line, column)
|
|
6
|
+
* - Source snippets showing where errors occurred
|
|
7
|
+
* - Descriptive messages for different error types
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Source position in the input string.
|
|
11
|
+
*/
|
|
12
|
+
export interface SourcePosition {
|
|
13
|
+
/** Zero-based character offset from start of input */
|
|
14
|
+
readonly offset: number;
|
|
15
|
+
/** One-based line number */
|
|
16
|
+
readonly line: number;
|
|
17
|
+
/** One-based column number (characters from start of line) */
|
|
18
|
+
readonly column: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Calculate position information from input and current offset.
|
|
22
|
+
*
|
|
23
|
+
* @param input - The original input string
|
|
24
|
+
* @param offset - Character offset into the input
|
|
25
|
+
* @returns Position with line and column numbers
|
|
26
|
+
*/
|
|
27
|
+
export declare function calculatePosition(input: string, offset: number): SourcePosition;
|
|
28
|
+
/** Error kinds for categorization */
|
|
29
|
+
export type ParseErrorKind = 'no_match' | 'type_mismatch' | 'unterminated_string' | 'unclosed_paren' | 'unexpected_token' | 'empty_input';
|
|
30
|
+
/**
|
|
31
|
+
* Rich parse error with position and context information.
|
|
32
|
+
*/
|
|
33
|
+
export interface RichParseError {
|
|
34
|
+
/** Error marker for type discrimination */
|
|
35
|
+
readonly __error: true;
|
|
36
|
+
/** Error kind for categorization */
|
|
37
|
+
readonly kind: ParseErrorKind;
|
|
38
|
+
/** Human-readable error message */
|
|
39
|
+
readonly message: string;
|
|
40
|
+
/** Position where the error occurred */
|
|
41
|
+
readonly position: SourcePosition;
|
|
42
|
+
/** The problematic input snippet */
|
|
43
|
+
readonly snippet: string;
|
|
44
|
+
/** The full original input */
|
|
45
|
+
readonly input: string;
|
|
46
|
+
/** Additional context (e.g., expected type, actual type) */
|
|
47
|
+
readonly context?: ErrorContext;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Additional error context for specific error types.
|
|
51
|
+
*/
|
|
52
|
+
export interface ErrorContext {
|
|
53
|
+
/** Expected type for type mismatch errors */
|
|
54
|
+
expected?: string;
|
|
55
|
+
/** Actual type for type mismatch errors */
|
|
56
|
+
actual?: string;
|
|
57
|
+
/** What was being parsed when error occurred */
|
|
58
|
+
parsing?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a snippet of the input around the error position.
|
|
62
|
+
*
|
|
63
|
+
* @param input - The full input string
|
|
64
|
+
* @param offset - Character offset where error occurred
|
|
65
|
+
* @param contextChars - Number of characters to show around the error
|
|
66
|
+
* @returns A snippet with error position marker
|
|
67
|
+
*/
|
|
68
|
+
export declare function createSnippet(input: string, offset: number, contextChars?: number): string;
|
|
69
|
+
/**
|
|
70
|
+
* Create a RichParseError.
|
|
71
|
+
*/
|
|
72
|
+
export declare function createParseError(kind: ParseErrorKind, message: string, input: string, offset: number, context?: ErrorContext): RichParseError;
|
|
73
|
+
/**
|
|
74
|
+
* Create a "no match" error.
|
|
75
|
+
*/
|
|
76
|
+
export declare function noMatchError(input: string, offset: number): RichParseError;
|
|
77
|
+
/**
|
|
78
|
+
* Create a "type mismatch" error.
|
|
79
|
+
*/
|
|
80
|
+
export declare function typeMismatchError(input: string, offset: number, expected: string, actual: string, parsing?: string): RichParseError;
|
|
81
|
+
/**
|
|
82
|
+
* Create an "unterminated string" error.
|
|
83
|
+
*/
|
|
84
|
+
export declare function unterminatedStringError(input: string, offset: number, quote: string): RichParseError;
|
|
85
|
+
/**
|
|
86
|
+
* Create an "unclosed parenthesis" error.
|
|
87
|
+
*/
|
|
88
|
+
export declare function unclosedParenError(input: string, offset: number): RichParseError;
|
|
89
|
+
/**
|
|
90
|
+
* Create an "unexpected token" error.
|
|
91
|
+
*/
|
|
92
|
+
export declare function unexpectedTokenError(input: string, offset: number, found: string, expected?: string): RichParseError;
|
|
93
|
+
/**
|
|
94
|
+
* Create an "empty input" error.
|
|
95
|
+
*/
|
|
96
|
+
export declare function emptyInputError(input: string): RichParseError;
|
|
97
|
+
import type { ASTNode } from './primitive/index.js';
|
|
98
|
+
/**
|
|
99
|
+
* Extended parse result that can include error information.
|
|
100
|
+
* - Empty array: no match (backward compatible)
|
|
101
|
+
* - [node, remaining]: successful parse
|
|
102
|
+
* - [node, remaining, errors]: successful parse with collected errors
|
|
103
|
+
*/
|
|
104
|
+
export type ParseResultWithErrors<T extends ASTNode<string, unknown> = ASTNode<string, unknown>> = [] | [T & {}, string] | [T & {}, string, RichParseError[]];
|
|
105
|
+
/**
|
|
106
|
+
* Check if a result includes errors.
|
|
107
|
+
*/
|
|
108
|
+
export declare function hasErrors(result: ParseResultWithErrors): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Get errors from a result, or empty array if none.
|
|
111
|
+
*/
|
|
112
|
+
export declare function getErrors(result: ParseResultWithErrors): RichParseError[];
|
|
113
|
+
/**
|
|
114
|
+
* Format an error for display with source context.
|
|
115
|
+
*/
|
|
116
|
+
export declare function formatError(error: RichParseError): string;
|
|
117
|
+
/**
|
|
118
|
+
* Format multiple errors for display.
|
|
119
|
+
*/
|
|
120
|
+
export declare function formatErrors(errors: RichParseError[]): string;
|
|
121
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"A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c,EAAE,CAAC,CAAC;AAEvC;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAEhE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,qBAAqB,GAAG,cAAc,EAAE,CAKzE;AAMD;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAmBzD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAE7D"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Types and Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides rich error information for parse failures including:
|
|
5
|
+
* - Position tracking (offset, line, column)
|
|
6
|
+
* - Source snippets showing where errors occurred
|
|
7
|
+
* - Descriptive messages for different error types
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Calculate position information from input and current offset.
|
|
11
|
+
*
|
|
12
|
+
* @param input - The original input string
|
|
13
|
+
* @param offset - Character offset into the input
|
|
14
|
+
* @returns Position with line and column numbers
|
|
15
|
+
*/
|
|
16
|
+
export function calculatePosition(input, offset) {
|
|
17
|
+
const textBeforeOffset = input.slice(0, offset);
|
|
18
|
+
const lines = textBeforeOffset.split('\n');
|
|
19
|
+
const line = lines.length;
|
|
20
|
+
const column = lines[lines.length - 1].length + 1;
|
|
21
|
+
return { offset, line, column };
|
|
22
|
+
}
|
|
23
|
+
// =============================================================================
|
|
24
|
+
// Error Creation Utilities
|
|
25
|
+
// =============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Create a snippet of the input around the error position.
|
|
28
|
+
*
|
|
29
|
+
* @param input - The full input string
|
|
30
|
+
* @param offset - Character offset where error occurred
|
|
31
|
+
* @param contextChars - Number of characters to show around the error
|
|
32
|
+
* @returns A snippet with error position marker
|
|
33
|
+
*/
|
|
34
|
+
export function createSnippet(input, offset, contextChars = 20) {
|
|
35
|
+
if (input.length === 0)
|
|
36
|
+
return '(empty input)';
|
|
37
|
+
const start = Math.max(0, offset - contextChars);
|
|
38
|
+
const end = Math.min(input.length, offset + contextChars);
|
|
39
|
+
let snippet = '';
|
|
40
|
+
// Add ellipsis if we're not at the start
|
|
41
|
+
if (start > 0)
|
|
42
|
+
snippet += '...';
|
|
43
|
+
// Add the snippet content
|
|
44
|
+
snippet += input.slice(start, offset);
|
|
45
|
+
snippet += '→'; // Position marker
|
|
46
|
+
snippet += input.slice(offset, end);
|
|
47
|
+
// Add ellipsis if we're not at the end
|
|
48
|
+
if (end < input.length)
|
|
49
|
+
snippet += '...';
|
|
50
|
+
// Escape control characters for display
|
|
51
|
+
snippet = snippet.replace(/\n/g, '\\n').replace(/\t/g, '\\t').replace(/\r/g, '\\r');
|
|
52
|
+
return snippet;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a RichParseError.
|
|
56
|
+
*/
|
|
57
|
+
export function createParseError(kind, message, input, offset, context) {
|
|
58
|
+
return {
|
|
59
|
+
__error: true,
|
|
60
|
+
kind,
|
|
61
|
+
message,
|
|
62
|
+
position: calculatePosition(input, offset),
|
|
63
|
+
snippet: createSnippet(input, offset),
|
|
64
|
+
input,
|
|
65
|
+
context,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a "no match" error.
|
|
70
|
+
*/
|
|
71
|
+
export function noMatchError(input, offset) {
|
|
72
|
+
const position = calculatePosition(input, offset);
|
|
73
|
+
const remaining = input.slice(offset).trim();
|
|
74
|
+
const preview = remaining.slice(0, 20) + (remaining.length > 20 ? '...' : '');
|
|
75
|
+
let message;
|
|
76
|
+
if (input.trim().length === 0) {
|
|
77
|
+
message = 'Empty or whitespace-only input';
|
|
78
|
+
}
|
|
79
|
+
else if (offset >= input.length) {
|
|
80
|
+
message = 'Unexpected end of input';
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
message = `No grammar rule matched at position ${position.line}:${position.column}: "${preview}"`;
|
|
84
|
+
}
|
|
85
|
+
return createParseError('no_match', message, input, offset);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create a "type mismatch" error.
|
|
89
|
+
*/
|
|
90
|
+
export function typeMismatchError(input, offset, expected, actual, parsing) {
|
|
91
|
+
const position = calculatePosition(input, offset);
|
|
92
|
+
let message = `Type mismatch at ${position.line}:${position.column}: expected '${expected}', got '${actual}'`;
|
|
93
|
+
if (parsing) {
|
|
94
|
+
message += ` while parsing ${parsing}`;
|
|
95
|
+
}
|
|
96
|
+
return createParseError('type_mismatch', message, input, offset, {
|
|
97
|
+
expected,
|
|
98
|
+
actual,
|
|
99
|
+
parsing,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create an "unterminated string" error.
|
|
104
|
+
*/
|
|
105
|
+
export function unterminatedStringError(input, offset, quote) {
|
|
106
|
+
const position = calculatePosition(input, offset);
|
|
107
|
+
const message = `Unterminated string literal at ${position.line}:${position.column}: missing closing ${quote}`;
|
|
108
|
+
return createParseError('unterminated_string', message, input, offset, {
|
|
109
|
+
parsing: 'string literal',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create an "unclosed parenthesis" error.
|
|
114
|
+
*/
|
|
115
|
+
export function unclosedParenError(input, offset) {
|
|
116
|
+
const position = calculatePosition(input, offset);
|
|
117
|
+
const message = `Unclosed parenthesis at ${position.line}:${position.column}: missing ')'`;
|
|
118
|
+
return createParseError('unclosed_paren', message, input, offset, {
|
|
119
|
+
parsing: 'parenthesized expression',
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Create an "unexpected token" error.
|
|
124
|
+
*/
|
|
125
|
+
export function unexpectedTokenError(input, offset, found, expected) {
|
|
126
|
+
const position = calculatePosition(input, offset);
|
|
127
|
+
let message = `Unexpected token at ${position.line}:${position.column}: found '${found}'`;
|
|
128
|
+
if (expected) {
|
|
129
|
+
message += `, expected ${expected}`;
|
|
130
|
+
}
|
|
131
|
+
return createParseError('unexpected_token', message, input, offset, {
|
|
132
|
+
expected,
|
|
133
|
+
parsing: 'expression',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create an "empty input" error.
|
|
138
|
+
*/
|
|
139
|
+
export function emptyInputError(input) {
|
|
140
|
+
return createParseError('empty_input', 'Cannot parse empty or whitespace-only input', input, 0);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Check if a result includes errors.
|
|
144
|
+
*/
|
|
145
|
+
export function hasErrors(result) {
|
|
146
|
+
return result.length === 3 && result[2].length > 0;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get errors from a result, or empty array if none.
|
|
150
|
+
*/
|
|
151
|
+
export function getErrors(result) {
|
|
152
|
+
if (result.length === 3) {
|
|
153
|
+
return result[2];
|
|
154
|
+
}
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
// =============================================================================
|
|
158
|
+
// Error Formatting
|
|
159
|
+
// =============================================================================
|
|
160
|
+
/**
|
|
161
|
+
* Format an error for display with source context.
|
|
162
|
+
*/
|
|
163
|
+
export function formatError(error) {
|
|
164
|
+
const { position, message, snippet } = error;
|
|
165
|
+
const lines = [];
|
|
166
|
+
lines.push(`Error at line ${position.line}, column ${position.column}:`);
|
|
167
|
+
lines.push(` ${message}`);
|
|
168
|
+
lines.push('');
|
|
169
|
+
lines.push(` ${snippet}`);
|
|
170
|
+
if (error.context) {
|
|
171
|
+
const ctx = error.context;
|
|
172
|
+
if (ctx.expected && ctx.actual) {
|
|
173
|
+
lines.push('');
|
|
174
|
+
lines.push(` Expected: ${ctx.expected}`);
|
|
175
|
+
lines.push(` Actual: ${ctx.actual}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return lines.join('\n');
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Format multiple errors for display.
|
|
182
|
+
*/
|
|
183
|
+
export function formatErrors(errors) {
|
|
184
|
+
return errors.map(formatError).join('\n\n');
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa,EAAE,MAAc;IAC7D,MAAM,gBAAgB,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC;IAC1B,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAElD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC;AA+CD,gFAAgF;AAChF,2BAA2B;AAC3B,gFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,MAAc,EAAE,eAAuB,EAAE;IACpF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,eAAe,CAAC;IAE/C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC;IACjD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC;IAE1D,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,yCAAyC;IACzC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,IAAI,KAAK,CAAC;IAEhC,0BAA0B;IAC1B,OAAO,I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/grammar/index.d.ts
CHANGED
|
@@ -1,43 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Grammar Type Computation
|
|
3
3
|
*
|
|
4
|
-
* Computes a grammar TYPE from
|
|
4
|
+
* Computes a grammar TYPE from operator schemas. The grammar is a flat tuple
|
|
5
5
|
* of precedence levels, sorted from lowest to highest precedence, with
|
|
6
|
-
* atoms as the final element.
|
|
6
|
+
* built-in atoms as the final element.
|
|
7
7
|
*
|
|
8
8
|
* Example:
|
|
9
|
-
* [[AddOps], [MulOps], [
|
|
9
|
+
* [[AddOps], [MulOps], [BuiltInAtoms]]
|
|
10
10
|
* // level 0 (lowest prec) → level 1 → atoms (last)
|
|
11
11
|
*/
|
|
12
|
-
import type { Pipe, Numbers, Objects, Tuples, Fn, Unions, Call } from
|
|
13
|
-
import type { NodeSchema } from
|
|
12
|
+
import type { Pipe, Numbers, Objects, Tuples, Fn, Unions, Call } from 'hotscript';
|
|
13
|
+
import type { NodeSchema } from '../schema/index.js';
|
|
14
|
+
import type { BUILT_IN_ATOMS } from '../runtime/parser.js';
|
|
14
15
|
/**
|
|
15
16
|
* A grammar is a tuple of levels, where each level is an array of node schemas.
|
|
16
|
-
* Sorted by precedence (lowest first), atoms last.
|
|
17
|
+
* Sorted by precedence (lowest first), built-in atoms last.
|
|
17
18
|
*/
|
|
18
19
|
export type Grammar = readonly (readonly NodeSchema[])[];
|
|
20
|
+
/** Built-in atoms type - derived from the runtime definitions */
|
|
21
|
+
export type BuiltInAtoms = typeof BUILT_IN_ATOMS;
|
|
19
22
|
/**
|
|
20
|
-
* Compare precedence entries: numbers sort ascending
|
|
23
|
+
* Compare precedence entries: numbers sort ascending.
|
|
21
24
|
* Entry format: [precedence, nodes[]]
|
|
22
25
|
*/
|
|
23
26
|
interface SortByPrecedence extends Fn {
|
|
24
|
-
return:
|
|
27
|
+
return: Call<Numbers.LessThanOrEqual, this['arg0'][0], this['arg1'][0]>;
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
|
-
* Compute the grammar tuple from
|
|
30
|
+
* Compute the grammar tuple from operator schemas.
|
|
28
31
|
*
|
|
29
|
-
* 1. Group
|
|
30
|
-
* 2. Convert to entries and sort (numbers ascending
|
|
32
|
+
* 1. Group operators by precedence
|
|
33
|
+
* 2. Convert to entries and sort (numbers ascending)
|
|
31
34
|
* 3. Extract just the node arrays
|
|
35
|
+
* 4. Append built-in atoms as the last level
|
|
32
36
|
*/
|
|
33
|
-
type
|
|
37
|
+
type ComputeOperatorLevels<TNodes extends readonly NodeSchema[]> = Pipe<[
|
|
34
38
|
...TNodes
|
|
35
39
|
], [
|
|
36
|
-
Tuples.GroupBy<Objects.Get<
|
|
40
|
+
Tuples.GroupBy<Objects.Get<'precedence'>>,
|
|
37
41
|
Objects.Entries,
|
|
38
42
|
Unions.ToTuple,
|
|
39
43
|
Tuples.Sort<SortByPrecedence>,
|
|
40
44
|
Tuples.Map<Tuples.At<1>>
|
|
41
45
|
]>;
|
|
42
|
-
export type ComputeGrammar<TNodes extends readonly NodeSchema[]> =
|
|
46
|
+
export type ComputeGrammar<TNodes extends readonly NodeSchema[]> = ComputeOperatorLevels<TNodes> extends infer Levels extends readonly (readonly NodeSchema[])[] ? readonly [...Levels, BuiltInAtoms] : never;
|
|
43
47
|
export {};
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/grammar/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,CAAC,SAAS,UAAU,EAAE,CAAC,EAAE,CAAC;AAMzD,iEAAiE;AACjE,MAAM,MAAM,YAAY,GAAG,OAAO,cAAc,CAAC;AAMjD;;;GAGG;AACH,UAAU,gBAAiB,SAAQ,EAAE;IACnC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACzE;AAMD;;;;;;;GAOG;AACH,KAAK,qBAAqB,CAAC,MAAM,SAAS,SAAS,UAAU,EAAE,IAAI,IAAI,CACrE;IAAC,GAAG,MAAM;CAAC,EACX;IACE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACzC,OAAO,CAAC,OAAO;IACf,MAAM,CAAC,OAAO;IACd,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC;IAC7B,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CACzB,CACF,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,SAAS,UAAU,EAAE,IAC7D,qBAAqB,CAAC,MAAM,CAAC,SAAS,MAAM,MAAM,SAAS,SAAS,CAAC,SAAS,UAAU,EAAE,CAAC,EAAE,GACzF,SAAS,CAAC,GAAG,MAAM,EAAE,YAAY,CAAC,GAClC,KAAK,CAAC"}
|
package/dist/grammar/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Grammar Type Computation
|
|
3
3
|
*
|
|
4
|
-
* Computes a grammar TYPE from
|
|
4
|
+
* Computes a grammar TYPE from operator schemas. The grammar is a flat tuple
|
|
5
5
|
* of precedence levels, sorted from lowest to highest precedence, with
|
|
6
|
-
* atoms as the final element.
|
|
6
|
+
* built-in atoms as the final element.
|
|
7
7
|
*
|
|
8
8
|
* Example:
|
|
9
|
-
* [[AddOps], [MulOps], [
|
|
9
|
+
* [[AddOps], [MulOps], [BuiltInAtoms]]
|
|
10
10
|
* // level 0 (lowest prec) → level 1 → atoms (last)
|
|
11
11
|
*/
|
|
12
12
|
export {};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/grammar/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,14 +6,22 @@
|
|
|
6
6
|
* - createParser: Build a type-safe parser from nodes
|
|
7
7
|
* - Parse<Grammar, Input, Context>: Type-level parsing
|
|
8
8
|
*/
|
|
9
|
-
export { defineNode, number, string, ident, constVal, lhs, rhs, expr } from
|
|
10
|
-
export type { NodeSchema, PatternSchema, NumberSchema, StringSchema, IdentSchema, ConstSchema, ExprSchema, ExprRole, Precedence, ConfigureFn, EvalFn, SchemaToType, InferBindings, InferEvaluatedBindings, } from
|
|
11
|
-
export { createParser } from
|
|
12
|
-
export type { Parser } from
|
|
13
|
-
export type { Parse, BinaryNode, ParseError, TypeMismatchError, NoMatchError } from
|
|
14
|
-
export type { ComputeGrammar, Grammar } from
|
|
15
|
-
export type { Context, EmptyContext } from
|
|
16
|
-
export { emptyContext } from
|
|
17
|
-
export type { ASTNode, LiteralNode, NumberNode, StringNode, IdentNode, ConstNode, } from
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
9
|
+
export { defineNode, number, string, ident, constVal, lhs, rhs, expr, nullLiteral, booleanLiteral, undefinedLiteral, } from './schema/index.js';
|
|
10
|
+
export type { NodeSchema, PatternSchema, NumberSchema, StringSchema, IdentSchema, ConstSchema, NullSchema, BooleanSchema, UndefinedSchema, ExprSchema, ExprRole, Precedence, ConfigureFn, EvalFn, SchemaToType, InferBindings, InferEvaluatedBindings, UnionResultType, ResultTypeSpec, } from './schema/index.js';
|
|
11
|
+
export { createParser } from './createParser.js';
|
|
12
|
+
export type { Parser, Evaluator, ParseResult, SchemaRecordToData } from './createParser.js';
|
|
13
|
+
export type { Parse, BinaryNode, ParseError, TypeMismatchError, NoMatchError, } from './parse/index.js';
|
|
14
|
+
export type { ComputeGrammar, Grammar } from './grammar/index.js';
|
|
15
|
+
export type { Context, EmptyContext } from './context.js';
|
|
16
|
+
export { emptyContext } from './context.js';
|
|
17
|
+
export type { ASTNode, LiteralNode, NumberNode, StringNode, IdentNode, ConstNode, NullNode, BooleanNode, UndefinedNode, } from './primitive/index.js';
|
|
18
|
+
export { processEscapeSequences, parseWithErrors, formatParseError } from './runtime/parser.js';
|
|
19
|
+
export type { RichParseError, ParseResultWithErrors, ParseWithErrorsResult, } from './runtime/parser.js';
|
|
20
|
+
export { calculatePosition, createSnippet, createParseError, noMatchError, typeMismatchError, unterminatedStringError, unclosedParenError, unexpectedTokenError, emptyInputError, hasErrors, getErrors, formatError, formatErrors, } from './errors.js';
|
|
21
|
+
export type { SourcePosition, ParseErrorKind, ErrorContext } from './errors.js';
|
|
22
|
+
export { evaluate, createEvaluator } from './runtime/eval.js';
|
|
23
|
+
export type { EvalContext } from './runtime/eval.js';
|
|
24
|
+
export { infer } from './runtime/infer.js';
|
|
25
|
+
export type { InferredType } from './runtime/infer.js';
|
|
26
|
+
export type { Infer } from './static/infer.js';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,EACL,UAAU,EACV,MAAM,EACN,MAAM,EACN,KAAK,EACL,QAAQ,EACR,GAAG,EACH,GAAG,EACH,IAAI,EACJ,WAAW,EACX,cAAc,EACd,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,U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,EAAE,MAAM,mBAAmB,CAAC;AAMrD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,14 +9,23 @@
|
|
|
9
9
|
// =============================================================================
|
|
10
10
|
// Main API: defineNode & createParser
|
|
11
11
|
// =============================================================================
|
|
12
|
-
export { defineNode, number, string, ident, constVal, lhs, rhs, expr } from
|
|
13
|
-
export { createParser } from
|
|
14
|
-
export { emptyContext } from
|
|
12
|
+
export { defineNode, number, string, ident, constVal, lhs, rhs, expr, nullLiteral, booleanLiteral, undefinedLiteral, } from './schema/index.js';
|
|
13
|
+
export { createParser } from './createParser.js';
|
|
14
|
+
export { emptyContext } from './context.js';
|
|
15
15
|
// =============================================================================
|
|
16
|
-
//
|
|
16
|
+
// Runtime Utilities
|
|
17
17
|
// =============================================================================
|
|
18
|
-
export {
|
|
18
|
+
export { processEscapeSequences, parseWithErrors, formatParseError } from './runtime/parser.js';
|
|
19
19
|
// =============================================================================
|
|
20
|
-
//
|
|
20
|
+
// Error Types and Utilities
|
|
21
21
|
// =============================================================================
|
|
22
|
-
export {
|
|
22
|
+
export { calculatePosition, createSnippet, createParseError, noMatchError, typeMismatchError, unterminatedStringError, unclosedParenError, unexpectedTokenError, emptyInputError, hasErrors, getErrors, formatError, formatErrors, } from './errors.js';
|
|
23
|
+
// =============================================================================
|
|
24
|
+
// Runtime Evaluation
|
|
25
|
+
// =============================================================================
|
|
26
|
+
export { evaluate, createEvaluator } from './runtime/eval.js';
|
|
27
|
+
// =============================================================================
|
|
28
|
+
// Inference
|
|
29
|
+
// =============================================================================
|
|
30
|
+
export { infer } from './runtime/infer.js';
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,gFAAgF;AAChF,sCAAsC;AACtC,gFAAgF;AAEhF,OAAO,EACL,UAAU,EACV,MAAM,EACN,MAAM,EACN,KAAK,EACL,QAAQ,EACR,GAAG,EACH,GAAG,EACH,IAAI,EACJ,WAAW,EACX,cAAc,EACd,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAuB3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAgBjD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAkB5C,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAOhG,gFAAgF;AAChF,4BAA4B;AAC5B,gFAAgF;AAEhF,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,GACb,MAAM,aAAa,CAAC;AAGrB,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAG9D,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC"}
|