@prisma-next/psl-parser 0.14.0-dev.2 → 0.14.0-dev.20
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 +28 -10
- package/dist/declarations-D9h_ihD3.mjs +820 -0
- package/dist/declarations-D9h_ihD3.mjs.map +1 -0
- package/dist/format.d.mts +19 -0
- package/dist/format.d.mts.map +1 -0
- package/dist/format.mjs +470 -0
- package/dist/format.mjs.map +1 -0
- package/dist/index.d.mts +136 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +472 -3
- package/dist/index.mjs.map +1 -1
- package/dist/parse-DX12Jvsh.d.mts +349 -0
- package/dist/parse-DX12Jvsh.d.mts.map +1 -0
- package/dist/parse-DhEV6av6.mjs +605 -0
- package/dist/parse-DhEV6av6.mjs.map +1 -0
- package/dist/syntax.d.mts +2 -346
- package/dist/syntax.d.mts.map +1 -1
- package/dist/syntax.mjs +2 -1417
- package/package.json +6 -6
- package/src/block-reconstruction.ts +139 -0
- package/src/exports/format.ts +3 -0
- package/src/exports/index.ts +27 -3
- package/src/extension-block.ts +107 -0
- package/src/format/emit.ts +603 -0
- package/src/format/error.ts +13 -0
- package/src/format/format.ts +13 -0
- package/src/format/options.ts +28 -0
- package/src/parse.ts +9 -0
- package/src/resolve.ts +120 -0
- package/src/symbol-table.ts +446 -0
- package/src/syntax/ast/attributes.ts +5 -6
- package/src/syntax/ast/declarations.ts +18 -19
- package/src/syntax/ast/expressions.ts +12 -13
- package/src/syntax/ast/identifier.ts +2 -3
- package/src/syntax/ast/qualified-name.ts +3 -4
- package/src/syntax/ast/type-annotation.ts +4 -5
- package/src/syntax/ast-helpers.ts +3 -3
- package/dist/parser-CaplKvRs.mjs +0 -1145
- package/dist/parser-CaplKvRs.mjs.map +0 -1
- package/dist/parser-Dfi3Wfdq.d.mts +0 -7
- package/dist/parser-Dfi3Wfdq.d.mts.map +0 -1
- package/dist/parser.d.mts +0 -2
- package/dist/parser.mjs +0 -2
- package/dist/syntax.mjs.map +0 -1
- package/src/exports/parser.ts +0 -1
- package/src/parser.ts +0 -1642
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { Token } from '../../tokenizer';
|
|
2
1
|
import type { AstNode } from '../ast-helpers';
|
|
3
2
|
import { filterChildren, findChildToken, findFirstChild } from '../ast-helpers';
|
|
4
|
-
import { SyntaxNode } from '../red';
|
|
3
|
+
import { SyntaxNode, type SyntaxToken } from '../red';
|
|
5
4
|
import { FieldAttributeAst, ModelAttributeAst } from './attributes';
|
|
6
5
|
import type { ExpressionAst } from './expressions';
|
|
7
6
|
import { castExpression } from './expressions';
|
|
@@ -53,7 +52,7 @@ export class ModelDeclarationAst implements AstNode {
|
|
|
53
52
|
this.syntax = syntax;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
keyword():
|
|
55
|
+
keyword(): SyntaxToken | undefined {
|
|
57
56
|
return findChildToken(this.syntax, 'Ident');
|
|
58
57
|
}
|
|
59
58
|
|
|
@@ -61,11 +60,11 @@ export class ModelDeclarationAst implements AstNode {
|
|
|
61
60
|
return findFirstChild(this.syntax, IdentifierAst.cast);
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
lbrace():
|
|
63
|
+
lbrace(): SyntaxToken | undefined {
|
|
65
64
|
return findChildToken(this.syntax, 'LBrace');
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
rbrace():
|
|
67
|
+
rbrace(): SyntaxToken | undefined {
|
|
69
68
|
return findChildToken(this.syntax, 'RBrace');
|
|
70
69
|
}
|
|
71
70
|
|
|
@@ -89,7 +88,7 @@ export class CompositeTypeDeclarationAst implements AstNode {
|
|
|
89
88
|
this.syntax = syntax;
|
|
90
89
|
}
|
|
91
90
|
|
|
92
|
-
keyword():
|
|
91
|
+
keyword(): SyntaxToken | undefined {
|
|
93
92
|
return findChildToken(this.syntax, 'Ident');
|
|
94
93
|
}
|
|
95
94
|
|
|
@@ -97,11 +96,11 @@ export class CompositeTypeDeclarationAst implements AstNode {
|
|
|
97
96
|
return findFirstChild(this.syntax, IdentifierAst.cast);
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
lbrace():
|
|
99
|
+
lbrace(): SyntaxToken | undefined {
|
|
101
100
|
return findChildToken(this.syntax, 'LBrace');
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
rbrace():
|
|
103
|
+
rbrace(): SyntaxToken | undefined {
|
|
105
104
|
return findChildToken(this.syntax, 'RBrace');
|
|
106
105
|
}
|
|
107
106
|
|
|
@@ -127,7 +126,7 @@ export class NamespaceDeclarationAst implements AstNode {
|
|
|
127
126
|
this.syntax = syntax;
|
|
128
127
|
}
|
|
129
128
|
|
|
130
|
-
keyword():
|
|
129
|
+
keyword(): SyntaxToken | undefined {
|
|
131
130
|
return findChildToken(this.syntax, 'Ident');
|
|
132
131
|
}
|
|
133
132
|
|
|
@@ -135,11 +134,11 @@ export class NamespaceDeclarationAst implements AstNode {
|
|
|
135
134
|
return findFirstChild(this.syntax, IdentifierAst.cast);
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
lbrace():
|
|
137
|
+
lbrace(): SyntaxToken | undefined {
|
|
139
138
|
return findChildToken(this.syntax, 'LBrace');
|
|
140
139
|
}
|
|
141
140
|
|
|
142
|
-
rbrace():
|
|
141
|
+
rbrace(): SyntaxToken | undefined {
|
|
143
142
|
return findChildToken(this.syntax, 'RBrace');
|
|
144
143
|
}
|
|
145
144
|
|
|
@@ -159,15 +158,15 @@ export class TypesBlockAst implements AstNode {
|
|
|
159
158
|
this.syntax = syntax;
|
|
160
159
|
}
|
|
161
160
|
|
|
162
|
-
keyword():
|
|
161
|
+
keyword(): SyntaxToken | undefined {
|
|
163
162
|
return findChildToken(this.syntax, 'Ident');
|
|
164
163
|
}
|
|
165
164
|
|
|
166
|
-
lbrace():
|
|
165
|
+
lbrace(): SyntaxToken | undefined {
|
|
167
166
|
return findChildToken(this.syntax, 'LBrace');
|
|
168
167
|
}
|
|
169
168
|
|
|
170
|
-
rbrace():
|
|
169
|
+
rbrace(): SyntaxToken | undefined {
|
|
171
170
|
return findChildToken(this.syntax, 'RBrace');
|
|
172
171
|
}
|
|
173
172
|
|
|
@@ -187,7 +186,7 @@ export class GenericBlockDeclarationAst implements AstNode {
|
|
|
187
186
|
this.syntax = syntax;
|
|
188
187
|
}
|
|
189
188
|
|
|
190
|
-
keyword():
|
|
189
|
+
keyword(): SyntaxToken | undefined {
|
|
191
190
|
return findChildToken(this.syntax, 'Ident');
|
|
192
191
|
}
|
|
193
192
|
|
|
@@ -195,11 +194,11 @@ export class GenericBlockDeclarationAst implements AstNode {
|
|
|
195
194
|
return findFirstChild(this.syntax, IdentifierAst.cast);
|
|
196
195
|
}
|
|
197
196
|
|
|
198
|
-
lbrace():
|
|
197
|
+
lbrace(): SyntaxToken | undefined {
|
|
199
198
|
return findChildToken(this.syntax, 'LBrace');
|
|
200
199
|
}
|
|
201
200
|
|
|
202
|
-
rbrace():
|
|
201
|
+
rbrace(): SyntaxToken | undefined {
|
|
203
202
|
return findChildToken(this.syntax, 'RBrace');
|
|
204
203
|
}
|
|
205
204
|
|
|
@@ -229,7 +228,7 @@ export class KeyValuePairAst implements AstNode {
|
|
|
229
228
|
return findFirstChild(this.syntax, IdentifierAst.cast);
|
|
230
229
|
}
|
|
231
230
|
|
|
232
|
-
equals():
|
|
231
|
+
equals(): SyntaxToken | undefined {
|
|
233
232
|
return findChildToken(this.syntax, 'Equals');
|
|
234
233
|
}
|
|
235
234
|
|
|
@@ -288,7 +287,7 @@ export class NamedTypeDeclarationAst implements AstNode {
|
|
|
288
287
|
return findFirstChild(this.syntax, IdentifierAst.cast);
|
|
289
288
|
}
|
|
290
289
|
|
|
291
|
-
equals():
|
|
290
|
+
equals(): SyntaxToken | undefined {
|
|
292
291
|
return findChildToken(this.syntax, 'Equals');
|
|
293
292
|
}
|
|
294
293
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { Token } from '../../tokenizer';
|
|
2
1
|
import type { AstNode } from '../ast-helpers';
|
|
3
2
|
import { filterChildren, findChildToken, findFirstChild } from '../ast-helpers';
|
|
4
|
-
import { SyntaxNode } from '../red';
|
|
3
|
+
import { SyntaxNode, type SyntaxToken } from '../red';
|
|
5
4
|
import { IdentifierAst } from './identifier';
|
|
6
5
|
import { QualifiedNameAst } from './qualified-name';
|
|
7
6
|
|
|
@@ -32,11 +31,11 @@ export class FunctionCallAst implements AstNode {
|
|
|
32
31
|
return segments;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
lparen():
|
|
34
|
+
lparen(): SyntaxToken | undefined {
|
|
36
35
|
return findChildToken(this.syntax, 'LParen');
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
rparen():
|
|
38
|
+
rparen(): SyntaxToken | undefined {
|
|
40
39
|
return findChildToken(this.syntax, 'RParen');
|
|
41
40
|
}
|
|
42
41
|
|
|
@@ -56,11 +55,11 @@ export class ArrayLiteralAst implements AstNode {
|
|
|
56
55
|
this.syntax = syntax;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
lbracket():
|
|
58
|
+
lbracket(): SyntaxToken | undefined {
|
|
60
59
|
return findChildToken(this.syntax, 'LBracket');
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
rbracket():
|
|
62
|
+
rbracket(): SyntaxToken | undefined {
|
|
64
63
|
return findChildToken(this.syntax, 'RBracket');
|
|
65
64
|
}
|
|
66
65
|
|
|
@@ -156,7 +155,7 @@ export class StringLiteralExprAst implements AstNode {
|
|
|
156
155
|
this.syntax = syntax;
|
|
157
156
|
}
|
|
158
157
|
|
|
159
|
-
token():
|
|
158
|
+
token(): SyntaxToken | undefined {
|
|
160
159
|
return findChildToken(this.syntax, 'StringLiteral');
|
|
161
160
|
}
|
|
162
161
|
|
|
@@ -178,7 +177,7 @@ export class NumberLiteralExprAst implements AstNode {
|
|
|
178
177
|
this.syntax = syntax;
|
|
179
178
|
}
|
|
180
179
|
|
|
181
|
-
token():
|
|
180
|
+
token(): SyntaxToken | undefined {
|
|
182
181
|
return findChildToken(this.syntax, 'NumberLiteral');
|
|
183
182
|
}
|
|
184
183
|
|
|
@@ -200,7 +199,7 @@ export class BooleanLiteralExprAst implements AstNode {
|
|
|
200
199
|
this.syntax = syntax;
|
|
201
200
|
}
|
|
202
201
|
|
|
203
|
-
token():
|
|
202
|
+
token(): SyntaxToken | undefined {
|
|
204
203
|
return findChildToken(this.syntax, 'Ident');
|
|
205
204
|
}
|
|
206
205
|
|
|
@@ -224,11 +223,11 @@ export class ObjectLiteralExprAst implements AstNode {
|
|
|
224
223
|
this.syntax = syntax;
|
|
225
224
|
}
|
|
226
225
|
|
|
227
|
-
lbrace():
|
|
226
|
+
lbrace(): SyntaxToken | undefined {
|
|
228
227
|
return findChildToken(this.syntax, 'LBrace');
|
|
229
228
|
}
|
|
230
229
|
|
|
231
|
-
rbrace():
|
|
230
|
+
rbrace(): SyntaxToken | undefined {
|
|
232
231
|
return findChildToken(this.syntax, 'RBrace');
|
|
233
232
|
}
|
|
234
233
|
|
|
@@ -279,7 +278,7 @@ export class ObjectFieldAst implements AstNode {
|
|
|
279
278
|
return undefined;
|
|
280
279
|
}
|
|
281
280
|
|
|
282
|
-
colon():
|
|
281
|
+
colon(): SyntaxToken | undefined {
|
|
283
282
|
return findChildToken(this.syntax, 'Colon');
|
|
284
283
|
}
|
|
285
284
|
|
|
@@ -339,7 +338,7 @@ export class AttributeArgAst implements AstNode {
|
|
|
339
338
|
return findFirstChild(this.syntax, IdentifierAst.cast);
|
|
340
339
|
}
|
|
341
340
|
|
|
342
|
-
colon():
|
|
341
|
+
colon(): SyntaxToken | undefined {
|
|
343
342
|
return findChildToken(this.syntax, 'Colon');
|
|
344
343
|
}
|
|
345
344
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { Token } from '../../tokenizer';
|
|
2
1
|
import type { AstNode } from '../ast-helpers';
|
|
3
2
|
import { findChildToken } from '../ast-helpers';
|
|
4
|
-
import type { SyntaxNode } from '../red';
|
|
3
|
+
import type { SyntaxNode, SyntaxToken } from '../red';
|
|
5
4
|
|
|
6
5
|
export class IdentifierAst implements AstNode {
|
|
7
6
|
readonly syntax: SyntaxNode;
|
|
@@ -10,7 +9,7 @@ export class IdentifierAst implements AstNode {
|
|
|
10
9
|
this.syntax = syntax;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
token():
|
|
12
|
+
token(): SyntaxToken | undefined {
|
|
14
13
|
return findChildToken(this.syntax, 'Ident');
|
|
15
14
|
}
|
|
16
15
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { Token } from '../../tokenizer';
|
|
2
1
|
import type { AstNode } from '../ast-helpers';
|
|
3
2
|
import { filterChildren, findChildToken, findFirstChild } from '../ast-helpers';
|
|
4
|
-
import { SyntaxNode } from '../red';
|
|
3
|
+
import { SyntaxNode, type SyntaxToken } from '../red';
|
|
5
4
|
import { IdentifierAst } from './identifier';
|
|
6
5
|
|
|
7
6
|
/** A namespace-qualified name, e.g. `pgvector.Vector` or `supabase:auth.User`. */
|
|
@@ -38,11 +37,11 @@ export class QualifiedNameAst implements AstNode {
|
|
|
38
37
|
return count;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
colon():
|
|
40
|
+
colon(): SyntaxToken | undefined {
|
|
42
41
|
return findChildToken(this.syntax, 'Colon');
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
dot():
|
|
44
|
+
dot(): SyntaxToken | undefined {
|
|
46
45
|
return findChildToken(this.syntax, 'Dot');
|
|
47
46
|
}
|
|
48
47
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { Token } from '../../tokenizer';
|
|
2
1
|
import type { AstNode } from '../ast-helpers';
|
|
3
2
|
import { findChildToken, findFirstChild } from '../ast-helpers';
|
|
4
|
-
import type { SyntaxNode } from '../red';
|
|
3
|
+
import type { SyntaxNode, SyntaxToken } from '../red';
|
|
5
4
|
import { AttributeArgListAst } from './attributes';
|
|
6
5
|
import { QualifiedNameAst } from './qualified-name';
|
|
7
6
|
|
|
@@ -26,15 +25,15 @@ export class TypeAnnotationAst implements AstNode {
|
|
|
26
25
|
return this.argList() !== undefined;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
lbracket():
|
|
28
|
+
lbracket(): SyntaxToken | undefined {
|
|
30
29
|
return findChildToken(this.syntax, 'LBracket');
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
rbracket():
|
|
32
|
+
rbracket(): SyntaxToken | undefined {
|
|
34
33
|
return findChildToken(this.syntax, 'RBracket');
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
questionMark():
|
|
36
|
+
questionMark(): SyntaxToken | undefined {
|
|
38
37
|
return findChildToken(this.syntax, 'Question');
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { SyntaxNode } from './red';
|
|
1
|
+
import type { TokenKind } from '../tokenizer';
|
|
2
|
+
import { SyntaxNode, type SyntaxToken } from './red';
|
|
3
3
|
|
|
4
4
|
export interface AstNode {
|
|
5
5
|
readonly syntax: SyntaxNode;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export function findChildToken(node: SyntaxNode, kind: TokenKind):
|
|
8
|
+
export function findChildToken(node: SyntaxNode, kind: TokenKind): SyntaxToken | undefined {
|
|
9
9
|
for (const child of node.children()) {
|
|
10
10
|
if (!(child instanceof SyntaxNode) && child.kind === kind) {
|
|
11
11
|
return child;
|