@altopelago/aeon-parser 0.9.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/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @altopelago/aeon-parser
2
+
3
+ AST construction for AEON source text.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @altopelago/aeon-parser
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { tokenize } from '@altopelago/aeon-lexer';
15
+ import { parse } from '@altopelago/aeon-parser';
16
+
17
+ const tokens = tokenize('answer = 42').tokens;
18
+ const result = parse(tokens);
19
+
20
+ if (result.errors.length === 0) {
21
+ console.log(result.root);
22
+ }
23
+ ```
24
+
25
+ Use this package when you need direct parser output for tooling or advanced analysis.
26
+ If you want the stable application-facing entry point, prefer `@altopelago/aeon-core`.
package/dist/ast.d.ts ADDED
@@ -0,0 +1,260 @@
1
+ import type { Span } from '@altopelago/aeon-lexer';
2
+ import type { TrimtickMetadata } from './trimticks.js';
3
+ /**
4
+ * Base node interface
5
+ */
6
+ export interface ASTNode {
7
+ readonly span: Span;
8
+ }
9
+ /**
10
+ * AEON Document
11
+ */
12
+ export interface Document extends ASTNode {
13
+ readonly type: 'Document';
14
+ readonly header: Header | null;
15
+ readonly bindings: readonly Binding[];
16
+ readonly envelope: Envelope | null;
17
+ }
18
+ /**
19
+ * Document header
20
+ */
21
+ export interface Header extends ASTNode {
22
+ readonly type: 'Header';
23
+ readonly form: 'structured' | 'shorthand';
24
+ /** Whether a structured header (aeon:header = {...}) was present */
25
+ readonly hasStructured: boolean;
26
+ /** Whether any shorthand header fields (aeon:mode = ...) were present */
27
+ readonly hasShorthand: boolean;
28
+ /** Full header bindings preserved for canonicalization and structural tooling */
29
+ readonly bindings: readonly Binding[];
30
+ readonly fields: ReadonlyMap<string, Value>;
31
+ }
32
+ /**
33
+ * Binding (key = value)
34
+ */
35
+ export interface Binding extends ASTNode {
36
+ readonly type: 'Binding';
37
+ readonly key: string;
38
+ readonly value: Value;
39
+ readonly datatype: TypeAnnotation | null;
40
+ readonly attributes: readonly Attribute[];
41
+ }
42
+ /**
43
+ * Type annotation
44
+ */
45
+ export interface TypeAnnotation extends ASTNode {
46
+ readonly type: 'TypeAnnotation';
47
+ readonly name: string;
48
+ readonly genericArgs: readonly string[];
49
+ readonly radixBase?: number | null;
50
+ readonly separators: readonly string[];
51
+ }
52
+ /**
53
+ * Attribute (@{...})
54
+ */
55
+ export interface Attribute extends ASTNode {
56
+ readonly type: 'Attribute';
57
+ readonly entries: ReadonlyMap<string, AttributeValue>;
58
+ }
59
+ /**
60
+ * Attribute value (may have its own type annotation)
61
+ */
62
+ export interface AttributeValue {
63
+ readonly value: Value;
64
+ readonly datatype: TypeAnnotation | null;
65
+ readonly attributes: readonly Attribute[];
66
+ }
67
+ /**
68
+ * Envelope binding metadata
69
+ */
70
+ export interface Envelope extends ASTNode {
71
+ readonly type: 'Envelope';
72
+ readonly fields: ReadonlyMap<string, Value>;
73
+ }
74
+ /**
75
+ * Value union type
76
+ */
77
+ export type Value = TypedValue | StringLiteral | NumberLiteral | InfinityLiteral | NaNLiteral | NullLiteral | BooleanLiteral | ToggleLiteral | HexLiteral | RadixLiteral | EncodingLiteral | SeparatorLiteral | DateLiteral | DateTimeLiteral | TimeLiteral | ObjectNode | ListNode | TupleLiteral | NodeLiteral | CloneReference | PointerReference;
78
+ /**
79
+ * Anonymous headed value (:type = value, @{...} = value, or @{...}:type = value),
80
+ * valid only inside value containers.
81
+ */
82
+ export interface TypedValue extends ASTNode {
83
+ readonly type: 'TypedValue';
84
+ readonly datatype: TypeAnnotation | null;
85
+ readonly attributes: readonly Attribute[];
86
+ readonly value: Value;
87
+ }
88
+ /**
89
+ * String literal
90
+ */
91
+ export interface StringLiteral extends ASTNode {
92
+ readonly type: 'StringLiteral';
93
+ readonly value: string;
94
+ readonly raw: string;
95
+ readonly delimiter: '"' | "'" | '`';
96
+ readonly trimticks?: TrimtickMetadata;
97
+ }
98
+ /**
99
+ * Number literal
100
+ */
101
+ export interface NumberLiteral extends ASTNode {
102
+ readonly type: 'NumberLiteral';
103
+ readonly value: string;
104
+ readonly raw: string;
105
+ }
106
+ /**
107
+ * Infinity literal
108
+ */
109
+ export interface InfinityLiteral extends ASTNode {
110
+ readonly type: 'InfinityLiteral';
111
+ readonly value: 'Infinity' | '-Infinity';
112
+ readonly raw: 'Infinity' | '-Infinity';
113
+ }
114
+ /**
115
+ * NaN literal
116
+ */
117
+ export interface NaNLiteral extends ASTNode {
118
+ readonly type: 'NaNLiteral';
119
+ readonly value: 'NaN' | '-NaN';
120
+ readonly raw: 'NaN' | '-NaN';
121
+ }
122
+ /**
123
+ * Null literal
124
+ */
125
+ export interface NullLiteral extends ASTNode {
126
+ readonly type: 'NullLiteral';
127
+ readonly mode: 'reserved' | 'reason';
128
+ readonly value: string;
129
+ readonly raw: string;
130
+ }
131
+ /**
132
+ * Boolean literal
133
+ */
134
+ export interface BooleanLiteral extends ASTNode {
135
+ readonly type: 'BooleanLiteral';
136
+ readonly value: boolean;
137
+ readonly raw: string;
138
+ }
139
+ /**
140
+ * Toggle literal (yes/no/on/off)
141
+ */
142
+ export interface ToggleLiteral extends ASTNode {
143
+ readonly type: 'ToggleLiteral';
144
+ readonly value: 'yes' | 'no' | 'on' | 'off';
145
+ readonly raw: string;
146
+ }
147
+ /**
148
+ * Hex literal (#FF00AA)
149
+ */
150
+ export interface HexLiteral extends ASTNode {
151
+ readonly type: 'HexLiteral';
152
+ readonly value: string;
153
+ readonly raw: string;
154
+ }
155
+ /**
156
+ * Radix literal (%1011)
157
+ */
158
+ export interface RadixLiteral extends ASTNode {
159
+ readonly type: 'RadixLiteral';
160
+ readonly value: string;
161
+ readonly raw: string;
162
+ }
163
+ /**
164
+ * Encoding literal ($Base64...)
165
+ */
166
+ export interface EncodingLiteral extends ASTNode {
167
+ readonly type: 'EncodingLiteral';
168
+ readonly value: string;
169
+ readonly raw: string;
170
+ }
171
+ /**
172
+ * Separator literal (^content)
173
+ */
174
+ export interface SeparatorLiteral extends ASTNode {
175
+ readonly type: 'SeparatorLiteral';
176
+ readonly value: string;
177
+ readonly raw: string;
178
+ }
179
+ /**
180
+ * Date literal
181
+ */
182
+ export interface DateLiteral extends ASTNode {
183
+ readonly type: 'DateLiteral';
184
+ readonly value: string;
185
+ readonly raw: string;
186
+ }
187
+ /**
188
+ * DateTime literal (including ZRUT)
189
+ */
190
+ export interface DateTimeLiteral extends ASTNode {
191
+ readonly type: 'DateTimeLiteral';
192
+ readonly value: string;
193
+ readonly raw: string;
194
+ }
195
+ /**
196
+ * Time literal
197
+ */
198
+ export interface TimeLiteral extends ASTNode {
199
+ readonly type: 'TimeLiteral';
200
+ readonly value: string;
201
+ readonly raw: string;
202
+ }
203
+ /**
204
+ * Object node
205
+ */
206
+ export interface ObjectNode extends ASTNode {
207
+ readonly type: 'ObjectNode';
208
+ readonly bindings: readonly Binding[];
209
+ readonly attributes: readonly Attribute[];
210
+ }
211
+ /**
212
+ * List node
213
+ */
214
+ export interface ListNode extends ASTNode {
215
+ readonly type: 'ListNode';
216
+ readonly elements: readonly Value[];
217
+ readonly attributes: readonly Attribute[];
218
+ }
219
+ /**
220
+ * Tuple node
221
+ */
222
+ export interface TupleLiteral extends ASTNode {
223
+ readonly type: 'TupleLiteral';
224
+ readonly elements: readonly Value[];
225
+ readonly attributes: readonly Attribute[];
226
+ readonly raw: string;
227
+ }
228
+ /**
229
+ * Node literal (<tag(...)>)
230
+ */
231
+ export interface NodeLiteral extends ASTNode {
232
+ readonly type: 'NodeLiteral';
233
+ readonly tag: string;
234
+ readonly attributes: readonly Attribute[];
235
+ readonly datatype: TypeAnnotation | null;
236
+ readonly children: readonly Value[];
237
+ }
238
+ /**
239
+ * Clone reference (~path)
240
+ */
241
+ export interface CloneReference extends ASTNode {
242
+ readonly type: 'CloneReference';
243
+ readonly path: readonly ReferencePathSegment[];
244
+ }
245
+ /**
246
+ * Pointer reference (~>path)
247
+ */
248
+ export interface PointerReference extends ASTNode {
249
+ readonly type: 'PointerReference';
250
+ readonly path: readonly ReferencePathSegment[];
251
+ }
252
+ export interface ReferenceAttrSegment {
253
+ readonly type: 'attr';
254
+ readonly key: string;
255
+ }
256
+ /**
257
+ * Reference path segment (member, index, and attribute segments)
258
+ */
259
+ export type ReferencePathSegment = string | number | ReferenceAttrSegment;
260
+ //# sourceMappingURL=ast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,OAAO;IACpB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,QAAS,SAAQ,OAAO;IACrC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,MAAO,SAAQ,OAAO;IACnC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,WAAW,CAAC;IAC1C,oEAAoE;IACpE,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,yEAAyE;IACzE,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC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.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ import type { Span } from '@altopelago/aeon-lexer';
2
+ /**
3
+ * Base class for parser errors
4
+ */
5
+ export declare class ParserError extends Error {
6
+ readonly span: Span;
7
+ readonly code: string;
8
+ constructor(message: string, span: Span, code?: string);
9
+ }
10
+ /**
11
+ * Syntax error - unexpected token or missing expected token
12
+ */
13
+ export declare class SyntaxError extends ParserError {
14
+ readonly expected: string | null;
15
+ readonly found: string;
16
+ constructor(message: string, span: Span, expected: string | null, found: string);
17
+ }
18
+ export declare class InvalidSeparatorCharError extends ParserError {
19
+ readonly value: string;
20
+ constructor(value: string, span: Span);
21
+ }
22
+ export declare class SeparatorDepthExceededError extends ParserError {
23
+ readonly observedDepth: number;
24
+ readonly limit: number;
25
+ constructor(observedDepth: number, limit: number, span: Span);
26
+ }
27
+ export declare class GenericDepthExceededError extends ParserError {
28
+ readonly observedDepth: number;
29
+ readonly limit: number;
30
+ constructor(observedDepth: number, limit: number, span: Span);
31
+ }
32
+ export declare class AttributeDepthExceededError extends ParserError {
33
+ readonly observedDepth: number;
34
+ readonly limit: number;
35
+ constructor(observedDepth: number, limit: number, span: Span);
36
+ }
37
+ export declare class NestingDepthExceededError extends ParserError {
38
+ readonly observedDepth: number;
39
+ readonly limit: number;
40
+ constructor(observedDepth: number, limit: number, span: Span);
41
+ }
42
+ /**
43
+ * Duplicate key error
44
+ */
45
+ export declare class DuplicateKeyError extends ParserError {
46
+ readonly key: string;
47
+ readonly path?: string;
48
+ constructor(key: string, span: Span, path?: string);
49
+ }
50
+ /**
51
+ * Profile error - feature requires profile that is not enabled
52
+ */
53
+ export declare class ProfileError extends ParserError {
54
+ readonly feature: string;
55
+ constructor(feature: string, span: Span);
56
+ }
57
+ /**
58
+ * Reference error - invalid reference
59
+ */
60
+ export declare class ReferenceError extends ParserError {
61
+ readonly path: string;
62
+ constructor(message: string, path: string, span: Span);
63
+ }
64
+ /**
65
+ * Type error - type mismatch
66
+ */
67
+ export declare class TypeError extends ParserError {
68
+ constructor(message: string, span: Span);
69
+ }
70
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAE,MAAuB;CAMzE;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,WAAW;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM;CAMlF;AAED,qBAAa,yBAA0B,SAAQ,WAAW;IACtD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;CAKxC;AAED,qBAAa,2BAA4B,SAAQ,WAAW;IACxD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;CAU/D;AAED,qBAAa,yBAA0B,SAAQ,WAAW;IACtD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,aAAa,EAAE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PARSER_ERROR') {
8
+ super(message);
9
+ this.name = 'ParserError';
10
+ this.span = span;
11
+ this.code = code;
12
+ }
13
+ }
14
+ /**
15
+ * Syntax error - unexpected token or missing expected token
16
+ */
17
+ export class SyntaxError extends ParserError {
18
+ expected;
19
+ found;
20
+ constructor(message, span, expected, found) {
21
+ super(message, span, 'SYNTAX_ERROR');
22
+ this.name = 'SyntaxError';
23
+ this.expected = expected;
24
+ this.found = found;
25
+ }
26
+ }
27
+ export class InvalidSeparatorCharError extends ParserError {
28
+ value;
29
+ constructor(value, span) {
30
+ super(`Invalid separator character '${value}'`, span, 'INVALID_SEPARATOR_CHAR');
31
+ this.name = 'InvalidSeparatorCharError';
32
+ this.value = value;
33
+ }
34
+ }
35
+ export class SeparatorDepthExceededError extends ParserError {
36
+ observedDepth;
37
+ limit;
38
+ constructor(observedDepth, limit, span) {
39
+ super(`Separator depth ${observedDepth} exceeds max_separator_depth ${limit}`, span, 'SEPARATOR_DEPTH_EXCEEDED');
40
+ this.name = 'SeparatorDepthExceededError';
41
+ this.observedDepth = observedDepth;
42
+ this.limit = limit;
43
+ }
44
+ }
45
+ export class GenericDepthExceededError extends ParserError {
46
+ observedDepth;
47
+ limit;
48
+ constructor(observedDepth, limit, span) {
49
+ super(`Generic depth ${observedDepth} exceeds max_generic_depth ${limit}`, span, 'GENERIC_DEPTH_EXCEEDED');
50
+ this.name = 'GenericDepthExceededError';
51
+ this.observedDepth = observedDepth;
52
+ this.limit = limit;
53
+ }
54
+ }
55
+ export class AttributeDepthExceededError extends ParserError {
56
+ observedDepth;
57
+ limit;
58
+ constructor(observedDepth, limit, span) {
59
+ super(`Attribute depth ${observedDepth} exceeds max_attribute_depth ${limit}`, span, 'ATTRIBUTE_DEPTH_EXCEEDED');
60
+ this.name = 'AttributeDepthExceededError';
61
+ this.observedDepth = observedDepth;
62
+ this.limit = limit;
63
+ }
64
+ }
65
+ export class NestingDepthExceededError extends ParserError {
66
+ observedDepth;
67
+ limit;
68
+ constructor(observedDepth, limit, span) {
69
+ super(`Value nesting depth ${observedDepth} exceeds max_nesting_depth ${limit}`, span, 'NESTING_DEPTH_EXCEEDED');
70
+ this.name = 'NestingDepthExceededError';
71
+ this.observedDepth = observedDepth;
72
+ this.limit = limit;
73
+ }
74
+ }
75
+ /**
76
+ * Duplicate key error
77
+ */
78
+ export class DuplicateKeyError extends ParserError {
79
+ key;
80
+ path;
81
+ constructor(key, span, path) {
82
+ super(`Duplicate key: '${key}'`, span, 'DUPLICATE_KEY');
83
+ this.name = 'DuplicateKeyError';
84
+ this.key = key;
85
+ if (path !== undefined) {
86
+ this.path = path;
87
+ }
88
+ }
89
+ }
90
+ /**
91
+ * Profile error - feature requires profile that is not enabled
92
+ */
93
+ export class ProfileError extends ParserError {
94
+ feature;
95
+ constructor(feature, span) {
96
+ super(`Feature '${feature}' requires a profile that is not enabled`, span, 'PROFILE_ERROR');
97
+ this.name = 'ProfileError';
98
+ this.feature = feature;
99
+ }
100
+ }
101
+ /**
102
+ * Reference error - invalid reference
103
+ */
104
+ export class ReferenceError extends ParserError {
105
+ path;
106
+ constructor(message, path, span) {
107
+ super(message, span, 'REFERENCE_ERROR');
108
+ this.name = 'ReferenceError';
109
+ this.path = path;
110
+ }
111
+ }
112
+ /**
113
+ * Type error - type mismatch
114
+ */
115
+ export class TypeError extends ParserError {
116
+ constructor(message, span) {
117
+ super(message, span, 'TYPE_ERROR');
118
+ this.name = 'TypeError';
119
+ }
120
+ }
121
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACzB,IAAI,CAAO;IACX,IAAI,CAAS;IAEtB,YAAY,OAAe,EAAE,IAAU,EAAE,OAAe,cAAc;QAClE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,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AS,EAAE,CAAC;YACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACrB,CAAC;IACL,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,WAAW;IAChC,OAAO,CAAS;IAEzB,YAAY,OAAe,EAAE,IAAU;QACnC,KAAK,CAAC,YAAY,OAAO,0CAA0C,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;QAC5F,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,WAAW;IAClC,IAAI,CAAS;IAEtB,YAAY,OAAe,EAAE,IAAY,EAAE,IAAU;QACjD,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,WAAW;IACtC,YAAY,OAAe,EAAE,IAAU;QACnC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC5B,CAAC;CACJ"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @altopelago/aeon-parser - AEON Parser Package
3
+ *
4
+ * Parses AEON tokens into an Abstract Syntax Tree.
5
+ */
6
+ export * from './ast.js';
7
+ export * from './parser.js';
8
+ export * from './errors.js';
9
+ export * from './trimticks.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @altopelago/aeon-parser - AEON Parser Package
3
+ *
4
+ * Parses AEON tokens into an Abstract Syntax Tree.
5
+ */
6
+ export * from './ast.js';
7
+ export * from './parser.js';
8
+ export * from './errors.js';
9
+ export * from './trimticks.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { type Token } from '@altopelago/aeon-lexer';
2
+ import type { Document } from './ast.js';
3
+ import { ParserError } from './errors.js';
4
+ /**
5
+ * Parser options
6
+ */
7
+ export interface ParserOptions {
8
+ /** Maximum nesting depth for attribute heads (default: 1) */
9
+ readonly maxAttributeDepth?: number;
10
+ /** Maximum number of separator segments in datatype annotation (default: 1) */
11
+ readonly maxSeparatorDepth?: number;
12
+ /** Maximum nesting depth for nested generic type annotations (default: 1) */
13
+ readonly maxGenericDepth?: number;
14
+ /** Maximum nesting depth for value structures like lists and objects (default: 256) */
15
+ readonly maxNestingDepth?: number;
16
+ }
17
+ /**
18
+ * Parse result
19
+ */
20
+ export interface ParseResult {
21
+ readonly document: Document | null;
22
+ readonly errors: readonly ParserError[];
23
+ }
24
+ /**
25
+ * Parse AEON tokens into an AST
26
+ */
27
+ export declare function parse(tokens: readonly Token[], options?: ParserOptions): ParseResult;
28
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAoC,MAAM,wBAAwB,CAAC;AACtF,OAAO,KAAK,EACR,QAAQ,EA0BX,MAAM,UAAU,CAAC;AAClB,OAAO,EACH,WAAW,EAQd,MAAM,aAAa,CAAC;AAGrB;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,6EAA6E;IAC7E,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,uFAAuF;IACvF,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;CAC3C;AAsqDD;;GAEG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,WAAW,CAGpF"}