@prisma-next/psl-parser 0.0.1 → 0.3.0-dev.101

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 ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2026] [Prisma Data, Inc]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -26,6 +26,7 @@ In the provider-based authoring model, PSL providers call this parser and then r
26
26
  - Attributes may include an **optional argument list**.
27
27
  - Arguments are parsed into positional/named entries with preserved raw values and source spans.
28
28
  - The parser owns **syntax + structure + spans**, not semantics.
29
+ - Example: `@default(uuid(7))` is preserved as a positional argument value `uuid(7)`; semantic lowering is handled downstream.
29
30
 
30
31
  Interpretation/validation (for example `@prisma-next/sql-contract-psl`) is responsible for:
31
32
 
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { S as PslPosition, T as PslTypesBlock, _ as PslFieldAttribute, a as PslAttributeNamedArgument, b as PslModelAttribute, c as PslDefaultFunctionValue, d as PslDiagnostic, f as PslDiagnosticCode, g as PslField, h as PslEnumValue, i as PslAttributeArgument, l as PslDefaultLiteralValue, m as PslEnum, n as ParsePslDocumentResult, o as PslAttributePositionalArgument, p as PslDocumentAst, r as PslAttribute, s as PslAttributeTarget, t as ParsePslDocumentInput, u as PslDefaultValue, w as PslSpan, x as PslNamedTypeDeclaration, y as PslModel } from "./types-QqDFOzNR.mjs";
2
- import { t as parsePslDocument } from "./parser-CUqO9VeG.mjs";
1
+ import { S as PslPosition, T as PslTypesBlock, _ as PslFieldAttribute, a as PslAttributeNamedArgument, b as PslModelAttribute, c as PslDefaultFunctionValue, d as PslDiagnostic, f as PslDiagnosticCode, g as PslField, h as PslEnumValue, i as PslAttributeArgument, l as PslDefaultLiteralValue, m as PslEnum, n as ParsePslDocumentResult, o as PslAttributePositionalArgument, p as PslDocumentAst, r as PslAttribute, s as PslAttributeTarget, t as ParsePslDocumentInput, u as PslDefaultValue, w as PslSpan, x as PslNamedTypeDeclaration, y as PslModel } from "./types-CyfspkvF.mjs";
2
+ import { t as parsePslDocument } from "./parser-BgdIJNqs.mjs";
3
3
  export { type ParsePslDocumentInput, type ParsePslDocumentResult, type PslAttribute, type PslAttributeArgument, type PslAttributeNamedArgument, type PslAttributePositionalArgument, type PslAttributeTarget, type PslDefaultFunctionValue, type PslDefaultLiteralValue, type PslDefaultValue, type PslDiagnostic, type PslDiagnosticCode, type PslDocumentAst, type PslEnum, type PslEnumValue, type PslField, type PslFieldAttribute, type PslModel, type PslModelAttribute, type PslNamedTypeDeclaration, type PslPosition, type PslSpan, type PslTypesBlock, parsePslDocument };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as parsePslDocument } from "./parser-BP2RP4rk.mjs";
1
+ import { t as parsePslDocument } from "./parser-Br4vqzd-.mjs";
2
2
 
3
3
  export { parsePslDocument };
@@ -1,7 +1,7 @@
1
- import { n as ParsePslDocumentResult, t as ParsePslDocumentInput } from "./types-QqDFOzNR.mjs";
1
+ import { n as ParsePslDocumentResult, t as ParsePslDocumentInput } from "./types-CyfspkvF.mjs";
2
2
 
3
3
  //#region src/parser.d.ts
4
4
  declare function parsePslDocument(input: ParsePslDocumentInput): ParsePslDocumentResult;
5
5
  //#endregion
6
6
  export { parsePslDocument as t };
7
- //# sourceMappingURL=parser-CUqO9VeG.d.mts.map
7
+ //# sourceMappingURL=parser-BgdIJNqs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser-BgdIJNqs.d.mts","names":[],"sources":["../src/parser.ts"],"sourcesContent":[],"mappings":";;;iBAgDgB,gBAAA,QAAwB,wBAAwB"}
@@ -678,4 +678,4 @@ function pushDiagnostic(context, diagnostic) {
678
678
 
679
679
  //#endregion
680
680
  export { parsePslDocument as t };
681
- //# sourceMappingURL=parser-BP2RP4rk.mjs.map
681
+ //# sourceMappingURL=parser-Br4vqzd-.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"parser-BP2RP4rk.mjs","names":["diagnostics: PslDiagnostic[]","context: ParserContext","models: PslModel[]","enums: PslEnum[]","typesBlock: PslTypesBlock | undefined","fields: PslField[]","attributes: PslModelAttribute[]","values: PslEnumValue[]","declarations: PslNamedTypeDeclaration[]","attributes: PslFieldAttribute[]","args: readonly PslAttributeArgument[]","args: PslAttributeArgument[]","quote: '\"' | \"'\" | null","parts: TopLevelSegment[]","tokens: { text: string; span: PslSpan }[]"],"sources":["../src/parser.ts"],"sourcesContent":["import { ifDefined } from '@prisma-next/utils/defined';\nimport type {\n ParsePslDocumentInput,\n ParsePslDocumentResult,\n PslAttribute,\n PslAttributeArgument,\n PslAttributeTarget,\n PslDiagnostic,\n PslDiagnosticCode,\n PslDocumentAst,\n PslEnum,\n PslEnumValue,\n PslField,\n PslFieldAttribute,\n PslModel,\n PslModelAttribute,\n PslNamedTypeDeclaration,\n PslPosition,\n PslSpan,\n PslTypesBlock,\n} from './types';\n\nconst SCALAR_TYPES = new Set([\n 'String',\n 'Boolean',\n 'Int',\n 'BigInt',\n 'Float',\n 'Decimal',\n 'DateTime',\n 'Json',\n 'Bytes',\n]);\n\ninterface BlockBounds {\n readonly startLine: number;\n readonly endLine: number;\n readonly closed: boolean;\n}\n\ninterface ParserContext {\n readonly schema: string;\n readonly sourceId: string;\n readonly lines: readonly string[];\n readonly lineOffsets: readonly number[];\n readonly diagnostics: PslDiagnostic[];\n}\n\nexport function parsePslDocument(input: ParsePslDocumentInput): ParsePslDocumentResult {\n const normalizedSchema = input.schema.replaceAll('\\r\\n', '\\n');\n const lines = normalizedSchema.split('\\n');\n const lineOffsets = computeLineOffsets(normalizedSchema);\n const diagnostics: PslDiagnostic[] = [];\n const context: ParserContext = {\n schema: normalizedSchema,\n sourceId: input.sourceId,\n lines,\n lineOffsets,\n diagnostics,\n };\n\n const models: PslModel[] = [];\n const enums: PslEnum[] = [];\n let typesBlock: PslTypesBlock | undefined;\n\n let lineIndex = 0;\n while (lineIndex < lines.length) {\n const rawLine = lines[lineIndex] ?? '';\n const line = stripInlineComment(rawLine).trim();\n if (line.length === 0) {\n lineIndex += 1;\n continue;\n }\n\n const modelMatch = line.match(/^model\\s+([A-Za-z_]\\w*)\\s*\\{$/);\n if (modelMatch) {\n const bounds = findBlockBounds(context, lineIndex);\n const name = modelMatch[1] ?? '';\n if (name.length === 0) {\n lineIndex = bounds.endLine + 1;\n continue;\n }\n models.push(parseModelBlock(context, name, bounds));\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n const enumMatch = line.match(/^enum\\s+([A-Za-z_]\\w*)\\s*\\{$/);\n if (enumMatch) {\n const bounds = findBlockBounds(context, lineIndex);\n const name = enumMatch[1] ?? '';\n if (name.length === 0) {\n lineIndex = bounds.endLine + 1;\n continue;\n }\n enums.push(parseEnumBlock(context, name, bounds));\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n if (/^types\\s*\\{$/.test(line)) {\n const bounds = findBlockBounds(context, lineIndex);\n typesBlock = parseTypesBlock(context, bounds);\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n if (line.includes('{')) {\n const blockName = line.split(/\\s+/)[0] ?? 'block';\n pushDiagnostic(context, {\n code: 'PSL_UNSUPPORTED_TOP_LEVEL_BLOCK',\n message: `Unsupported top-level block \"${blockName}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n const bounds = findBlockBounds(context, lineIndex);\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n pushDiagnostic(context, {\n code: 'PSL_UNSUPPORTED_TOP_LEVEL_BLOCK',\n message: `Unsupported top-level declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n lineIndex += 1;\n }\n\n const namedTypeNames = new Set(\n (typesBlock?.declarations ?? []).map((declaration) => declaration.name),\n );\n const modelNames = new Set(models.map((model) => model.name));\n const enumNames = new Set(enums.map((enumBlock) => enumBlock.name));\n for (const declaration of typesBlock?.declarations ?? []) {\n if (SCALAR_TYPES.has(declaration.name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Named type \"${declaration.name}\" conflicts with scalar type \"${declaration.name}\"`,\n span: declaration.span,\n });\n continue;\n }\n if (modelNames.has(declaration.name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Named type \"${declaration.name}\" conflicts with model name \"${declaration.name}\"`,\n span: declaration.span,\n });\n continue;\n }\n if (enumNames.has(declaration.name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Named type \"${declaration.name}\" conflicts with enum name \"${declaration.name}\"`,\n span: declaration.span,\n });\n }\n }\n const normalizedModels = models.map((model) => ({\n ...model,\n fields: model.fields.map((field) => {\n if (!namedTypeNames.has(field.typeName)) {\n return field;\n }\n const hasRelationAttribute = field.attributes.some(\n (attribute) => attribute.name === 'relation',\n );\n if (\n hasRelationAttribute ||\n modelNames.has(field.typeName) ||\n enumNames.has(field.typeName) ||\n SCALAR_TYPES.has(field.typeName)\n ) {\n return field;\n }\n return {\n ...field,\n typeRef: field.typeName,\n };\n }),\n }));\n\n const ast: PslDocumentAst = {\n kind: 'document',\n sourceId: input.sourceId,\n models: normalizedModels,\n enums,\n ...ifDefined('types', typesBlock),\n span: {\n start: createPosition(context, 0, 0),\n end: createPosition(\n context,\n Math.max(lines.length - 1, 0),\n (lines[Math.max(lines.length - 1, 0)] ?? '').length,\n ),\n },\n };\n\n return {\n ast,\n diagnostics,\n ok: diagnostics.length === 0,\n };\n}\n\nfunction parseModelBlock(context: ParserContext, name: string, bounds: BlockBounds): PslModel {\n const fields: PslField[] = [];\n const attributes: PslModelAttribute[] = [];\n\n for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {\n const raw = context.lines[lineIndex] ?? '';\n const line = stripInlineComment(raw).trim();\n if (line.length === 0) {\n continue;\n }\n\n if (line.startsWith('@@')) {\n const attribute = parseModelAttribute(context, line, lineIndex);\n if (attribute) {\n attributes.push(attribute);\n }\n continue;\n }\n\n const field = parseField(context, line, lineIndex);\n if (field) {\n fields.push(field);\n }\n }\n\n return {\n kind: 'model',\n name,\n fields,\n attributes,\n span: createLineRangeSpan(context, bounds.startLine, bounds.endLine),\n };\n}\n\nfunction parseEnumBlock(context: ParserContext, name: string, bounds: BlockBounds): PslEnum {\n const values: PslEnumValue[] = [];\n\n for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {\n const raw = context.lines[lineIndex] ?? '';\n const line = stripInlineComment(raw).trim();\n if (line.length === 0) {\n continue;\n }\n\n const valueMatch = line.match(/^([A-Za-z_]\\w*)$/);\n if (!valueMatch) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ENUM_MEMBER',\n message: `Invalid enum value declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n continue;\n }\n\n values.push({\n kind: 'enumValue',\n name: valueMatch[1] ?? '',\n span: createTrimmedLineSpan(context, lineIndex),\n });\n }\n\n return {\n kind: 'enum',\n name,\n values,\n span: createLineRangeSpan(context, bounds.startLine, bounds.endLine),\n };\n}\n\nfunction parseTypesBlock(context: ParserContext, bounds: BlockBounds): PslTypesBlock {\n const declarations: PslNamedTypeDeclaration[] = [];\n\n for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {\n const raw = context.lines[lineIndex] ?? '';\n const lineWithoutComment = stripInlineComment(raw);\n const line = lineWithoutComment.trim();\n if (line.length === 0) {\n continue;\n }\n\n const declarationMatch = line.match(/^([A-Za-z_]\\w*)\\s*=\\s*([A-Za-z_]\\w*)(.*)$/);\n if (!declarationMatch) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Invalid types declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n continue;\n }\n\n const declarationName = declarationMatch[1] ?? '';\n const baseType = declarationMatch[2] ?? '';\n const attributePart = declarationMatch[3] ?? '';\n const trimmedStartColumn = firstNonWhitespaceColumn(raw);\n const attributeOffset = line.length - attributePart.length;\n const attributeSource = attributePart.trimStart();\n const leadingAttributeWhitespace = attributePart.length - attributeSource.length;\n const attributeParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n attributeSource,\n trimmedStartColumn + attributeOffset + leadingAttributeWhitespace,\n );\n if (!attributeParse.ok) {\n continue;\n }\n const attributes = attributeParse.tokens\n .map((token) =>\n parseAttributeToken(context, {\n token: token.text,\n target: 'namedType',\n lineIndex,\n span: token.span,\n }),\n )\n .filter((attribute): attribute is PslAttribute => Boolean(attribute));\n\n declarations.push({\n kind: 'namedType',\n name: declarationName,\n baseType,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n }\n\n return {\n kind: 'types',\n declarations,\n span: createLineRangeSpan(context, bounds.startLine, bounds.endLine),\n };\n}\n\nfunction parseModelAttribute(\n context: ParserContext,\n line: string,\n lineIndex: number,\n): PslModelAttribute | undefined {\n const rawLine = context.lines[lineIndex] ?? '';\n const tokenParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n line,\n firstNonWhitespaceColumn(rawLine),\n );\n if (!tokenParse.ok || tokenParse.tokens.length !== 1) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid model attribute syntax \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n return undefined;\n }\n const token = tokenParse.tokens[0];\n if (!token) {\n return undefined;\n }\n return parseAttributeToken(context, {\n token: token.text,\n target: 'model',\n lineIndex,\n span: token.span,\n });\n}\n\nfunction parseField(context: ParserContext, line: string, lineIndex: number): PslField | undefined {\n const fieldMatch = line.match(/^([A-Za-z_]\\w*)\\s+([A-Za-z_]\\w*(?:\\[\\])?)(\\?)?(.*)$/);\n if (!fieldMatch) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_MODEL_MEMBER',\n message: `Invalid model member declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n return undefined;\n }\n\n const fieldName = fieldMatch[1] ?? '';\n const rawTypeToken = fieldMatch[2] ?? '';\n const optionalMarker = fieldMatch[3] ?? '';\n const attributePart = fieldMatch[4] ?? '';\n const list = rawTypeToken.endsWith('[]');\n const typeName = list ? rawTypeToken.slice(0, -2) : rawTypeToken;\n const optional = optionalMarker === '?';\n\n const attributes: PslFieldAttribute[] = [];\n const rawLine = context.lines[lineIndex] ?? '';\n const trimmedStartColumn = firstNonWhitespaceColumn(rawLine);\n const attributeOffset = line.length - attributePart.length;\n const attributeSource = attributePart.trimStart();\n const leadingAttributeWhitespace = attributePart.length - attributeSource.length;\n const tokenParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n attributeSource,\n trimmedStartColumn + attributeOffset + leadingAttributeWhitespace,\n );\n if (!tokenParse.ok) {\n return {\n kind: 'field',\n name: fieldName,\n typeName,\n optional,\n list,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\n };\n }\n\n for (const token of tokenParse.tokens) {\n const parsed = parseAttributeToken(context, {\n token: token.text,\n target: 'field',\n lineIndex,\n span: token.span,\n });\n if (parsed) {\n attributes.push(parsed);\n }\n }\n\n return {\n kind: 'field',\n name: fieldName,\n typeName,\n optional,\n list,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\n };\n}\n\nfunction parseAttributeToken(\n context: ParserContext,\n input: {\n readonly token: string;\n readonly target: PslAttributeTarget;\n readonly lineIndex: number;\n readonly span: PslSpan;\n },\n): PslAttribute | undefined {\n const expectsModelPrefix = input.target === 'model';\n if (expectsModelPrefix && !input.token.startsWith('@@')) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Model attribute \"${input.token}\" must use @@ prefix`,\n span: input.span,\n });\n return undefined;\n }\n if (!expectsModelPrefix && !input.token.startsWith('@')) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Attribute \"${input.token}\" must use @ prefix`,\n span: input.span,\n });\n return undefined;\n }\n if (!expectsModelPrefix && input.token.startsWith('@@')) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Attribute \"${input.token}\" is not valid in ${input.target} context`,\n span: input.span,\n });\n return undefined;\n }\n\n const rawBody = expectsModelPrefix ? input.token.slice(2) : input.token.slice(1);\n const openParen = rawBody.indexOf('(');\n const closeParen = rawBody.lastIndexOf(')');\n const hasArgs = openParen >= 0 || closeParen >= 0;\n if ((openParen >= 0 && closeParen === -1) || (openParen === -1 && closeParen >= 0)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${input.token}\"`,\n span: input.span,\n });\n return undefined;\n }\n\n const name = (openParen >= 0 ? rawBody.slice(0, openParen) : rawBody).trim();\n if (!/^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z_][A-Za-z0-9_-]*)*$/.test(name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute name \"${name || input.token}\"`,\n span: input.span,\n });\n return undefined;\n }\n\n let args: readonly PslAttributeArgument[] = [];\n if (hasArgs && openParen >= 0 && closeParen >= openParen) {\n if (closeParen !== rawBody.length - 1) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid trailing syntax in attribute \"${input.token}\"`,\n span: input.span,\n });\n return undefined;\n }\n const argsRaw = rawBody.slice(openParen + 1, closeParen);\n const parsedArgs = parseAttributeArguments(context, {\n argsRaw,\n argsOffset: input.span.start.column - 1 + (expectsModelPrefix ? 2 : 1) + openParen + 1,\n lineIndex: input.lineIndex,\n token: input.token,\n span: input.span,\n });\n if (!parsedArgs) {\n return undefined;\n }\n args = parsedArgs;\n }\n\n return {\n kind: 'attribute',\n target: input.target,\n name,\n args,\n span: input.span,\n };\n}\n\nfunction parseAttributeArguments(\n context: ParserContext,\n input: {\n readonly argsRaw: string;\n readonly argsOffset: number;\n readonly lineIndex: number;\n readonly token: string;\n readonly span: PslSpan;\n },\n): readonly PslAttributeArgument[] | undefined {\n const trimmed = input.argsRaw.trim();\n if (trimmed.length === 0) {\n return [];\n }\n\n const parts = splitTopLevelSegments(input.argsRaw, ',');\n const args: PslAttributeArgument[] = [];\n\n for (const part of parts) {\n const original = part.value;\n const trimmedPart = original.trim();\n if (trimmedPart.length === 0) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid empty argument in attribute \"${input.token}\"`,\n span: input.span,\n });\n return undefined;\n }\n\n const leadingWhitespace = original.length - original.trimStart().length;\n const partStart = input.argsOffset + part.start + leadingWhitespace;\n const partEnd = partStart + trimmedPart.length;\n const partSpan = createInlineSpan(context, input.lineIndex, partStart, partEnd);\n\n const namedSplit = splitTopLevelSegments(trimmedPart, ':');\n if (namedSplit.length > 1) {\n const first = namedSplit[0];\n if (!first) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid named argument syntax \"${trimmedPart}\"`,\n span: partSpan,\n });\n return undefined;\n }\n const name = first.value.trim();\n const rawValue = trimmedPart.slice(first.end + 1).trim();\n if (!name || rawValue.length === 0) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid named argument syntax \"${trimmedPart}\"`,\n span: partSpan,\n });\n return undefined;\n }\n args.push({\n kind: 'named',\n name,\n value: normalizeAttributeArgumentValue(rawValue),\n span: partSpan,\n });\n continue;\n }\n\n args.push({\n kind: 'positional',\n value: normalizeAttributeArgumentValue(trimmedPart),\n span: partSpan,\n });\n }\n\n return args;\n}\n\nfunction normalizeAttributeArgumentValue(value: string): string {\n return value.trim();\n}\n\nfunction findBlockBounds(context: ParserContext, startLine: number): BlockBounds {\n let depth = 0;\n\n for (let lineIndex = startLine; lineIndex < context.lines.length; lineIndex += 1) {\n const line = stripInlineComment(context.lines[lineIndex] ?? '');\n let quote: '\"' | \"'\" | null = null;\n let previousCharacter = '';\n for (const character of line) {\n if (quote) {\n if (character === quote && previousCharacter !== '\\\\') {\n quote = null;\n }\n previousCharacter = character;\n continue;\n }\n\n if (character === '\"' || character === \"'\") {\n quote = character;\n previousCharacter = character;\n continue;\n }\n\n if (character === '{') {\n depth += 1;\n }\n if (character === '}') {\n depth -= 1;\n if (depth === 0) {\n return { startLine, endLine: lineIndex, closed: true };\n }\n }\n previousCharacter = character;\n }\n }\n\n pushDiagnostic(context, {\n code: 'PSL_UNTERMINATED_BLOCK',\n message: 'Unterminated block declaration',\n span: createTrimmedLineSpan(context, startLine),\n });\n return {\n startLine,\n endLine: context.lines.length - 1,\n closed: false,\n };\n}\n\ninterface TopLevelSegment {\n readonly value: string;\n readonly start: number;\n readonly end: number;\n}\n\nfunction splitTopLevelSegments(value: string, separator: ',' | ':'): TopLevelSegment[] {\n const parts: TopLevelSegment[] = [];\n let depthParen = 0;\n let depthBracket = 0;\n let quote: '\"' | \"'\" | null = null;\n let start = 0;\n\n for (let index = 0; index < value.length; index += 1) {\n const character = value[index] ?? '';\n if (quote) {\n if (character === quote && value[index - 1] !== '\\\\') {\n quote = null;\n }\n continue;\n }\n\n if (character === '\"' || character === \"'\") {\n quote = character;\n continue;\n }\n\n if (character === '(') {\n depthParen += 1;\n continue;\n }\n if (character === ')') {\n depthParen = Math.max(0, depthParen - 1);\n continue;\n }\n if (character === '[') {\n depthBracket += 1;\n continue;\n }\n if (character === ']') {\n depthBracket = Math.max(0, depthBracket - 1);\n continue;\n }\n\n if (character === separator && depthParen === 0 && depthBracket === 0) {\n parts.push({\n value: value.slice(start, index),\n start,\n end: index,\n });\n start = index + 1;\n }\n }\n\n parts.push({\n value: value.slice(start),\n start,\n end: value.length,\n });\n return parts;\n}\n\nfunction extractAttributeTokensWithSpans(\n context: ParserContext,\n lineIndex: number,\n value: string,\n startColumn: number,\n): { readonly ok: boolean; readonly tokens: readonly { text: string; span: PslSpan }[] } {\n const tokens: { text: string; span: PslSpan }[] = [];\n let index = 0;\n while (index < value.length) {\n while (index < value.length && /\\s/.test(value[index] ?? '')) {\n index += 1;\n }\n if (index >= value.length) {\n break;\n }\n\n if (value[index] !== '@') {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${value.trim()}\"`,\n span: createInlineSpan(context, lineIndex, startColumn + index, startColumn + value.length),\n });\n return { ok: false, tokens };\n }\n\n const start = index;\n index += 1;\n if (value[index] === '@') {\n index += 1;\n }\n\n const nameStart = index;\n while (index < value.length && /[A-Za-z0-9_.-]/.test(value[index] ?? '')) {\n index += 1;\n }\n\n if (index === nameStart) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${value.slice(start).trim()}\"`,\n span: createInlineSpan(context, lineIndex, startColumn + start, startColumn + value.length),\n });\n return { ok: false, tokens };\n }\n\n if (value[index] === '(') {\n let depth = 0;\n let quote: '\"' | \"'\" | null = null;\n while (index < value.length) {\n const char = value[index] ?? '';\n if (quote) {\n if (char === quote && value[index - 1] !== '\\\\') {\n quote = null;\n }\n index += 1;\n continue;\n }\n\n if (char === '\"' || char === \"'\") {\n quote = char;\n index += 1;\n continue;\n }\n\n if (char === '(') {\n depth += 1;\n } else if (char === ')') {\n depth -= 1;\n if (depth === 0) {\n index += 1;\n break;\n }\n }\n index += 1;\n }\n if (depth !== 0) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Unterminated attribute argument list in \"${value.slice(start).trim()}\"`,\n span: createInlineSpan(\n context,\n lineIndex,\n startColumn + start,\n startColumn + value.length,\n ),\n });\n return { ok: false, tokens };\n }\n }\n\n const tokenText = value.slice(start, index).trim();\n tokens.push({\n text: tokenText,\n span: createInlineSpan(context, lineIndex, startColumn + start, startColumn + index),\n });\n\n while (index < value.length && /\\s/.test(value[index] ?? '')) {\n index += 1;\n }\n\n if (index < value.length && value[index] !== '@') {\n break;\n }\n }\n\n if (index < value.length && value[index] !== '@') {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${value.trim()}\"`,\n span: createInlineSpan(context, lineIndex, startColumn + index, startColumn + value.length),\n });\n return { ok: false, tokens };\n }\n\n return { ok: true, tokens };\n}\n\nfunction stripInlineComment(line: string): string {\n let quote: '\"' | \"'\" | null = null;\n for (let index = 0; index < line.length - 1; index += 1) {\n const current = line[index] ?? '';\n const next = line[index + 1] ?? '';\n\n if (quote) {\n if (current === quote && line[index - 1] !== '\\\\') {\n quote = null;\n }\n continue;\n }\n\n if (current === '\"' || current === \"'\") {\n quote = current;\n continue;\n }\n\n if (current === '/' && next === '/') {\n return line.slice(0, index);\n }\n }\n\n return line;\n}\n\nfunction computeLineOffsets(schema: string): number[] {\n const offsets = [0];\n for (let index = 0; index < schema.length; index += 1) {\n if (schema[index] === '\\n') {\n offsets.push(index + 1);\n }\n }\n return offsets;\n}\n\nfunction firstNonWhitespaceColumn(line: string): number {\n const first = line.search(/\\S/);\n return first === -1 ? 0 : first;\n}\n\nfunction createInlineSpan(\n context: ParserContext,\n lineIndex: number,\n startColumn: number,\n endColumn: number,\n): PslSpan {\n return {\n start: createPosition(context, lineIndex, startColumn),\n end: createPosition(context, lineIndex, endColumn),\n };\n}\n\nfunction createTrimmedLineSpan(context: ParserContext, lineIndex: number): PslSpan {\n const line = context.lines[lineIndex] ?? '';\n const startColumn = firstNonWhitespaceColumn(line);\n return {\n start: createPosition(context, lineIndex, startColumn),\n end: createPosition(context, lineIndex, line.length),\n };\n}\n\nfunction createLineRangeSpan(context: ParserContext, startLine: number, endLine: number): PslSpan {\n const startLineText = context.lines[startLine] ?? '';\n const endLineText = context.lines[endLine] ?? '';\n const startColumn = firstNonWhitespaceColumn(startLineText);\n return {\n start: createPosition(context, startLine, startColumn),\n end: createPosition(context, endLine, endLineText.length),\n };\n}\n\nfunction createPosition(\n context: ParserContext,\n lineIndex: number,\n columnIndex: number,\n): PslPosition {\n const clampedLineIndex = Math.max(0, Math.min(lineIndex, context.lineOffsets.length - 1));\n const lineText = context.lines[clampedLineIndex] ?? '';\n const clampedColumnIndex = Math.max(0, Math.min(columnIndex, lineText.length));\n return {\n offset: (context.lineOffsets[clampedLineIndex] ?? 0) + clampedColumnIndex,\n line: clampedLineIndex + 1,\n column: clampedColumnIndex + 1,\n };\n}\n\nfunction pushDiagnostic(\n context: ParserContext,\n diagnostic: Omit<PslDiagnostic, 'sourceId'> & { readonly code: PslDiagnosticCode },\n): void {\n context.diagnostics.push({\n ...diagnostic,\n sourceId: context.sourceId,\n });\n}\n"],"mappings":";;;AAsBA,MAAM,eAAe,IAAI,IAAI;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAgBF,SAAgB,iBAAiB,OAAsD;CACrF,MAAM,mBAAmB,MAAM,OAAO,WAAW,QAAQ,KAAK;CAC9D,MAAM,QAAQ,iBAAiB,MAAM,KAAK;CAC1C,MAAM,cAAc,mBAAmB,iBAAiB;CACxD,MAAMA,cAA+B,EAAE;CACvC,MAAMC,UAAyB;EAC7B,QAAQ;EACR,UAAU,MAAM;EAChB;EACA;EACA;EACD;CAED,MAAMC,SAAqB,EAAE;CAC7B,MAAMC,QAAmB,EAAE;CAC3B,IAAIC;CAEJ,IAAI,YAAY;AAChB,QAAO,YAAY,MAAM,QAAQ;EAE/B,MAAM,OAAO,mBADG,MAAM,cAAc,GACI,CAAC,MAAM;AAC/C,MAAI,KAAK,WAAW,GAAG;AACrB,gBAAa;AACb;;EAGF,MAAM,aAAa,KAAK,MAAM,gCAAgC;AAC9D,MAAI,YAAY;GACd,MAAM,SAAS,gBAAgB,SAAS,UAAU;GAClD,MAAM,OAAO,WAAW,MAAM;AAC9B,OAAI,KAAK,WAAW,GAAG;AACrB,gBAAY,OAAO,UAAU;AAC7B;;AAEF,UAAO,KAAK,gBAAgB,SAAS,MAAM,OAAO,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C,QAAO;EACL,OAAO,eAAe,SAAS,WAFb,yBAAyB,cAAc,CAEH;EACtD,KAAK,eAAe,SAAS,SAAS,YAAY,OAAO;EAC1D;;AAGH,SAAS,eACP,SACA,WACA,aACa;CACb,MAAM,mBAAmB,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,QAAQ,YAAY,SAAS,EAAE,CAAC;CACzF,MAAM,WAAW,QAAQ,MAAM,qBAAqB;CACpD,MAAM,qBAAqB,KAAK,IAAI,GAAG,KAAK,IAAI,aAAa,SAAS,OAAO,CAAC;AAC9E,QAAO;EACL,SAAS,QAAQ,YAAY,qBAAqB,KAAK;EACvD,MAAM,mBAAmB;EACzB,QAAQ,qBAAqB;EAC9B;;AAGH,SAAS,eACP,SACA,YACM;AACN,SAAQ,YAAY,KAAK;EACvB,GAAG;EACH,UAAU,QAAQ;EACnB,CAAC"}
1
+ {"version":3,"file":"parser-Br4vqzd-.mjs","names":["diagnostics: PslDiagnostic[]","context: ParserContext","models: PslModel[]","enums: PslEnum[]","typesBlock: PslTypesBlock | undefined","fields: PslField[]","attributes: PslModelAttribute[]","values: PslEnumValue[]","declarations: PslNamedTypeDeclaration[]","attributes: PslFieldAttribute[]","args: readonly PslAttributeArgument[]","args: PslAttributeArgument[]","quote: '\"' | \"'\" | null","parts: TopLevelSegment[]","tokens: { text: string; span: PslSpan }[]"],"sources":["../src/parser.ts"],"sourcesContent":["import { ifDefined } from '@prisma-next/utils/defined';\nimport type {\n ParsePslDocumentInput,\n ParsePslDocumentResult,\n PslAttribute,\n PslAttributeArgument,\n PslAttributeTarget,\n PslDiagnostic,\n PslDiagnosticCode,\n PslDocumentAst,\n PslEnum,\n PslEnumValue,\n PslField,\n PslFieldAttribute,\n PslModel,\n PslModelAttribute,\n PslNamedTypeDeclaration,\n PslPosition,\n PslSpan,\n PslTypesBlock,\n} from './types';\n\nconst SCALAR_TYPES = new Set([\n 'String',\n 'Boolean',\n 'Int',\n 'BigInt',\n 'Float',\n 'Decimal',\n 'DateTime',\n 'Json',\n 'Bytes',\n]);\n\ninterface BlockBounds {\n readonly startLine: number;\n readonly endLine: number;\n readonly closed: boolean;\n}\n\ninterface ParserContext {\n readonly schema: string;\n readonly sourceId: string;\n readonly lines: readonly string[];\n readonly lineOffsets: readonly number[];\n readonly diagnostics: PslDiagnostic[];\n}\n\nexport function parsePslDocument(input: ParsePslDocumentInput): ParsePslDocumentResult {\n const normalizedSchema = input.schema.replaceAll('\\r\\n', '\\n');\n const lines = normalizedSchema.split('\\n');\n const lineOffsets = computeLineOffsets(normalizedSchema);\n const diagnostics: PslDiagnostic[] = [];\n const context: ParserContext = {\n schema: normalizedSchema,\n sourceId: input.sourceId,\n lines,\n lineOffsets,\n diagnostics,\n };\n\n const models: PslModel[] = [];\n const enums: PslEnum[] = [];\n let typesBlock: PslTypesBlock | undefined;\n\n let lineIndex = 0;\n while (lineIndex < lines.length) {\n const rawLine = lines[lineIndex] ?? '';\n const line = stripInlineComment(rawLine).trim();\n if (line.length === 0) {\n lineIndex += 1;\n continue;\n }\n\n const modelMatch = line.match(/^model\\s+([A-Za-z_]\\w*)\\s*\\{$/);\n if (modelMatch) {\n const bounds = findBlockBounds(context, lineIndex);\n const name = modelMatch[1] ?? '';\n if (name.length === 0) {\n lineIndex = bounds.endLine + 1;\n continue;\n }\n models.push(parseModelBlock(context, name, bounds));\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n const enumMatch = line.match(/^enum\\s+([A-Za-z_]\\w*)\\s*\\{$/);\n if (enumMatch) {\n const bounds = findBlockBounds(context, lineIndex);\n const name = enumMatch[1] ?? '';\n if (name.length === 0) {\n lineIndex = bounds.endLine + 1;\n continue;\n }\n enums.push(parseEnumBlock(context, name, bounds));\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n if (/^types\\s*\\{$/.test(line)) {\n const bounds = findBlockBounds(context, lineIndex);\n typesBlock = parseTypesBlock(context, bounds);\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n if (line.includes('{')) {\n const blockName = line.split(/\\s+/)[0] ?? 'block';\n pushDiagnostic(context, {\n code: 'PSL_UNSUPPORTED_TOP_LEVEL_BLOCK',\n message: `Unsupported top-level block \"${blockName}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n const bounds = findBlockBounds(context, lineIndex);\n lineIndex = bounds.endLine + 1;\n continue;\n }\n\n pushDiagnostic(context, {\n code: 'PSL_UNSUPPORTED_TOP_LEVEL_BLOCK',\n message: `Unsupported top-level declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n lineIndex += 1;\n }\n\n const namedTypeNames = new Set(\n (typesBlock?.declarations ?? []).map((declaration) => declaration.name),\n );\n const modelNames = new Set(models.map((model) => model.name));\n const enumNames = new Set(enums.map((enumBlock) => enumBlock.name));\n for (const declaration of typesBlock?.declarations ?? []) {\n if (SCALAR_TYPES.has(declaration.name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Named type \"${declaration.name}\" conflicts with scalar type \"${declaration.name}\"`,\n span: declaration.span,\n });\n continue;\n }\n if (modelNames.has(declaration.name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Named type \"${declaration.name}\" conflicts with model name \"${declaration.name}\"`,\n span: declaration.span,\n });\n continue;\n }\n if (enumNames.has(declaration.name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Named type \"${declaration.name}\" conflicts with enum name \"${declaration.name}\"`,\n span: declaration.span,\n });\n }\n }\n const normalizedModels = models.map((model) => ({\n ...model,\n fields: model.fields.map((field) => {\n if (!namedTypeNames.has(field.typeName)) {\n return field;\n }\n const hasRelationAttribute = field.attributes.some(\n (attribute) => attribute.name === 'relation',\n );\n if (\n hasRelationAttribute ||\n modelNames.has(field.typeName) ||\n enumNames.has(field.typeName) ||\n SCALAR_TYPES.has(field.typeName)\n ) {\n return field;\n }\n return {\n ...field,\n typeRef: field.typeName,\n };\n }),\n }));\n\n const ast: PslDocumentAst = {\n kind: 'document',\n sourceId: input.sourceId,\n models: normalizedModels,\n enums,\n ...ifDefined('types', typesBlock),\n span: {\n start: createPosition(context, 0, 0),\n end: createPosition(\n context,\n Math.max(lines.length - 1, 0),\n (lines[Math.max(lines.length - 1, 0)] ?? '').length,\n ),\n },\n };\n\n return {\n ast,\n diagnostics,\n ok: diagnostics.length === 0,\n };\n}\n\nfunction parseModelBlock(context: ParserContext, name: string, bounds: BlockBounds): PslModel {\n const fields: PslField[] = [];\n const attributes: PslModelAttribute[] = [];\n\n for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {\n const raw = context.lines[lineIndex] ?? '';\n const line = stripInlineComment(raw).trim();\n if (line.length === 0) {\n continue;\n }\n\n if (line.startsWith('@@')) {\n const attribute = parseModelAttribute(context, line, lineIndex);\n if (attribute) {\n attributes.push(attribute);\n }\n continue;\n }\n\n const field = parseField(context, line, lineIndex);\n if (field) {\n fields.push(field);\n }\n }\n\n return {\n kind: 'model',\n name,\n fields,\n attributes,\n span: createLineRangeSpan(context, bounds.startLine, bounds.endLine),\n };\n}\n\nfunction parseEnumBlock(context: ParserContext, name: string, bounds: BlockBounds): PslEnum {\n const values: PslEnumValue[] = [];\n\n for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {\n const raw = context.lines[lineIndex] ?? '';\n const line = stripInlineComment(raw).trim();\n if (line.length === 0) {\n continue;\n }\n\n const valueMatch = line.match(/^([A-Za-z_]\\w*)$/);\n if (!valueMatch) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ENUM_MEMBER',\n message: `Invalid enum value declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n continue;\n }\n\n values.push({\n kind: 'enumValue',\n name: valueMatch[1] ?? '',\n span: createTrimmedLineSpan(context, lineIndex),\n });\n }\n\n return {\n kind: 'enum',\n name,\n values,\n span: createLineRangeSpan(context, bounds.startLine, bounds.endLine),\n };\n}\n\nfunction parseTypesBlock(context: ParserContext, bounds: BlockBounds): PslTypesBlock {\n const declarations: PslNamedTypeDeclaration[] = [];\n\n for (let lineIndex = bounds.startLine + 1; lineIndex < bounds.endLine; lineIndex += 1) {\n const raw = context.lines[lineIndex] ?? '';\n const lineWithoutComment = stripInlineComment(raw);\n const line = lineWithoutComment.trim();\n if (line.length === 0) {\n continue;\n }\n\n const declarationMatch = line.match(/^([A-Za-z_]\\w*)\\s*=\\s*([A-Za-z_]\\w*)(.*)$/);\n if (!declarationMatch) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_TYPES_MEMBER',\n message: `Invalid types declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n continue;\n }\n\n const declarationName = declarationMatch[1] ?? '';\n const baseType = declarationMatch[2] ?? '';\n const attributePart = declarationMatch[3] ?? '';\n const trimmedStartColumn = firstNonWhitespaceColumn(raw);\n const attributeOffset = line.length - attributePart.length;\n const attributeSource = attributePart.trimStart();\n const leadingAttributeWhitespace = attributePart.length - attributeSource.length;\n const attributeParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n attributeSource,\n trimmedStartColumn + attributeOffset + leadingAttributeWhitespace,\n );\n if (!attributeParse.ok) {\n continue;\n }\n const attributes = attributeParse.tokens\n .map((token) =>\n parseAttributeToken(context, {\n token: token.text,\n target: 'namedType',\n lineIndex,\n span: token.span,\n }),\n )\n .filter((attribute): attribute is PslAttribute => Boolean(attribute));\n\n declarations.push({\n kind: 'namedType',\n name: declarationName,\n baseType,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n }\n\n return {\n kind: 'types',\n declarations,\n span: createLineRangeSpan(context, bounds.startLine, bounds.endLine),\n };\n}\n\nfunction parseModelAttribute(\n context: ParserContext,\n line: string,\n lineIndex: number,\n): PslModelAttribute | undefined {\n const rawLine = context.lines[lineIndex] ?? '';\n const tokenParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n line,\n firstNonWhitespaceColumn(rawLine),\n );\n if (!tokenParse.ok || tokenParse.tokens.length !== 1) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid model attribute syntax \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n return undefined;\n }\n const token = tokenParse.tokens[0];\n if (!token) {\n return undefined;\n }\n return parseAttributeToken(context, {\n token: token.text,\n target: 'model',\n lineIndex,\n span: token.span,\n });\n}\n\nfunction parseField(context: ParserContext, line: string, lineIndex: number): PslField | undefined {\n const fieldMatch = line.match(/^([A-Za-z_]\\w*)\\s+([A-Za-z_]\\w*(?:\\[\\])?)(\\?)?(.*)$/);\n if (!fieldMatch) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_MODEL_MEMBER',\n message: `Invalid model member declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n return undefined;\n }\n\n const fieldName = fieldMatch[1] ?? '';\n const rawTypeToken = fieldMatch[2] ?? '';\n const optionalMarker = fieldMatch[3] ?? '';\n const attributePart = fieldMatch[4] ?? '';\n const list = rawTypeToken.endsWith('[]');\n const typeName = list ? rawTypeToken.slice(0, -2) : rawTypeToken;\n const optional = optionalMarker === '?';\n\n const attributes: PslFieldAttribute[] = [];\n const rawLine = context.lines[lineIndex] ?? '';\n const trimmedStartColumn = firstNonWhitespaceColumn(rawLine);\n const attributeOffset = line.length - attributePart.length;\n const attributeSource = attributePart.trimStart();\n const leadingAttributeWhitespace = attributePart.length - attributeSource.length;\n const tokenParse = extractAttributeTokensWithSpans(\n context,\n lineIndex,\n attributeSource,\n trimmedStartColumn + attributeOffset + leadingAttributeWhitespace,\n );\n if (!tokenParse.ok) {\n return {\n kind: 'field',\n name: fieldName,\n typeName,\n optional,\n list,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\n };\n }\n\n for (const token of tokenParse.tokens) {\n const parsed = parseAttributeToken(context, {\n token: token.text,\n target: 'field',\n lineIndex,\n span: token.span,\n });\n if (parsed) {\n attributes.push(parsed);\n }\n }\n\n return {\n kind: 'field',\n name: fieldName,\n typeName,\n optional,\n list,\n attributes,\n span: createTrimmedLineSpan(context, lineIndex),\n };\n}\n\nfunction parseAttributeToken(\n context: ParserContext,\n input: {\n readonly token: string;\n readonly target: PslAttributeTarget;\n readonly lineIndex: number;\n readonly span: PslSpan;\n },\n): PslAttribute | undefined {\n const expectsModelPrefix = input.target === 'model';\n if (expectsModelPrefix && !input.token.startsWith('@@')) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Model attribute \"${input.token}\" must use @@ prefix`,\n span: input.span,\n });\n return undefined;\n }\n if (!expectsModelPrefix && !input.token.startsWith('@')) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Attribute \"${input.token}\" must use @ prefix`,\n span: input.span,\n });\n return undefined;\n }\n if (!expectsModelPrefix && input.token.startsWith('@@')) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Attribute \"${input.token}\" is not valid in ${input.target} context`,\n span: input.span,\n });\n return undefined;\n }\n\n const rawBody = expectsModelPrefix ? input.token.slice(2) : input.token.slice(1);\n const openParen = rawBody.indexOf('(');\n const closeParen = rawBody.lastIndexOf(')');\n const hasArgs = openParen >= 0 || closeParen >= 0;\n if ((openParen >= 0 && closeParen === -1) || (openParen === -1 && closeParen >= 0)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${input.token}\"`,\n span: input.span,\n });\n return undefined;\n }\n\n const name = (openParen >= 0 ? rawBody.slice(0, openParen) : rawBody).trim();\n if (!/^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z_][A-Za-z0-9_-]*)*$/.test(name)) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute name \"${name || input.token}\"`,\n span: input.span,\n });\n return undefined;\n }\n\n let args: readonly PslAttributeArgument[] = [];\n if (hasArgs && openParen >= 0 && closeParen >= openParen) {\n if (closeParen !== rawBody.length - 1) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid trailing syntax in attribute \"${input.token}\"`,\n span: input.span,\n });\n return undefined;\n }\n const argsRaw = rawBody.slice(openParen + 1, closeParen);\n const parsedArgs = parseAttributeArguments(context, {\n argsRaw,\n argsOffset: input.span.start.column - 1 + (expectsModelPrefix ? 2 : 1) + openParen + 1,\n lineIndex: input.lineIndex,\n token: input.token,\n span: input.span,\n });\n if (!parsedArgs) {\n return undefined;\n }\n args = parsedArgs;\n }\n\n return {\n kind: 'attribute',\n target: input.target,\n name,\n args,\n span: input.span,\n };\n}\n\nfunction parseAttributeArguments(\n context: ParserContext,\n input: {\n readonly argsRaw: string;\n readonly argsOffset: number;\n readonly lineIndex: number;\n readonly token: string;\n readonly span: PslSpan;\n },\n): readonly PslAttributeArgument[] | undefined {\n const trimmed = input.argsRaw.trim();\n if (trimmed.length === 0) {\n return [];\n }\n\n const parts = splitTopLevelSegments(input.argsRaw, ',');\n const args: PslAttributeArgument[] = [];\n\n for (const part of parts) {\n const original = part.value;\n const trimmedPart = original.trim();\n if (trimmedPart.length === 0) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid empty argument in attribute \"${input.token}\"`,\n span: input.span,\n });\n return undefined;\n }\n\n const leadingWhitespace = original.length - original.trimStart().length;\n const partStart = input.argsOffset + part.start + leadingWhitespace;\n const partEnd = partStart + trimmedPart.length;\n const partSpan = createInlineSpan(context, input.lineIndex, partStart, partEnd);\n\n const namedSplit = splitTopLevelSegments(trimmedPart, ':');\n if (namedSplit.length > 1) {\n const first = namedSplit[0];\n if (!first) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid named argument syntax \"${trimmedPart}\"`,\n span: partSpan,\n });\n return undefined;\n }\n const name = first.value.trim();\n const rawValue = trimmedPart.slice(first.end + 1).trim();\n if (!name || rawValue.length === 0) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid named argument syntax \"${trimmedPart}\"`,\n span: partSpan,\n });\n return undefined;\n }\n args.push({\n kind: 'named',\n name,\n value: normalizeAttributeArgumentValue(rawValue),\n span: partSpan,\n });\n continue;\n }\n\n args.push({\n kind: 'positional',\n value: normalizeAttributeArgumentValue(trimmedPart),\n span: partSpan,\n });\n }\n\n return args;\n}\n\nfunction normalizeAttributeArgumentValue(value: string): string {\n return value.trim();\n}\n\nfunction findBlockBounds(context: ParserContext, startLine: number): BlockBounds {\n let depth = 0;\n\n for (let lineIndex = startLine; lineIndex < context.lines.length; lineIndex += 1) {\n const line = stripInlineComment(context.lines[lineIndex] ?? '');\n let quote: '\"' | \"'\" | null = null;\n let previousCharacter = '';\n for (const character of line) {\n if (quote) {\n if (character === quote && previousCharacter !== '\\\\') {\n quote = null;\n }\n previousCharacter = character;\n continue;\n }\n\n if (character === '\"' || character === \"'\") {\n quote = character;\n previousCharacter = character;\n continue;\n }\n\n if (character === '{') {\n depth += 1;\n }\n if (character === '}') {\n depth -= 1;\n if (depth === 0) {\n return { startLine, endLine: lineIndex, closed: true };\n }\n }\n previousCharacter = character;\n }\n }\n\n pushDiagnostic(context, {\n code: 'PSL_UNTERMINATED_BLOCK',\n message: 'Unterminated block declaration',\n span: createTrimmedLineSpan(context, startLine),\n });\n return {\n startLine,\n endLine: context.lines.length - 1,\n closed: false,\n };\n}\n\ninterface TopLevelSegment {\n readonly value: string;\n readonly start: number;\n readonly end: number;\n}\n\nfunction splitTopLevelSegments(value: string, separator: ',' | ':'): TopLevelSegment[] {\n const parts: TopLevelSegment[] = [];\n let depthParen = 0;\n let depthBracket = 0;\n let quote: '\"' | \"'\" | null = null;\n let start = 0;\n\n for (let index = 0; index < value.length; index += 1) {\n const character = value[index] ?? '';\n if (quote) {\n if (character === quote && value[index - 1] !== '\\\\') {\n quote = null;\n }\n continue;\n }\n\n if (character === '\"' || character === \"'\") {\n quote = character;\n continue;\n }\n\n if (character === '(') {\n depthParen += 1;\n continue;\n }\n if (character === ')') {\n depthParen = Math.max(0, depthParen - 1);\n continue;\n }\n if (character === '[') {\n depthBracket += 1;\n continue;\n }\n if (character === ']') {\n depthBracket = Math.max(0, depthBracket - 1);\n continue;\n }\n\n if (character === separator && depthParen === 0 && depthBracket === 0) {\n parts.push({\n value: value.slice(start, index),\n start,\n end: index,\n });\n start = index + 1;\n }\n }\n\n parts.push({\n value: value.slice(start),\n start,\n end: value.length,\n });\n return parts;\n}\n\nfunction extractAttributeTokensWithSpans(\n context: ParserContext,\n lineIndex: number,\n value: string,\n startColumn: number,\n): { readonly ok: boolean; readonly tokens: readonly { text: string; span: PslSpan }[] } {\n const tokens: { text: string; span: PslSpan }[] = [];\n let index = 0;\n while (index < value.length) {\n while (index < value.length && /\\s/.test(value[index] ?? '')) {\n index += 1;\n }\n if (index >= value.length) {\n break;\n }\n\n if (value[index] !== '@') {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${value.trim()}\"`,\n span: createInlineSpan(context, lineIndex, startColumn + index, startColumn + value.length),\n });\n return { ok: false, tokens };\n }\n\n const start = index;\n index += 1;\n if (value[index] === '@') {\n index += 1;\n }\n\n const nameStart = index;\n while (index < value.length && /[A-Za-z0-9_.-]/.test(value[index] ?? '')) {\n index += 1;\n }\n\n if (index === nameStart) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${value.slice(start).trim()}\"`,\n span: createInlineSpan(context, lineIndex, startColumn + start, startColumn + value.length),\n });\n return { ok: false, tokens };\n }\n\n if (value[index] === '(') {\n let depth = 0;\n let quote: '\"' | \"'\" | null = null;\n while (index < value.length) {\n const char = value[index] ?? '';\n if (quote) {\n if (char === quote && value[index - 1] !== '\\\\') {\n quote = null;\n }\n index += 1;\n continue;\n }\n\n if (char === '\"' || char === \"'\") {\n quote = char;\n index += 1;\n continue;\n }\n\n if (char === '(') {\n depth += 1;\n } else if (char === ')') {\n depth -= 1;\n if (depth === 0) {\n index += 1;\n break;\n }\n }\n index += 1;\n }\n if (depth !== 0) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Unterminated attribute argument list in \"${value.slice(start).trim()}\"`,\n span: createInlineSpan(\n context,\n lineIndex,\n startColumn + start,\n startColumn + value.length,\n ),\n });\n return { ok: false, tokens };\n }\n }\n\n const tokenText = value.slice(start, index).trim();\n tokens.push({\n text: tokenText,\n span: createInlineSpan(context, lineIndex, startColumn + start, startColumn + index),\n });\n\n while (index < value.length && /\\s/.test(value[index] ?? '')) {\n index += 1;\n }\n\n if (index < value.length && value[index] !== '@') {\n break;\n }\n }\n\n if (index < value.length && value[index] !== '@') {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `Invalid attribute syntax \"${value.trim()}\"`,\n span: createInlineSpan(context, lineIndex, startColumn + index, startColumn + value.length),\n });\n return { ok: false, tokens };\n }\n\n return { ok: true, tokens };\n}\n\nfunction stripInlineComment(line: string): string {\n let quote: '\"' | \"'\" | null = null;\n for (let index = 0; index < line.length - 1; index += 1) {\n const current = line[index] ?? '';\n const next = line[index + 1] ?? '';\n\n if (quote) {\n if (current === quote && line[index - 1] !== '\\\\') {\n quote = null;\n }\n continue;\n }\n\n if (current === '\"' || current === \"'\") {\n quote = current;\n continue;\n }\n\n if (current === '/' && next === '/') {\n return line.slice(0, index);\n }\n }\n\n return line;\n}\n\nfunction computeLineOffsets(schema: string): number[] {\n const offsets = [0];\n for (let index = 0; index < schema.length; index += 1) {\n if (schema[index] === '\\n') {\n offsets.push(index + 1);\n }\n }\n return offsets;\n}\n\nfunction firstNonWhitespaceColumn(line: string): number {\n const first = line.search(/\\S/);\n return first === -1 ? 0 : first;\n}\n\nfunction createInlineSpan(\n context: ParserContext,\n lineIndex: number,\n startColumn: number,\n endColumn: number,\n): PslSpan {\n return {\n start: createPosition(context, lineIndex, startColumn),\n end: createPosition(context, lineIndex, endColumn),\n };\n}\n\nfunction createTrimmedLineSpan(context: ParserContext, lineIndex: number): PslSpan {\n const line = context.lines[lineIndex] ?? '';\n const startColumn = firstNonWhitespaceColumn(line);\n return {\n start: createPosition(context, lineIndex, startColumn),\n end: createPosition(context, lineIndex, line.length),\n };\n}\n\nfunction createLineRangeSpan(context: ParserContext, startLine: number, endLine: number): PslSpan {\n const startLineText = context.lines[startLine] ?? '';\n const endLineText = context.lines[endLine] ?? '';\n const startColumn = firstNonWhitespaceColumn(startLineText);\n return {\n start: createPosition(context, startLine, startColumn),\n end: createPosition(context, endLine, endLineText.length),\n };\n}\n\nfunction createPosition(\n context: ParserContext,\n lineIndex: number,\n columnIndex: number,\n): PslPosition {\n const clampedLineIndex = Math.max(0, Math.min(lineIndex, context.lineOffsets.length - 1));\n const lineText = context.lines[clampedLineIndex] ?? '';\n const clampedColumnIndex = Math.max(0, Math.min(columnIndex, lineText.length));\n return {\n offset: (context.lineOffsets[clampedLineIndex] ?? 0) + clampedColumnIndex,\n line: clampedLineIndex + 1,\n column: clampedColumnIndex + 1,\n };\n}\n\nfunction pushDiagnostic(\n context: ParserContext,\n diagnostic: Omit<PslDiagnostic, 'sourceId'> & { readonly code: PslDiagnosticCode },\n): void {\n context.diagnostics.push({\n ...diagnostic,\n sourceId: context.sourceId,\n });\n}\n"],"mappings":";;;AAsBA,MAAM,eAAe,IAAI,IAAI;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAgBF,SAAgB,iBAAiB,OAAsD;CACrF,MAAM,mBAAmB,MAAM,OAAO,WAAW,QAAQ,KAAK;CAC9D,MAAM,QAAQ,iBAAiB,MAAM,KAAK;CAC1C,MAAM,cAAc,mBAAmB,iB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,QAAQ,EAAE;AAG3B,QAAO;;AAGT,SAAS,yBAAyB,MAAsB;CACtD,MAAM,QAAQ,KAAK,OAAO,KAAK;AAC/B,QAAO,UAAU,KAAK,IAAI;;AAG5B,SAAS,iBACP,SACA,WACA,aACA,WACS;AACT,QAAO;EACL,OAAO,eAAe,SAAS,WAAW,YAAY;EACtD,KAAK,eAAe,SAAS,WAAW,UAAU;EACnD;;AAGH,SAAS,sBAAsB,SAAwB,WAA4B;CACjF,MAAM,OAAO,QAAQ,MAAM,cAAc;AAEzC,QAAO;EACL,OAAO,eAAe,SAAS,WAFb,yBAAyB,KAAK,CAEM;EACtD,KAAK,eAAe,SAAS,WAAW,KAAK,OAAO;EACrD;;AAGH,SAAS,oBAAoB,SAAwB,WAAmB,SAA0B;CAChG,MAAM,gBAAgB,QAAQ,MAAM,cAAc;CAClD,MAAM,cAAc,QAAQ,MAAM,YAAY;AAE9C,QAAO;EACL,OAAO,eAAe,SAAS,WAFb,yBAAyB,cAAc,CAEH;EACtD,KAAK,eAAe,SAAS,SAAS,YAAY,OAAO;EAC1D;;AAGH,SAAS,eACP,SACA,WACA,aACa;CACb,MAAM,mBAAmB,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,QAAQ,YAAY,SAAS,EAAE,CAAC;CACzF,MAAM,WAAW,QAAQ,MAAM,qBAAqB;CACpD,MAAM,qBAAqB,KAAK,IAAI,GAAG,KAAK,IAAI,aAAa,SAAS,OAAO,CAAC;AAC9E,QAAO;EACL,SAAS,QAAQ,YAAY,qBAAqB,KAAK;EACvD,MAAM,mBAAmB;EACzB,QAAQ,qBAAqB;EAC9B;;AAGH,SAAS,eACP,SACA,YACM;AACN,SAAQ,YAAY,KAAK;EACvB,GAAG;EACH,UAAU,QAAQ;EACnB,CAAC"}
package/dist/parser.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as parsePslDocument } from "./parser-CUqO9VeG.mjs";
1
+ import { t as parsePslDocument } from "./parser-BgdIJNqs.mjs";
2
2
  export { parsePslDocument };
package/dist/parser.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as parsePslDocument } from "./parser-BP2RP4rk.mjs";
1
+ import { t as parsePslDocument } from "./parser-Br4vqzd-.mjs";
2
2
 
3
3
  export { parsePslDocument };
@@ -0,0 +1,15 @@
1
+ //#region src/tokenizer.d.ts
2
+ type TokenKind = 'Ident' | 'StringLiteral' | 'NumberLiteral' | 'At' | 'DoubleAt' | 'LBrace' | 'RBrace' | 'LParen' | 'RParen' | 'LBracket' | 'RBracket' | 'Equals' | 'Question' | 'Dot' | 'Comma' | 'Colon' | 'Whitespace' | 'Newline' | 'Comment' | 'Invalid' | 'Eof';
3
+ interface Token {
4
+ readonly kind: TokenKind;
5
+ readonly text: string;
6
+ }
7
+ declare class Tokenizer {
8
+ #private;
9
+ constructor(source: string);
10
+ next(): Token;
11
+ peek(offset?: number): Token;
12
+ }
13
+ //#endregion
14
+ export { type Token, type TokenKind, Tokenizer };
15
+ //# sourceMappingURL=tokenizer.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenizer.d.mts","names":[],"sources":["../src/tokenizer.ts"],"sourcesContent":[],"mappings":";KAAY,SAAA;AAAA,UAuBK,KAAA,CAvBI;EAuBJ,SAAK,IAAA,EACL,SAAA;EAIJ,SAAA,IAAS,EAAA,MAAA;;cAAT,SAAA;;;UAWH;yBAQU"}
@@ -0,0 +1,191 @@
1
+ //#region src/tokenizer.ts
2
+ var Tokenizer = class {
3
+ #source;
4
+ #pos;
5
+ #buffer;
6
+ constructor(source) {
7
+ this.#source = source;
8
+ this.#pos = 0;
9
+ this.#buffer = [];
10
+ }
11
+ next() {
12
+ const next = this.#buffer.shift();
13
+ if (next) return next;
14
+ return this.#scanNext();
15
+ }
16
+ peek(offset = 0) {
17
+ if (offset > this.#buffer.length) {
18
+ const last = this.#buffer.at(-1);
19
+ if (last?.kind === "Eof") return last;
20
+ }
21
+ const token = this.#buffer[offset];
22
+ if (token) return token;
23
+ while (this.#buffer.length <= offset) {
24
+ const token$1 = this.#scanNext();
25
+ if (token$1.kind === "Eof") return token$1;
26
+ this.#buffer.push(token$1);
27
+ }
28
+ return this.#buffer[offset];
29
+ }
30
+ #scanNext() {
31
+ const token = scan(this.#source, this.#pos);
32
+ this.#pos += token.text.length;
33
+ return token;
34
+ }
35
+ };
36
+ function scan(source, pos) {
37
+ if (pos >= source.length) return {
38
+ kind: "Eof",
39
+ text: ""
40
+ };
41
+ return scanNewline(source, pos) ?? scanWhitespace(source, pos) ?? scanComment(source, pos) ?? scanAt(source, pos) ?? scanIdent(source, pos) ?? scanNumber(source, pos) ?? scanString(source, pos) ?? scanPunctuation(source, pos) ?? {
42
+ kind: "Invalid",
43
+ text: readChar(source, pos)
44
+ };
45
+ }
46
+ function scanNewline(source, pos) {
47
+ const ch = source.charAt(pos);
48
+ if (ch !== "\r" && ch !== "\n") return void 0;
49
+ if (ch === "\r" && source.charAt(pos + 1) === "\n") return {
50
+ kind: "Newline",
51
+ text: "\r\n"
52
+ };
53
+ return {
54
+ kind: "Newline",
55
+ text: ch
56
+ };
57
+ }
58
+ function scanWhitespace(source, pos) {
59
+ const ch = source.charAt(pos);
60
+ if (ch !== " " && ch !== " ") return void 0;
61
+ let end = pos + 1;
62
+ while (end < source.length) {
63
+ const c = source.charAt(end);
64
+ if (c !== " " && c !== " ") break;
65
+ end++;
66
+ }
67
+ return {
68
+ kind: "Whitespace",
69
+ text: source.slice(pos, end)
70
+ };
71
+ }
72
+ function scanComment(source, pos) {
73
+ if (source.charAt(pos) !== "/" || source.charAt(pos + 1) !== "/") return void 0;
74
+ let end = pos + 2;
75
+ while (end < source.length) {
76
+ const c = source.charAt(end);
77
+ if (c === "\n" || c === "\r") break;
78
+ end++;
79
+ }
80
+ return {
81
+ kind: "Comment",
82
+ text: source.slice(pos, end)
83
+ };
84
+ }
85
+ function scanAt(source, pos) {
86
+ if (source.charAt(pos) !== "@") return void 0;
87
+ if (source.charAt(pos + 1) === "@") return {
88
+ kind: "DoubleAt",
89
+ text: "@@"
90
+ };
91
+ return {
92
+ kind: "At",
93
+ text: "@"
94
+ };
95
+ }
96
+ function scanIdent(source, pos) {
97
+ const ch = readChar(source, pos);
98
+ if (!isIdentStart(ch)) return void 0;
99
+ let end = pos + ch.length;
100
+ while (end < source.length) {
101
+ const c = readChar(source, end);
102
+ if (isIdentPart(c)) end += c.length;
103
+ else break;
104
+ }
105
+ return {
106
+ kind: "Ident",
107
+ text: source.slice(pos, end)
108
+ };
109
+ }
110
+ function scanNumber(source, pos) {
111
+ let end = pos;
112
+ if (source.charAt(end) === "-") {
113
+ if (end + 1 >= source.length || !isDigit(source.charAt(end + 1))) return void 0;
114
+ end++;
115
+ } else if (!isDigit(source.charAt(end))) return;
116
+ end++;
117
+ while (end < source.length && isDigit(source.charAt(end))) end++;
118
+ if (source.charAt(end) === "." && end + 1 < source.length && isDigit(source.charAt(end + 1))) {
119
+ end++;
120
+ while (end < source.length && isDigit(source.charAt(end))) end++;
121
+ }
122
+ return {
123
+ kind: "NumberLiteral",
124
+ text: source.slice(pos, end)
125
+ };
126
+ }
127
+ function scanString(source, pos) {
128
+ if (source.charAt(pos) !== "\"") return void 0;
129
+ let end = pos + 1;
130
+ while (end < source.length) {
131
+ const c = source.charAt(end);
132
+ if (c === "\\" && end + 1 < source.length) {
133
+ end += 2;
134
+ continue;
135
+ }
136
+ if (c === "\"") {
137
+ end++;
138
+ return {
139
+ kind: "StringLiteral",
140
+ text: source.slice(pos, end)
141
+ };
142
+ }
143
+ if (c === "\n" || c === "\r") return {
144
+ kind: "StringLiteral",
145
+ text: source.slice(pos, end)
146
+ };
147
+ end++;
148
+ }
149
+ return {
150
+ kind: "StringLiteral",
151
+ text: source.slice(pos, end)
152
+ };
153
+ }
154
+ function scanPunctuation(source, pos) {
155
+ const kind = PUNCTUATION[source.charAt(pos)];
156
+ if (kind === void 0) return void 0;
157
+ return {
158
+ kind,
159
+ text: source.charAt(pos)
160
+ };
161
+ }
162
+ function readChar(source, pos) {
163
+ const cp = source.codePointAt(pos);
164
+ return cp !== void 0 ? String.fromCodePoint(cp) : "";
165
+ }
166
+ function isIdentStart(ch) {
167
+ return /\p{L}/u.test(ch) || ch === "_";
168
+ }
169
+ function isIdentPart(ch) {
170
+ return isIdentStart(ch) || isDigit(ch) || ch === "-";
171
+ }
172
+ function isDigit(ch) {
173
+ return ch >= "0" && ch <= "9";
174
+ }
175
+ const PUNCTUATION = {
176
+ "{": "LBrace",
177
+ "}": "RBrace",
178
+ "(": "LParen",
179
+ ")": "RParen",
180
+ "[": "LBracket",
181
+ "]": "RBracket",
182
+ "=": "Equals",
183
+ "?": "Question",
184
+ ".": "Dot",
185
+ ",": "Comma",
186
+ ":": "Colon"
187
+ };
188
+
189
+ //#endregion
190
+ export { Tokenizer };
191
+ //# sourceMappingURL=tokenizer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenizer.mjs","names":["#source","#buffer","#pos","#scanNext","token","PUNCTUATION: Record<string, TokenKind>"],"sources":["../src/tokenizer.ts"],"sourcesContent":["export type TokenKind =\n | 'Ident'\n | 'StringLiteral'\n | 'NumberLiteral'\n | 'At'\n | 'DoubleAt'\n | 'LBrace'\n | 'RBrace'\n | 'LParen'\n | 'RParen'\n | 'LBracket'\n | 'RBracket'\n | 'Equals'\n | 'Question'\n | 'Dot'\n | 'Comma'\n | 'Colon'\n | 'Whitespace'\n | 'Newline'\n | 'Comment'\n | 'Invalid'\n | 'Eof';\n\nexport interface Token {\n readonly kind: TokenKind;\n readonly text: string;\n}\n\nexport class Tokenizer {\n readonly #source: string;\n #pos: number;\n readonly #buffer: Token[];\n\n constructor(source: string) {\n this.#source = source;\n this.#pos = 0;\n this.#buffer = [];\n }\n\n next(): Token {\n const next = this.#buffer.shift();\n if (next) {\n return next;\n }\n return this.#scanNext();\n }\n\n peek(offset = 0): Token {\n if (offset > this.#buffer.length) {\n const last = this.#buffer.at(-1);\n if (last?.kind === 'Eof') {\n return last;\n }\n }\n\n const token = this.#buffer[offset];\n if (token) {\n return token;\n }\n\n while (this.#buffer.length <= offset) {\n const token = this.#scanNext();\n if (token.kind === 'Eof') {\n return token;\n }\n this.#buffer.push(token);\n }\n\n return this.#buffer[offset] as Token;\n }\n\n #scanNext(): Token {\n const token = scan(this.#source, this.#pos);\n this.#pos += token.text.length;\n return token;\n }\n}\n\nfunction scan(source: string, pos: number): Token {\n if (pos >= source.length) {\n return { kind: 'Eof', text: '' };\n }\n\n return (\n scanNewline(source, pos) ??\n scanWhitespace(source, pos) ??\n scanComment(source, pos) ??\n scanAt(source, pos) ??\n scanIdent(source, pos) ??\n scanNumber(source, pos) ??\n scanString(source, pos) ??\n scanPunctuation(source, pos) ?? {\n kind: 'Invalid' as const,\n text: readChar(source, pos),\n }\n );\n}\n\nfunction scanNewline(source: string, pos: number): Token | undefined {\n const ch = source.charAt(pos);\n if (ch !== '\\r' && ch !== '\\n') return undefined;\n if (ch === '\\r' && source.charAt(pos + 1) === '\\n') {\n return { kind: 'Newline', text: '\\r\\n' };\n }\n return { kind: 'Newline', text: ch };\n}\n\nfunction scanWhitespace(source: string, pos: number): Token | undefined {\n const ch = source.charAt(pos);\n if (ch !== ' ' && ch !== '\\t') return undefined;\n let end = pos + 1;\n while (end < source.length) {\n const c = source.charAt(end);\n if (c !== ' ' && c !== '\\t') break;\n end++;\n }\n return { kind: 'Whitespace', text: source.slice(pos, end) };\n}\n\nfunction scanComment(source: string, pos: number): Token | undefined {\n if (source.charAt(pos) !== '/' || source.charAt(pos + 1) !== '/') return undefined;\n let end = pos + 2;\n while (end < source.length) {\n const c = source.charAt(end);\n if (c === '\\n' || c === '\\r') break;\n end++;\n }\n return { kind: 'Comment', text: source.slice(pos, end) };\n}\n\nfunction scanAt(source: string, pos: number): Token | undefined {\n if (source.charAt(pos) !== '@') return undefined;\n if (source.charAt(pos + 1) === '@') {\n return { kind: 'DoubleAt', text: '@@' };\n }\n return { kind: 'At', text: '@' };\n}\n\nfunction scanIdent(source: string, pos: number): Token | undefined {\n const ch = readChar(source, pos);\n if (!isIdentStart(ch)) return undefined;\n let end = pos + ch.length;\n while (end < source.length) {\n const c = readChar(source, end);\n if (isIdentPart(c)) {\n end += c.length;\n } else {\n break;\n }\n }\n return { kind: 'Ident', text: source.slice(pos, end) };\n}\n\nfunction scanNumber(source: string, pos: number): Token | undefined {\n let end = pos;\n if (source.charAt(end) === '-') {\n if (end + 1 >= source.length || !isDigit(source.charAt(end + 1))) return undefined;\n end++;\n } else if (!isDigit(source.charAt(end))) {\n return undefined;\n }\n end++;\n while (end < source.length && isDigit(source.charAt(end))) {\n end++;\n }\n if (source.charAt(end) === '.' && end + 1 < source.length && isDigit(source.charAt(end + 1))) {\n end++; // consume the dot\n while (end < source.length && isDigit(source.charAt(end))) {\n end++;\n }\n }\n return { kind: 'NumberLiteral', text: source.slice(pos, end) };\n}\n\nfunction scanString(source: string, pos: number): Token | undefined {\n if (source.charAt(pos) !== '\"') return undefined;\n let end = pos + 1;\n while (end < source.length) {\n const c = source.charAt(end);\n if (c === '\\\\' && end + 1 < source.length) {\n end += 2; // skip escape sequence\n continue;\n }\n if (c === '\"') {\n end++; // include closing quote\n return { kind: 'StringLiteral', text: source.slice(pos, end) };\n }\n if (c === '\\n' || c === '\\r') {\n // Unterminated: stop before newline\n return { kind: 'StringLiteral', text: source.slice(pos, end) };\n }\n end++;\n }\n // Unterminated at EOF\n return { kind: 'StringLiteral', text: source.slice(pos, end) };\n}\n\nfunction scanPunctuation(source: string, pos: number): Token | undefined {\n const kind = PUNCTUATION[source.charAt(pos)];\n if (kind === undefined) return undefined;\n return { kind, text: source.charAt(pos) };\n}\n\nfunction readChar(source: string, pos: number): string {\n const cp = source.codePointAt(pos);\n return cp !== undefined ? String.fromCodePoint(cp) : '';\n}\n\nfunction isIdentStart(ch: string): boolean {\n return /\\p{L}/u.test(ch) || ch === '_';\n}\n\nfunction isIdentPart(ch: string): boolean {\n return isIdentStart(ch) || isDigit(ch) || ch === '-';\n}\n\nfunction isDigit(ch: string): boolean {\n return ch >= '0' && ch <= '9';\n}\n\nconst PUNCTUATION: Record<string, TokenKind> = {\n '{': 'LBrace',\n '}': 'RBrace',\n '(': 'LParen',\n ')': 'RParen',\n '[': 'LBracket',\n ']': 'RBracket',\n '=': 'Equals',\n '?': 'Question',\n '.': 'Dot',\n ',': 'Comma',\n ':': 'Colon',\n};\n"],"mappings":";AA4BA,IAAa,YAAb,MAAuB;CACrB,CAASA;CACT;CACA,CAASC;CAET,YAAY,QAAgB;AAC1B,QAAKD,SAAU;AACf,QAAKE,MAAO;AACZ,QAAKD,SAAU,EAAE;;CAGnB,OAAc;EACZ,MAAM,OAAO,MAAKA,OAAQ,OAAO;AACjC,MAAI,KACF,QAAO;AAET,SAAO,MAAKE,UAAW;;CAGzB,KAAK,SAAS,GAAU;AACtB,MAAI,SAAS,MAAKF,OAAQ,QAAQ;GAChC,MAAM,OAAO,MAAKA,OAAQ,GAAG,GAAG;AAChC,OAAI,MAAM,SAAS,MACjB,QAAO;;EAIX,MAAM,QAAQ,MAAKA,OAAQ;AAC3B,MAAI,MACF,QAAO;AAGT,SAAO,MAAKA,OAAQ,UAAU,QAAQ;GACpC,MAAMG,UAAQ,MAAKD,UAAW;AAC9B,OAAIC,QAAM,SAAS,MACjB,QAAOA;AAET,SAAKH,OAAQ,KAAKG,QAAM;;AAG1B,SAAO,MAAKH,OAAQ;;CAGtB,YAAmB;EACjB,MAAM,QAAQ,KAAK,MAAKD,QAAS,MAAKE,IAAK;AAC3C,QAAKA,OAAQ,MAAM,KAAK;AACxB,SAAO;;;AAIX,SAAS,KAAK,QAAgB,KAAoB;AAChD,KAAI,OAAO,OAAO,OAChB,QAAO;EAAE,MAAM;EAAO,MAAM;EAAI;AAGlC,QACE,YAAY,QAAQ,IAAI,IACxB,eAAe,QAAQ,IAAI,IAC3B,YAAY,QAAQ,IAAI,IACxB,OAAO,QAAQ,IAAI,IACnB,UAAU,QAAQ,IAAI,IACtB,WAAW,QAAQ,IAAI,IACvB,WAAW,Q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AAM,QAAQ,MAAM,KAEtB,QAAO;GAAE,MAAM;GAAiB,MAAM,OAAO,MAAM,KAAK,IAAI;GAAE;AAEhE;;AAGF,QAAO;EAAE,MAAM;EAAiB,MAAM,OAAO,MAAM,KAAK,IAAI;EAAE;;AAGhE,SAAS,gBAAgB,QAAgB,KAAgC;CACvE,MAAM,OAAO,YAAY,OAAO,OAAO,IAAI;AAC3C,KAAI,SAAS,OAAW,QAAO;AAC/B,QAAO;EAAE;EAAM,MAAM,OAAO,OAAO,IAAI;EAAE;;AAG3C,SAAS,SAAS,QAAgB,KAAqB;CACrD,MAAM,KAAK,OAAO,YAAY,IAAI;AAClC,QAAO,OAAO,SAAY,OAAO,cAAc,GAAG,GAAG;;AAGvD,SAAS,aAAa,IAAqB;AACzC,QAAO,SAAS,KAAK,GAAG,IAAI,OAAO;;AAGrC,SAAS,YAAY,IAAqB;AACxC,QAAO,aAAa,GAAG,IAAI,QAAQ,GAAG,IAAI,OAAO;;AAGnD,SAAS,QAAQ,IAAqB;AACpC,QAAO,MAAM,OAAO,MAAM;;AAG5B,MAAMG,cAAyC;CAC7C,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN"}
@@ -116,4 +116,4 @@ interface ParsePslDocumentResult {
116
116
  }
117
117
  //#endregion
118
118
  export { PslReferentialAction as C, PslUniqueConstraint as E, PslPosition as S, PslTypesBlock as T, PslFieldAttribute as _, PslAttributeNamedArgument as a, PslModelAttribute as b, PslDefaultFunctionValue as c, PslDiagnostic as d, PslDiagnosticCode as f, PslField as g, PslEnumValue as h, PslAttributeArgument as i, PslDefaultLiteralValue as l, PslEnum as m, ParsePslDocumentResult as n, PslAttributePositionalArgument as o, PslDocumentAst as p, PslAttribute as r, PslAttributeTarget as s, ParsePslDocumentInput as t, PslDefaultValue as u, PslIndexConstraint as v, PslSpan as w, PslNamedTypeDeclaration as x, PslModel as y };
119
- //# sourceMappingURL=types-QqDFOzNR.d.mts.map
119
+ //# sourceMappingURL=types-CyfspkvF.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-QqDFOzNR.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";UAAiB,WAAA;EAAA,SAAA,MAAW,EAAA,MAAA;EAMX,SAAA,IAAO,EAAA,MACN;EAIN,SAAA,MAAA,EAAA,MAAiB;AAa7B;AAOiB,UAzBA,OAAA,CAyBA;EAKA,SAAA,KAAA,EA7BC,WA6BqB;EAK3B,SAAA,GAAA,EAjCI,WAiCW;AAE3B;AAEiB,KAlCL,iBAAA,GAkCK,wBAGO,GAAA,iCAAA,GAAA,8BAAA,GAAA,0BAAA,GAAA,iCAAA,GAAA,iCAAA,GAAA,gCAAA,GAAA,gCAAA,GAAA,2BAAA,GAAA,yBAAA,GAAA,0BAAA;AAGP,UA3BA,aAAA,CA2BA;EAOL,SAAA,IAAA,EAjCK,iBAiCe;EAEf,SAAA,OAAY,EAAA,MAAA;EAEV,SAAA,QAAA,EAAA,MAAA;EAEO,SAAA,IAAA,EApCT,OAoCS;;AACF,UAlCP,uBAAA,CAkCO;EAGZ,SAAA,IAAA,EAAA,UAAoB;EAEpB,SAAA,IAAA,EAAA,eAAiB,GAAG,KAAA;AAEhC;AAWiB,UA/CA,sBAAA,CAkDA;EAGA,SAAA,IAAA,EAAA,SAAkB;EAMvB,SAAA,KAAA,EAAA,MAAiB,GAAA,MAAA,GAAG,OAAA;AAEhC;AAG4B,KA3DhB,eAAA,GAAkB,uBA2DF,GA3D4B,sBA2D5B;AACI,KA1DpB,kBAAA,GA0DoB,OAAA,GAAA,OAAA,GAAA,WAAA;AACf,UAzDA,8BAAA,CAyDA;EAAO,SAAA,IAAA,EAAA,YAAA;EAGP,SAAA,KAAA,EAAY,MAAA;EAMZ,SAAA,IAAO,EA/DP,OAkEW;AAI5B;AAQiB,UA3EA,yBAAA,CA6EiB;EAIjB,SAAA,IA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as PslFieldAttribute, a as PslAttributeNamedArgument, b as PslModelAttribute, c as PslDefaultFunctionValue, d as PslDiagnostic, f as PslDiagnosticCode, g as PslField, h as PslEnumValue, i as PslAttributeArgument, l as PslDefaultLiteralValue, m as PslEnum, n as ParsePslDocumentResult, o as PslAttributePositionalArgument, p as PslDocumentAst, r as PslAttribute, s as PslAttributeTarget, t as ParsePslDocumentInput, u as PslDefaultValue, v as PslIndexConstraint, w as PslSpan, x as PslNamedTypeDeclaration, y as PslModel } from "./types-QqDFOzNR.mjs";
1
+ import { C as PslReferentialAction, E as PslUniqueConstraint, S as PslPosition, T as PslTypesBlock, _ as PslFieldAttribute, a as PslAttributeNamedArgument, b as PslModelAttribute, c as PslDefaultFunctionValue, d as PslDiagnostic, f as PslDiagnosticCode, g as PslField, h as PslEnumValue, i as PslAttributeArgument, l as PslDefaultLiteralValue, m as PslEnum, n as ParsePslDocumentResult, o as PslAttributePositionalArgument, p as PslDocumentAst, r as PslAttribute, s as PslAttributeTarget, t as ParsePslDocumentInput, u as PslDefaultValue, v as PslIndexConstraint, w as PslSpan, x as PslNamedTypeDeclaration, y as PslModel } from "./types-CyfspkvF.mjs";
2
2
  export { type ParsePslDocumentInput, type ParsePslDocumentResult, type PslAttribute, type PslAttributeArgument, type PslAttributeNamedArgument, type PslAttributePositionalArgument, type PslAttributeTarget, type PslDefaultFunctionValue, type PslDefaultLiteralValue, type PslDefaultValue, type PslDiagnostic, type PslDiagnosticCode, type PslDocumentAst, type PslEnum, type PslEnumValue, type PslField, type PslFieldAttribute, type PslIndexConstraint, type PslModel, type PslModelAttribute, type PslNamedTypeDeclaration, type PslPosition, type PslReferentialAction, type PslSpan, type PslTypesBlock, type PslUniqueConstraint };
package/package.json CHANGED
@@ -1,28 +1,18 @@
1
1
  {
2
2
  "name": "@prisma-next/psl-parser",
3
- "version": "0.0.1",
3
+ "version": "0.3.0-dev.101",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "Reusable parser for Prisma Schema Language (PSL)",
7
- "scripts": {
8
- "build": "tsdown",
9
- "test": "vitest run",
10
- "test:coverage": "vitest run --coverage",
11
- "typecheck": "tsc --project tsconfig.json --noEmit",
12
- "lint": "biome check . --error-on-warnings",
13
- "lint:fix": "biome check --write .",
14
- "lint:fix:unsafe": "biome check --write --unsafe .",
15
- "clean": "rm -rf dist dist-tsc dist-tsc-prod coverage .tmp-output"
16
- },
17
7
  "dependencies": {
18
- "@prisma-next/utils": "workspace:*"
8
+ "@prisma-next/utils": "0.3.0-dev.101"
19
9
  },
20
10
  "devDependencies": {
21
- "@prisma-next/tsconfig": "workspace:*",
22
- "@prisma-next/tsdown": "workspace:*",
23
- "tsdown": "catalog:",
24
- "typescript": "catalog:",
25
- "vitest": "catalog:"
11
+ "tsdown": "0.18.4",
12
+ "typescript": "5.9.3",
13
+ "vitest": "4.0.17",
14
+ "@prisma-next/tsconfig": "0.0.0",
15
+ "@prisma-next/tsdown": "0.0.0"
26
16
  },
27
17
  "files": [
28
18
  "dist",
@@ -31,6 +21,7 @@
31
21
  "exports": {
32
22
  ".": "./dist/index.mjs",
33
23
  "./parser": "./dist/parser.mjs",
24
+ "./tokenizer": "./dist/tokenizer.mjs",
34
25
  "./types": "./dist/types.mjs",
35
26
  "./package.json": "./package.json"
36
27
  },
@@ -41,5 +32,15 @@
41
32
  "type": "git",
42
33
  "url": "https://github.com/prisma/prisma-next.git",
43
34
  "directory": "packages/1-framework/2-authoring/psl-parser"
35
+ },
36
+ "scripts": {
37
+ "build": "tsdown",
38
+ "test": "vitest run",
39
+ "test:coverage": "vitest run --coverage",
40
+ "typecheck": "tsc --project tsconfig.json --noEmit",
41
+ "lint": "biome check . --error-on-warnings",
42
+ "lint:fix": "biome check --write .",
43
+ "lint:fix:unsafe": "biome check --write --unsafe .",
44
+ "clean": "rm -rf dist dist-tsc dist-tsc-prod coverage .tmp-output"
44
45
  }
45
- }
46
+ }
@@ -0,0 +1,2 @@
1
+ export type { Token, TokenKind } from '../tokenizer';
2
+ export { Tokenizer } from '../tokenizer';
@@ -0,0 +1,233 @@
1
+ export type TokenKind =
2
+ | 'Ident'
3
+ | 'StringLiteral'
4
+ | 'NumberLiteral'
5
+ | 'At'
6
+ | 'DoubleAt'
7
+ | 'LBrace'
8
+ | 'RBrace'
9
+ | 'LParen'
10
+ | 'RParen'
11
+ | 'LBracket'
12
+ | 'RBracket'
13
+ | 'Equals'
14
+ | 'Question'
15
+ | 'Dot'
16
+ | 'Comma'
17
+ | 'Colon'
18
+ | 'Whitespace'
19
+ | 'Newline'
20
+ | 'Comment'
21
+ | 'Invalid'
22
+ | 'Eof';
23
+
24
+ export interface Token {
25
+ readonly kind: TokenKind;
26
+ readonly text: string;
27
+ }
28
+
29
+ export class Tokenizer {
30
+ readonly #source: string;
31
+ #pos: number;
32
+ readonly #buffer: Token[];
33
+
34
+ constructor(source: string) {
35
+ this.#source = source;
36
+ this.#pos = 0;
37
+ this.#buffer = [];
38
+ }
39
+
40
+ next(): Token {
41
+ const next = this.#buffer.shift();
42
+ if (next) {
43
+ return next;
44
+ }
45
+ return this.#scanNext();
46
+ }
47
+
48
+ peek(offset = 0): Token {
49
+ if (offset > this.#buffer.length) {
50
+ const last = this.#buffer.at(-1);
51
+ if (last?.kind === 'Eof') {
52
+ return last;
53
+ }
54
+ }
55
+
56
+ const token = this.#buffer[offset];
57
+ if (token) {
58
+ return token;
59
+ }
60
+
61
+ while (this.#buffer.length <= offset) {
62
+ const token = this.#scanNext();
63
+ if (token.kind === 'Eof') {
64
+ return token;
65
+ }
66
+ this.#buffer.push(token);
67
+ }
68
+
69
+ return this.#buffer[offset] as Token;
70
+ }
71
+
72
+ #scanNext(): Token {
73
+ const token = scan(this.#source, this.#pos);
74
+ this.#pos += token.text.length;
75
+ return token;
76
+ }
77
+ }
78
+
79
+ function scan(source: string, pos: number): Token {
80
+ if (pos >= source.length) {
81
+ return { kind: 'Eof', text: '' };
82
+ }
83
+
84
+ return (
85
+ scanNewline(source, pos) ??
86
+ scanWhitespace(source, pos) ??
87
+ scanComment(source, pos) ??
88
+ scanAt(source, pos) ??
89
+ scanIdent(source, pos) ??
90
+ scanNumber(source, pos) ??
91
+ scanString(source, pos) ??
92
+ scanPunctuation(source, pos) ?? {
93
+ kind: 'Invalid' as const,
94
+ text: readChar(source, pos),
95
+ }
96
+ );
97
+ }
98
+
99
+ function scanNewline(source: string, pos: number): Token | undefined {
100
+ const ch = source.charAt(pos);
101
+ if (ch !== '\r' && ch !== '\n') return undefined;
102
+ if (ch === '\r' && source.charAt(pos + 1) === '\n') {
103
+ return { kind: 'Newline', text: '\r\n' };
104
+ }
105
+ return { kind: 'Newline', text: ch };
106
+ }
107
+
108
+ function scanWhitespace(source: string, pos: number): Token | undefined {
109
+ const ch = source.charAt(pos);
110
+ if (ch !== ' ' && ch !== '\t') return undefined;
111
+ let end = pos + 1;
112
+ while (end < source.length) {
113
+ const c = source.charAt(end);
114
+ if (c !== ' ' && c !== '\t') break;
115
+ end++;
116
+ }
117
+ return { kind: 'Whitespace', text: source.slice(pos, end) };
118
+ }
119
+
120
+ function scanComment(source: string, pos: number): Token | undefined {
121
+ if (source.charAt(pos) !== '/' || source.charAt(pos + 1) !== '/') return undefined;
122
+ let end = pos + 2;
123
+ while (end < source.length) {
124
+ const c = source.charAt(end);
125
+ if (c === '\n' || c === '\r') break;
126
+ end++;
127
+ }
128
+ return { kind: 'Comment', text: source.slice(pos, end) };
129
+ }
130
+
131
+ function scanAt(source: string, pos: number): Token | undefined {
132
+ if (source.charAt(pos) !== '@') return undefined;
133
+ if (source.charAt(pos + 1) === '@') {
134
+ return { kind: 'DoubleAt', text: '@@' };
135
+ }
136
+ return { kind: 'At', text: '@' };
137
+ }
138
+
139
+ function scanIdent(source: string, pos: number): Token | undefined {
140
+ const ch = readChar(source, pos);
141
+ if (!isIdentStart(ch)) return undefined;
142
+ let end = pos + ch.length;
143
+ while (end < source.length) {
144
+ const c = readChar(source, end);
145
+ if (isIdentPart(c)) {
146
+ end += c.length;
147
+ } else {
148
+ break;
149
+ }
150
+ }
151
+ return { kind: 'Ident', text: source.slice(pos, end) };
152
+ }
153
+
154
+ function scanNumber(source: string, pos: number): Token | undefined {
155
+ let end = pos;
156
+ if (source.charAt(end) === '-') {
157
+ if (end + 1 >= source.length || !isDigit(source.charAt(end + 1))) return undefined;
158
+ end++;
159
+ } else if (!isDigit(source.charAt(end))) {
160
+ return undefined;
161
+ }
162
+ end++;
163
+ while (end < source.length && isDigit(source.charAt(end))) {
164
+ end++;
165
+ }
166
+ if (source.charAt(end) === '.' && end + 1 < source.length && isDigit(source.charAt(end + 1))) {
167
+ end++; // consume the dot
168
+ while (end < source.length && isDigit(source.charAt(end))) {
169
+ end++;
170
+ }
171
+ }
172
+ return { kind: 'NumberLiteral', text: source.slice(pos, end) };
173
+ }
174
+
175
+ function scanString(source: string, pos: number): Token | undefined {
176
+ if (source.charAt(pos) !== '"') return undefined;
177
+ let end = pos + 1;
178
+ while (end < source.length) {
179
+ const c = source.charAt(end);
180
+ if (c === '\\' && end + 1 < source.length) {
181
+ end += 2; // skip escape sequence
182
+ continue;
183
+ }
184
+ if (c === '"') {
185
+ end++; // include closing quote
186
+ return { kind: 'StringLiteral', text: source.slice(pos, end) };
187
+ }
188
+ if (c === '\n' || c === '\r') {
189
+ // Unterminated: stop before newline
190
+ return { kind: 'StringLiteral', text: source.slice(pos, end) };
191
+ }
192
+ end++;
193
+ }
194
+ // Unterminated at EOF
195
+ return { kind: 'StringLiteral', text: source.slice(pos, end) };
196
+ }
197
+
198
+ function scanPunctuation(source: string, pos: number): Token | undefined {
199
+ const kind = PUNCTUATION[source.charAt(pos)];
200
+ if (kind === undefined) return undefined;
201
+ return { kind, text: source.charAt(pos) };
202
+ }
203
+
204
+ function readChar(source: string, pos: number): string {
205
+ const cp = source.codePointAt(pos);
206
+ return cp !== undefined ? String.fromCodePoint(cp) : '';
207
+ }
208
+
209
+ function isIdentStart(ch: string): boolean {
210
+ return /\p{L}/u.test(ch) || ch === '_';
211
+ }
212
+
213
+ function isIdentPart(ch: string): boolean {
214
+ return isIdentStart(ch) || isDigit(ch) || ch === '-';
215
+ }
216
+
217
+ function isDigit(ch: string): boolean {
218
+ return ch >= '0' && ch <= '9';
219
+ }
220
+
221
+ const PUNCTUATION: Record<string, TokenKind> = {
222
+ '{': 'LBrace',
223
+ '}': 'RBrace',
224
+ '(': 'LParen',
225
+ ')': 'RParen',
226
+ '[': 'LBracket',
227
+ ']': 'RBracket',
228
+ '=': 'Equals',
229
+ '?': 'Question',
230
+ '.': 'Dot',
231
+ ',': 'Comma',
232
+ ':': 'Colon',
233
+ };
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser-CUqO9VeG.d.mts","names":[],"sources":["../src/parser.ts"],"sourcesContent":[],"mappings":";;;iBAgDgB,gBAAA,QAAwB,wBAAwB"}