@prisma-next/psl-parser 0.3.0-dev.148 → 0.3.0-dev.149

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/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@prisma-next/psl-parser",
3
- "version": "0.3.0-dev.148",
3
+ "version": "0.3.0-dev.149",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "Reusable parser for Prisma Schema Language (PSL)",
7
7
  "dependencies": {
8
- "@prisma-next/utils": "0.3.0-dev.148"
8
+ "@prisma-next/utils": "0.3.0-dev.149"
9
9
  },
10
10
  "devDependencies": {
11
11
  "tsdown": "0.18.4",
12
12
  "typescript": "5.9.3",
13
13
  "vitest": "4.0.17",
14
- "@prisma-next/tsdown": "0.0.0",
15
- "@prisma-next/tsconfig": "0.0.0"
14
+ "@prisma-next/tsconfig": "0.0.0",
15
+ "@prisma-next/tsdown": "0.0.0"
16
16
  },
17
17
  "files": [
18
18
  "dist",
@@ -24,5 +24,6 @@ export type {
24
24
  PslNamedTypeDeclaration,
25
25
  PslPosition,
26
26
  PslSpan,
27
+ PslTypeConstructorCall,
27
28
  PslTypesBlock,
28
29
  } from '../types';
package/src/parser.ts CHANGED
@@ -18,6 +18,7 @@ import type {
18
18
  PslNamedTypeDeclaration,
19
19
  PslPosition,
20
20
  PslSpan,
21
+ PslTypeConstructorCall,
21
22
  PslTypesBlock,
22
23
  } from './types';
23
24
 
@@ -348,7 +349,7 @@ function parseTypesBlock(context: ParserContext, bounds: BlockBounds): PslTypesB
348
349
  continue;
349
350
  }
350
351
 
351
- const declarationMatch = line.match(/^([A-Za-z_]\w*)\s*=\s*([A-Za-z_]\w*)(.*)$/);
352
+ const declarationMatch = line.match(/^([A-Za-z_]\w*)\s*=\s*(.+)$/);
352
353
  if (!declarationMatch) {
353
354
  pushDiagnostic(context, {
354
355
  code: 'PSL_INVALID_TYPES_MEMBER',
@@ -359,17 +360,33 @@ function parseTypesBlock(context: ParserContext, bounds: BlockBounds): PslTypesB
359
360
  }
360
361
 
361
362
  const declarationName = declarationMatch[1] ?? '';
362
- const baseType = declarationMatch[2] ?? '';
363
- const attributePart = declarationMatch[3] ?? '';
364
363
  const trimmedStartColumn = firstNonWhitespaceColumn(raw);
365
- const attributeOffset = line.length - attributePart.length;
366
- const attributeSource = attributePart.trimStart();
367
- const leadingAttributeWhitespace = attributePart.length - attributeSource.length;
364
+ const declarationValue = (declarationMatch[2] ?? '').trim();
365
+ const valueOffset = line.indexOf(declarationValue);
366
+ const declarationValueColumn = trimmedStartColumn + Math.max(valueOffset, 0);
367
+
368
+ const typeAndAttributeSplit = splitTypeAndAttributes(declarationValue);
369
+ const typeSource = typeAndAttributeSplit.typeSource.trim();
370
+ const attributeSource = typeAndAttributeSplit.attributeSource.trimStart();
371
+ const leadingAttributeWhitespace =
372
+ typeAndAttributeSplit.attributeSource.length - attributeSource.length;
373
+
374
+ const typeConstructor = parseTypeConstructorCall(context, {
375
+ declarationValue: typeSource,
376
+ lineIndex,
377
+ startColumn: declarationValueColumn,
378
+ invalidCode: 'PSL_INVALID_TYPES_MEMBER',
379
+ invalidMessage: (value) => `Invalid types declaration "${value}"`,
380
+ });
381
+ if (typeConstructor === 'malformed') {
382
+ continue;
383
+ }
384
+
368
385
  const attributeParse = extractAttributeTokensWithSpans(
369
386
  context,
370
387
  lineIndex,
371
388
  attributeSource,
372
- trimmedStartColumn + attributeOffset + leadingAttributeWhitespace,
389
+ declarationValueColumn + typeAndAttributeSplit.attributeOffset + leadingAttributeWhitespace,
373
390
  );
374
391
  if (!attributeParse.ok) {
375
392
  continue;
@@ -385,6 +402,29 @@ function parseTypesBlock(context: ParserContext, bounds: BlockBounds): PslTypesB
385
402
  )
386
403
  .filter((attribute): attribute is PslAttribute => Boolean(attribute));
387
404
 
405
+ if (typeConstructor) {
406
+ declarations.push({
407
+ kind: 'namedType',
408
+ name: declarationName,
409
+ typeConstructor,
410
+ attributes,
411
+ span: createTrimmedLineSpan(context, lineIndex),
412
+ });
413
+ continue;
414
+ }
415
+
416
+ const baseTypeMatch = typeSource.match(/^([A-Za-z_]\w*)$/);
417
+ if (!baseTypeMatch) {
418
+ pushDiagnostic(context, {
419
+ code: 'PSL_INVALID_TYPES_MEMBER',
420
+ message: `Invalid types declaration "${line}"`,
421
+ span: createTrimmedLineSpan(context, lineIndex),
422
+ });
423
+ continue;
424
+ }
425
+
426
+ const baseType = baseTypeMatch[1] ?? '';
427
+
388
428
  declarations.push({
389
429
  kind: 'namedType',
390
430
  name: declarationName,
@@ -401,6 +441,78 @@ function parseTypesBlock(context: ParserContext, bounds: BlockBounds): PslTypesB
401
441
  };
402
442
  }
403
443
 
444
+ function parseTypeConstructorCall(
445
+ context: ParserContext,
446
+ input: {
447
+ readonly declarationValue: string;
448
+ readonly lineIndex: number;
449
+ readonly startColumn: number;
450
+ readonly invalidCode: PslDiagnosticCode;
451
+ readonly invalidMessage: (value: string) => string;
452
+ },
453
+ ): PslTypeConstructorCall | 'malformed' | undefined {
454
+ const value = input.declarationValue.trim();
455
+ const constructorMatch = value.match(
456
+ /^([A-Za-z_][A-Za-z0-9_-]*(?:\.[A-Za-z_][A-Za-z0-9_-]*)*)\s*\(/,
457
+ );
458
+ if (!constructorMatch) {
459
+ return undefined;
460
+ }
461
+
462
+ // constructorMatch already required `(`; openParen is guaranteed ≥ 0.
463
+ const openParen = value.indexOf('(');
464
+ const closeParen = value.lastIndexOf(')');
465
+
466
+ if (closeParen !== value.length - 1) {
467
+ pushDiagnostic(context, {
468
+ code: input.invalidCode,
469
+ message: input.invalidMessage(value),
470
+ span: createInlineSpan(
471
+ context,
472
+ input.lineIndex,
473
+ input.startColumn,
474
+ input.startColumn + value.length,
475
+ ),
476
+ });
477
+ return 'malformed';
478
+ }
479
+
480
+ const constructorPath = constructorMatch[1] ?? '';
481
+
482
+ const argsRaw = value.slice(openParen + 1, closeParen);
483
+ const args = parseArgumentList(context, {
484
+ argsRaw,
485
+ argsOffset: input.startColumn + openParen + 1,
486
+ lineIndex: input.lineIndex,
487
+ token: value,
488
+ span: createInlineSpan(
489
+ context,
490
+ input.lineIndex,
491
+ input.startColumn,
492
+ input.startColumn + value.length,
493
+ ),
494
+ invalidCode: input.invalidCode,
495
+ invalidEmptyArgumentMessage: `Invalid empty argument in type constructor "${value}"`,
496
+ invalidNamedArgumentMessage: (part) =>
497
+ `Invalid named argument syntax "${part}" in type constructor "${value}"`,
498
+ });
499
+ if (!args) {
500
+ return 'malformed';
501
+ }
502
+
503
+ return {
504
+ kind: 'typeConstructor',
505
+ path: constructorPath.split('.'),
506
+ args,
507
+ span: createInlineSpan(
508
+ context,
509
+ input.lineIndex,
510
+ input.startColumn,
511
+ input.startColumn + value.length,
512
+ ),
513
+ };
514
+ }
515
+
404
516
  function parseModelAttribute(
405
517
  context: ParserContext,
406
518
  line: string,
@@ -478,7 +590,7 @@ function parseEnumAttribute(
478
590
  }
479
591
 
480
592
  function parseField(context: ParserContext, line: string, lineIndex: number): PslField | undefined {
481
- const fieldMatch = line.match(/^([A-Za-z_]\w*)\s+([A-Za-z_]\w*(?:\[\])?)(\?)?(.*)$/);
593
+ const fieldMatch = line.match(/^([A-Za-z_]\w*)(\s+)(.+)$/);
482
594
  if (!fieldMatch) {
483
595
  pushDiagnostic(context, {
484
596
  code: 'PSL_INVALID_MODEL_MEMBER',
@@ -489,30 +601,62 @@ function parseField(context: ParserContext, line: string, lineIndex: number): Ps
489
601
  }
490
602
 
491
603
  const fieldName = fieldMatch[1] ?? '';
492
- const rawTypeToken = fieldMatch[2] ?? '';
493
- const optionalMarker = fieldMatch[3] ?? '';
494
- const attributePart = fieldMatch[4] ?? '';
495
- const list = rawTypeToken.endsWith('[]');
496
- const typeName = list ? rawTypeToken.slice(0, -2) : rawTypeToken;
497
- const optional = optionalMarker === '?';
498
-
499
- const attributes: PslFieldAttribute[] = [];
604
+ const separator = fieldMatch[2] ?? '';
605
+ const remainder = fieldMatch[3] ?? '';
606
+ const typeAndAttributeSplit = splitTypeAndAttributes(remainder);
607
+ const rawTypeSource = typeAndAttributeSplit.typeSource.trim();
608
+ const attributePart = typeAndAttributeSplit.attributeSource;
609
+ const optional = rawTypeSource.endsWith('?');
610
+ const typeSourceWithoutOptional = optional ? rawTypeSource.slice(0, -1).trimEnd() : rawTypeSource;
611
+ const list = typeSourceWithoutOptional.endsWith('[]');
612
+ const baseTypeSource = list
613
+ ? typeSourceWithoutOptional.slice(0, -2).trimEnd()
614
+ : typeSourceWithoutOptional;
500
615
  const rawLine = context.lines[lineIndex] ?? '';
501
616
  const trimmedStartColumn = firstNonWhitespaceColumn(rawLine);
502
- const attributeOffset = line.length - attributePart.length;
617
+ const typeStartColumn = trimmedStartColumn + fieldName.length + separator.length;
618
+
619
+ const typeConstructor = parseTypeConstructorCall(context, {
620
+ declarationValue: baseTypeSource,
621
+ lineIndex,
622
+ startColumn: typeStartColumn,
623
+ invalidCode: 'PSL_INVALID_MODEL_MEMBER',
624
+ invalidMessage: (value) => `Invalid field type constructor "${value}"`,
625
+ });
626
+ if (typeConstructor === 'malformed') {
627
+ return undefined;
628
+ }
629
+
630
+ const simpleTypeMatch = baseTypeSource.match(/^([A-Za-z_]\w*)$/);
631
+ const typeName = typeConstructor?.path.join('.') ?? simpleTypeMatch?.[1];
632
+ if (!typeName) {
633
+ pushDiagnostic(context, {
634
+ code: 'PSL_INVALID_MODEL_MEMBER',
635
+ message: `Invalid model member declaration "${line}"`,
636
+ span: createTrimmedLineSpan(context, lineIndex),
637
+ });
638
+ return undefined;
639
+ }
640
+
641
+ const attributes: PslFieldAttribute[] = [];
503
642
  const attributeSource = attributePart.trimStart();
504
643
  const leadingAttributeWhitespace = attributePart.length - attributeSource.length;
505
644
  const tokenParse = extractAttributeTokensWithSpans(
506
645
  context,
507
646
  lineIndex,
508
647
  attributeSource,
509
- trimmedStartColumn + attributeOffset + leadingAttributeWhitespace,
648
+ trimmedStartColumn +
649
+ fieldName.length +
650
+ separator.length +
651
+ typeAndAttributeSplit.attributeOffset +
652
+ leadingAttributeWhitespace,
510
653
  );
511
654
  if (!tokenParse.ok) {
512
655
  return {
513
656
  kind: 'field',
514
657
  name: fieldName,
515
658
  typeName,
659
+ ...ifDefined('typeConstructor', typeConstructor),
516
660
  optional,
517
661
  list,
518
662
  attributes,
@@ -536,6 +680,7 @@ function parseField(context: ParserContext, line: string, lineIndex: number): Ps
536
680
  kind: 'field',
537
681
  name: fieldName,
538
682
  typeName,
683
+ ...ifDefined('typeConstructor', typeConstructor),
539
684
  optional,
540
685
  list,
541
686
  attributes,
@@ -543,6 +688,80 @@ function parseField(context: ParserContext, line: string, lineIndex: number): Ps
543
688
  };
544
689
  }
545
690
 
691
+ function isQuoteEscaped(value: string, quoteIndex: number): boolean {
692
+ let backslashCount = 0;
693
+
694
+ for (let index = quoteIndex - 1; index >= 0 && value[index] === '\\'; index -= 1) {
695
+ backslashCount += 1;
696
+ }
697
+
698
+ return backslashCount % 2 === 1;
699
+ }
700
+
701
+ function splitTypeAndAttributes(value: string): {
702
+ readonly typeSource: string;
703
+ readonly attributeSource: string;
704
+ readonly attributeOffset: number;
705
+ } {
706
+ let depthParen = 0;
707
+ let depthBracket = 0;
708
+ let depthBrace = 0;
709
+ let quote: '"' | "'" | null = null;
710
+
711
+ for (let index = 0; index < value.length; index += 1) {
712
+ const character = value[index] ?? '';
713
+ if (quote) {
714
+ if (character === quote && !isQuoteEscaped(value, index)) {
715
+ quote = null;
716
+ }
717
+ continue;
718
+ }
719
+
720
+ if (character === '"' || character === "'") {
721
+ quote = character;
722
+ continue;
723
+ }
724
+ if (character === '(') {
725
+ depthParen += 1;
726
+ continue;
727
+ }
728
+ if (character === ')') {
729
+ depthParen = Math.max(0, depthParen - 1);
730
+ continue;
731
+ }
732
+ if (character === '[') {
733
+ depthBracket += 1;
734
+ continue;
735
+ }
736
+ if (character === ']') {
737
+ depthBracket = Math.max(0, depthBracket - 1);
738
+ continue;
739
+ }
740
+ if (character === '{') {
741
+ depthBrace += 1;
742
+ continue;
743
+ }
744
+ if (character === '}') {
745
+ depthBrace = Math.max(0, depthBrace - 1);
746
+ continue;
747
+ }
748
+
749
+ if (character === '@' && depthParen === 0 && depthBracket === 0 && depthBrace === 0) {
750
+ return {
751
+ typeSource: value.slice(0, index).trimEnd(),
752
+ attributeSource: value.slice(index),
753
+ attributeOffset: index,
754
+ };
755
+ }
756
+ }
757
+
758
+ return {
759
+ typeSource: value.trimEnd(),
760
+ attributeSource: '',
761
+ attributeOffset: value.length,
762
+ };
763
+ }
764
+
546
765
  function parseAttributeToken(
547
766
  context: ParserContext,
548
767
  input: {
@@ -613,12 +832,15 @@ function parseAttributeToken(
613
832
  return undefined;
614
833
  }
615
834
  const argsRaw = rawBody.slice(openParen + 1, closeParen);
616
- const parsedArgs = parseAttributeArguments(context, {
835
+ const parsedArgs = parseArgumentList(context, {
617
836
  argsRaw,
618
837
  argsOffset: input.span.start.column - 1 + (expectsBlockPrefix ? 2 : 1) + openParen + 1,
619
838
  lineIndex: input.lineIndex,
620
839
  token: input.token,
621
840
  span: input.span,
841
+ invalidCode: 'PSL_INVALID_ATTRIBUTE_SYNTAX',
842
+ invalidEmptyArgumentMessage: `Invalid empty argument in attribute "${input.token}"`,
843
+ invalidNamedArgumentMessage: (part) => `Invalid named argument syntax "${part}"`,
622
844
  });
623
845
  if (!parsedArgs) {
624
846
  return undefined;
@@ -635,7 +857,7 @@ function parseAttributeToken(
635
857
  };
636
858
  }
637
859
 
638
- function parseAttributeArguments(
860
+ function parseArgumentList(
639
861
  context: ParserContext,
640
862
  input: {
641
863
  readonly argsRaw: string;
@@ -643,6 +865,9 @@ function parseAttributeArguments(
643
865
  readonly lineIndex: number;
644
866
  readonly token: string;
645
867
  readonly span: PslSpan;
868
+ readonly invalidCode: PslDiagnosticCode;
869
+ readonly invalidEmptyArgumentMessage: string;
870
+ readonly invalidNamedArgumentMessage: (part: string) => string;
646
871
  },
647
872
  ): readonly PslAttributeArgument[] | undefined {
648
873
  const trimmed = input.argsRaw.trim();
@@ -658,8 +883,8 @@ function parseAttributeArguments(
658
883
  const trimmedPart = original.trim();
659
884
  if (trimmedPart.length === 0) {
660
885
  pushDiagnostic(context, {
661
- code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',
662
- message: `Invalid empty argument in attribute "${input.token}"`,
886
+ code: input.invalidCode,
887
+ message: input.invalidEmptyArgumentMessage,
663
888
  span: input.span,
664
889
  });
665
890
  return undefined;
@@ -675,8 +900,8 @@ function parseAttributeArguments(
675
900
  const first = namedSplit[0];
676
901
  if (!first) {
677
902
  pushDiagnostic(context, {
678
- code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',
679
- message: `Invalid named argument syntax "${trimmedPart}"`,
903
+ code: input.invalidCode,
904
+ message: input.invalidNamedArgumentMessage(trimmedPart),
680
905
  span: partSpan,
681
906
  });
682
907
  return undefined;
@@ -685,8 +910,8 @@ function parseAttributeArguments(
685
910
  const rawValue = trimmedPart.slice(first.end + 1).trim();
686
911
  if (!name || rawValue.length === 0) {
687
912
  pushDiagnostic(context, {
688
- code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',
689
- message: `Invalid named argument syntax "${trimmedPart}"`,
913
+ code: input.invalidCode,
914
+ message: input.invalidNamedArgumentMessage(trimmedPart),
690
915
  span: partSpan,
691
916
  });
692
917
  return undefined;
@@ -720,19 +945,17 @@ function findBlockBounds(context: ParserContext, startLine: number): BlockBounds
720
945
  for (let lineIndex = startLine; lineIndex < context.lines.length; lineIndex += 1) {
721
946
  const line = stripInlineComment(context.lines[lineIndex] ?? '');
722
947
  let quote: '"' | "'" | null = null;
723
- let previousCharacter = '';
724
- for (const character of line) {
948
+ for (let index = 0; index < line.length; index += 1) {
949
+ const character = line[index] ?? '';
725
950
  if (quote) {
726
- if (character === quote && previousCharacter !== '\\') {
951
+ if (character === quote && !isQuoteEscaped(line, index)) {
727
952
  quote = null;
728
953
  }
729
- previousCharacter = character;
730
954
  continue;
731
955
  }
732
956
 
733
957
  if (character === '"' || character === "'") {
734
958
  quote = character;
735
- previousCharacter = character;
736
959
  continue;
737
960
  }
738
961
 
@@ -745,7 +968,6 @@ function findBlockBounds(context: ParserContext, startLine: number): BlockBounds
745
968
  return { startLine, endLine: lineIndex, closed: true };
746
969
  }
747
970
  }
748
- previousCharacter = character;
749
971
  }
750
972
  }
751
973
 
@@ -771,13 +993,14 @@ function splitTopLevelSegments(value: string, separator: ',' | ':'): TopLevelSeg
771
993
  const parts: TopLevelSegment[] = [];
772
994
  let depthParen = 0;
773
995
  let depthBracket = 0;
996
+ let depthBrace = 0;
774
997
  let quote: '"' | "'" | null = null;
775
998
  let start = 0;
776
999
 
777
1000
  for (let index = 0; index < value.length; index += 1) {
778
1001
  const character = value[index] ?? '';
779
1002
  if (quote) {
780
- if (character === quote && value[index - 1] !== '\\') {
1003
+ if (character === quote && !isQuoteEscaped(value, index)) {
781
1004
  quote = null;
782
1005
  }
783
1006
  continue;
@@ -804,8 +1027,16 @@ function splitTopLevelSegments(value: string, separator: ',' | ':'): TopLevelSeg
804
1027
  depthBracket = Math.max(0, depthBracket - 1);
805
1028
  continue;
806
1029
  }
1030
+ if (character === '{') {
1031
+ depthBrace += 1;
1032
+ continue;
1033
+ }
1034
+ if (character === '}') {
1035
+ depthBrace = Math.max(0, depthBrace - 1);
1036
+ continue;
1037
+ }
807
1038
 
808
- if (character === separator && depthParen === 0 && depthBracket === 0) {
1039
+ if (character === separator && depthParen === 0 && depthBracket === 0 && depthBrace === 0) {
809
1040
  parts.push({
810
1041
  value: value.slice(start, index),
811
1042
  start,
@@ -874,7 +1105,7 @@ function extractAttributeTokensWithSpans(
874
1105
  while (index < value.length) {
875
1106
  const char = value[index] ?? '';
876
1107
  if (quote) {
877
- if (char === quote && value[index - 1] !== '\\') {
1108
+ if (char === quote && !isQuoteEscaped(value, index)) {
878
1109
  quote = null;
879
1110
  }
880
1111
  index += 1;
@@ -947,7 +1178,7 @@ function stripInlineComment(line: string): string {
947
1178
  const next = line[index + 1] ?? '';
948
1179
 
949
1180
  if (quote) {
950
- if (current === quote && line[index - 1] !== '\\') {
1181
+ if (current === quote && !isQuoteEscaped(line, index)) {
951
1182
  quote = null;
952
1183
  }
953
1184
  continue;
package/src/types.ts CHANGED
@@ -58,6 +58,13 @@ export interface PslAttributeNamedArgument {
58
58
 
59
59
  export type PslAttributeArgument = PslAttributePositionalArgument | PslAttributeNamedArgument;
60
60
 
61
+ export interface PslTypeConstructorCall {
62
+ readonly kind: 'typeConstructor';
63
+ readonly path: readonly string[];
64
+ readonly args: readonly PslAttributeArgument[];
65
+ readonly span: PslSpan;
66
+ }
67
+
61
68
  export interface PslAttribute {
62
69
  readonly kind: 'attribute';
63
70
  readonly target: PslAttributeTarget;
@@ -74,6 +81,7 @@ export interface PslField {
74
81
  readonly kind: 'field';
75
82
  readonly name: string;
76
83
  readonly typeName: string;
84
+ readonly typeConstructor?: PslTypeConstructorCall;
77
85
  readonly optional: boolean;
78
86
  readonly list: boolean;
79
87
  readonly typeRef?: string;
@@ -128,7 +136,13 @@ export interface PslCompositeType {
128
136
  export interface PslNamedTypeDeclaration {
129
137
  readonly kind: 'namedType';
130
138
  readonly name: string;
131
- readonly baseType: string;
139
+ /**
140
+ * Parser invariant: exactly one of `baseType` and `typeConstructor` is set.
141
+ * Expressing this as a discriminated union trips TypeScript narrowing when
142
+ * the declaration flows through helpers that accept the full union.
143
+ */
144
+ readonly baseType?: string;
145
+ readonly typeConstructor?: PslTypeConstructorCall;
132
146
  readonly attributes: readonly PslAttribute[];
133
147
  readonly span: PslSpan;
134
148
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser-D-_7FY6a.d.mts","names":[],"sources":["../src/parser.ts"],"sourcesContent":[],"mappings":";;;iBAiDgB,gBAAA,QAAwB,wBAAwB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser-jCEw-qFr.mjs","names":["diagnostics: PslDiagnostic[]","context: ParserContext","models: PslModel[]","enums: PslEnum[]","compositeTypes: PslCompositeType[]","typesBlock: PslTypesBlock | undefined","fields: PslField[]","attributes: PslModelAttribute[]","attributes: PslAttribute[]","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 PslCompositeType,\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 const compositeTypes: PslCompositeType[] = [];\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 const compositeTypeMatch = line.match(/^type\\s+([A-Za-z_]\\w*)\\s*\\{$/);\n if (compositeTypeMatch) {\n const bounds = findBlockBounds(context, lineIndex);\n const name = compositeTypeMatch[1] ?? '';\n if (name.length === 0) {\n lineIndex = bounds.endLine + 1;\n continue;\n }\n compositeTypes.push(parseCompositeTypeBlock(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 const compositeTypeNames = new Set(compositeTypes.map((ct) => ct.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 compositeTypeNames.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 compositeTypes,\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 parseCompositeTypeBlock(\n context: ParserContext,\n name: string,\n bounds: BlockBounds,\n): PslCompositeType {\n const fields: PslField[] = [];\n const attributes: PslAttribute[] = [];\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: 'compositeType',\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 const attributes: PslAttribute[] = [];\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 = parseEnumAttribute(context, line, lineIndex);\n if (attribute) {\n attributes.push(attribute);\n }\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 attributes,\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 parseEnumAttribute(\n context: ParserContext,\n line: string,\n lineIndex: number,\n): PslAttribute | 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_ENUM_MEMBER',\n message: `Invalid enum value declaration \"${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 const parsed = parseAttributeToken(context, {\n token: token.text,\n target: 'enum',\n lineIndex,\n span: token.span,\n });\n if (!parsed) {\n return undefined;\n }\n if (parsed.name !== 'map') {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ENUM_MEMBER',\n message: `Invalid enum value declaration \"${line}\"`,\n span: createTrimmedLineSpan(context, lineIndex),\n });\n return undefined;\n }\n return parsed;\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 expectsBlockPrefix = input.target === 'model' || input.target === 'enum';\n const targetLabel = input.target === 'enum' ? 'Enum' : 'Model';\n if (expectsBlockPrefix && !input.token.startsWith('@@')) {\n pushDiagnostic(context, {\n code: 'PSL_INVALID_ATTRIBUTE_SYNTAX',\n message: `${targetLabel} attribute \"${input.token}\" must use @@ prefix`,\n span: input.span,\n });\n return undefined;\n }\n if (!expectsBlockPrefix && !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 (!expectsBlockPrefix && 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 = expectsBlockPrefix ? 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 + (expectsBlockPrefix ? 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":";;;AAuBA,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,MAAMC,iBAAqC,EAAE;CAC7C,IAAIC;CAEJ,IAAI,Y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