semantifold 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +71 -0
  3. package/build/index.d.ts +54 -0
  4. package/build/index.d.ts.map +1 -0
  5. package/build/index.js +45 -0
  6. package/build/src/backends/identifiers.d.ts +19 -0
  7. package/build/src/backends/identifiers.d.ts.map +1 -0
  8. package/build/src/backends/identifiers.js +93 -0
  9. package/build/src/backends/index.d.ts +35 -0
  10. package/build/src/backends/index.d.ts.map +1 -0
  11. package/build/src/backends/index.js +149 -0
  12. package/build/src/backends/java.d.ts +8 -0
  13. package/build/src/backends/java.d.ts.map +1 -0
  14. package/build/src/backends/java.js +172 -0
  15. package/build/src/backends/javascript.d.ts +8 -0
  16. package/build/src/backends/javascript.d.ts.map +1 -0
  17. package/build/src/backends/javascript.js +173 -0
  18. package/build/src/backends/php.d.ts +8 -0
  19. package/build/src/backends/php.d.ts.map +1 -0
  20. package/build/src/backends/php.js +175 -0
  21. package/build/src/backends/ruby.d.ts +8 -0
  22. package/build/src/backends/ruby.d.ts.map +1 -0
  23. package/build/src/backends/ruby.js +155 -0
  24. package/build/src/backends/scalars.d.ts +15 -0
  25. package/build/src/backends/scalars.d.ts.map +1 -0
  26. package/build/src/backends/scalars.js +138 -0
  27. package/build/src/backends/shared.d.ts +26 -0
  28. package/build/src/backends/shared.d.ts.map +1 -0
  29. package/build/src/backends/shared.js +424 -0
  30. package/build/src/backends/typescript.d.ts +8 -0
  31. package/build/src/backends/typescript.d.ts.map +1 -0
  32. package/build/src/backends/typescript.js +160 -0
  33. package/build/src/backends/writer.d.ts +87 -0
  34. package/build/src/backends/writer.d.ts.map +1 -0
  35. package/build/src/backends/writer.js +207 -0
  36. package/build/src/diagnostic.d.ts +67 -0
  37. package/build/src/diagnostic.d.ts.map +1 -0
  38. package/build/src/diagnostic.js +96 -0
  39. package/build/src/frontends/index.d.ts +14 -0
  40. package/build/src/frontends/index.d.ts.map +1 -0
  41. package/build/src/frontends/index.js +36 -0
  42. package/build/src/frontends/java.d.ts +12 -0
  43. package/build/src/frontends/java.d.ts.map +1 -0
  44. package/build/src/frontends/java.js +630 -0
  45. package/build/src/frontends/javascript-typescript.d.ts +19 -0
  46. package/build/src/frontends/javascript-typescript.d.ts.map +1 -0
  47. package/build/src/frontends/javascript-typescript.js +633 -0
  48. package/build/src/frontends/php.d.ts +12 -0
  49. package/build/src/frontends/php.d.ts.map +1 -0
  50. package/build/src/frontends/php.js +523 -0
  51. package/build/src/frontends/ruby.d.ts +12 -0
  52. package/build/src/frontends/ruby.d.ts.map +1 -0
  53. package/build/src/frontends/ruby.js +515 -0
  54. package/build/src/frontends/scalars.d.ts +19 -0
  55. package/build/src/frontends/scalars.d.ts.map +1 -0
  56. package/build/src/frontends/scalars.js +71 -0
  57. package/build/src/mapping.d.ts +160 -0
  58. package/build/src/mapping.d.ts.map +1 -0
  59. package/build/src/mapping.js +1120 -0
  60. package/build/src/semantic/location.d.ts +61 -0
  61. package/build/src/semantic/location.d.ts.map +1 -0
  62. package/build/src/semantic/location.js +142 -0
  63. package/build/src/semantic/operators.d.ts +16 -0
  64. package/build/src/semantic/operators.d.ts.map +1 -0
  65. package/build/src/semantic/operators.js +24 -0
  66. package/build/src/semantic/provenance.d.ts +74 -0
  67. package/build/src/semantic/provenance.d.ts.map +1 -0
  68. package/build/src/semantic/provenance.js +577 -0
  69. package/build/src/semantic/scalars.d.ts +19 -0
  70. package/build/src/semantic/scalars.d.ts.map +1 -0
  71. package/build/src/semantic/scalars.js +40 -0
  72. package/build/src/semantic/types.d.ts +1003 -0
  73. package/build/src/semantic/types.d.ts.map +1 -0
  74. package/build/src/semantic/types.js +279 -0
  75. package/build/src/semantic/validate.d.ts +60 -0
  76. package/build/src/semantic/validate.d.ts.map +1 -0
  77. package/build/src/semantic/validate.js +472 -0
  78. package/docs/architecture.md +39 -0
  79. package/docs/coding-standards.md +7 -0
  80. package/docs/goals.md +7 -0
  81. package/docs/language-support.md +69 -0
  82. package/docs/plans/2026-09-02-initial-toolchain.md +54 -0
  83. package/docs/source-maps.md +134 -0
  84. package/docs/testing.md +25 -0
  85. package/index.js +63 -0
  86. package/package.json +69 -0
  87. package/src/backends/identifiers.js +101 -0
  88. package/src/backends/index.js +159 -0
  89. package/src/backends/java.js +182 -0
  90. package/src/backends/javascript.js +184 -0
  91. package/src/backends/php.js +184 -0
  92. package/src/backends/ruby.js +163 -0
  93. package/src/backends/scalars.js +120 -0
  94. package/src/backends/shared.js +456 -0
  95. package/src/backends/typescript.js +168 -0
  96. package/src/backends/writer.js +224 -0
  97. package/src/diagnostic.js +103 -0
  98. package/src/frontends/index.js +36 -0
  99. package/src/frontends/java.js +735 -0
  100. package/src/frontends/javascript-typescript.js +718 -0
  101. package/src/frontends/php.js +593 -0
  102. package/src/frontends/ruby.js +622 -0
  103. package/src/frontends/scalars.js +77 -0
  104. package/src/mapping.js +1260 -0
  105. package/src/semantic/location.js +154 -0
  106. package/src/semantic/operators.js +28 -0
  107. package/src/semantic/provenance.js +629 -0
  108. package/src/semantic/scalars.js +44 -0
  109. package/src/semantic/types.js +319 -0
  110. package/src/semantic/validate.js +529 -0
  111. package/tsconfig.json +16 -0
@@ -0,0 +1,1003 @@
1
+ export type SemanticLanguage = "php" | "ruby" | "javascript" | "typescript" | "java";
2
+ export type SemanticTypeName = "integer" | "boolean" | "string";
3
+ export type SemanticUnaryOperation = "IntegerNegate" | "BooleanNot";
4
+ export type SemanticBinaryOperation = "IntegerAdd" | "IntegerSubtract" | "IntegerMultiply" | "BooleanAnd" | "BooleanOr" | "IntegerEqual" | "IntegerNotEqual" | "BooleanEqual" | "BooleanNotEqual" | "StringEqual" | "StringNotEqual" | "IntegerLessThan" | "IntegerLessThanOrEqual" | "IntegerGreaterThan" | "IntegerGreaterThanOrEqual" | "StringConcat";
5
+ export type SemanticSymbolKind = "function" | "parameter" | "local";
6
+ export type SemanticSymbolRole = "declaration" | "read" | "write" | "call";
7
+ export type SourcePoint = {
8
+ /**
9
+ * - One-based line.
10
+ */
11
+ line: number;
12
+ /**
13
+ * - One-based UTF-16 code-unit column.
14
+ */
15
+ column: number;
16
+ /**
17
+ * - Zero-based UTF-16 source offset.
18
+ */
19
+ offset: number;
20
+ };
21
+ export type SourceLocation = {
22
+ /**
23
+ * - Originating filename.
24
+ */
25
+ filename: string;
26
+ /**
27
+ * - Inclusive start.
28
+ */
29
+ start: SourcePoint;
30
+ /**
31
+ * - Exclusive end.
32
+ */
33
+ end: SourcePoint;
34
+ };
35
+ export type RegisteredSource = {
36
+ /**
37
+ * - Registry-local deterministic source identity.
38
+ */
39
+ id: string;
40
+ /**
41
+ * - Original filename, preserved verbatim.
42
+ */
43
+ filename: string;
44
+ /**
45
+ * - Original source content, preserved verbatim when available.
46
+ */
47
+ content: string | null;
48
+ /**
49
+ * - Parser language when known.
50
+ */
51
+ language: SemanticLanguage | null;
52
+ };
53
+ export type SourceOrigin = {
54
+ /**
55
+ * - Direct source provenance.
56
+ */
57
+ kind: "source";
58
+ /**
59
+ * - Registered source identity.
60
+ */
61
+ sourceId: string;
62
+ /**
63
+ * - Exact original range.
64
+ */
65
+ location: SourceLocation;
66
+ };
67
+ export type RelatedOrigin = {
68
+ /**
69
+ * - Registered source identity.
70
+ */
71
+ sourceId: string;
72
+ /**
73
+ * - Related original range.
74
+ */
75
+ location: SourceLocation;
76
+ /**
77
+ * - Related semantic node identity.
78
+ */
79
+ nodeId?: string;
80
+ /**
81
+ * - Related semantic symbol identity.
82
+ */
83
+ symbolId?: string;
84
+ /**
85
+ * - Relationship role.
86
+ */
87
+ role?: string;
88
+ };
89
+ export type DerivedOrigin = {
90
+ /**
91
+ * - Provenance derived from one or more origins.
92
+ */
93
+ kind: "derived";
94
+ /**
95
+ * - Ordered, non-empty original ranges.
96
+ */
97
+ origins: RelatedOrigin[];
98
+ };
99
+ export type SyntheticOrigin = {
100
+ /**
101
+ * - Source-free generated or semantic scaffolding.
102
+ */
103
+ kind: "synthetic";
104
+ /**
105
+ * - Stable human-readable reason.
106
+ */
107
+ reason: string;
108
+ /**
109
+ * - Ordered related ranges, possibly empty.
110
+ */
111
+ relatedOrigins: RelatedOrigin[];
112
+ };
113
+ export type SemanticOrigin = SourceOrigin | DerivedOrigin | SyntheticOrigin;
114
+ export type SemanticNodeSourceProvenance = {
115
+ /**
116
+ * - Association discriminator.
117
+ */
118
+ schema: "SemantifoldNodeProvenance";
119
+ /**
120
+ * - Association version.
121
+ */
122
+ version: 1;
123
+ /**
124
+ * - Source association independent of traversal position.
125
+ */
126
+ origin: SemanticOrigin;
127
+ /**
128
+ * - Exact semantic-token subranges by role.
129
+ */
130
+ ranges: Readonly<Record<string, SourceLocation>>;
131
+ };
132
+ export type SemanticNodeProvenance = {
133
+ /**
134
+ * - Deterministic module-local node identity.
135
+ */
136
+ id: string;
137
+ /**
138
+ * - JSON Pointer from the semantic module root.
139
+ */
140
+ path: string;
141
+ /**
142
+ * - Semantic node kind.
143
+ */
144
+ kind: SemanticNode["kind"] | "TypeReference";
145
+ /**
146
+ * - Closed provenance value.
147
+ */
148
+ origin: SemanticOrigin;
149
+ /**
150
+ * - Exact semantic-token subranges by role.
151
+ */
152
+ ranges: Readonly<Record<string, SourceLocation>>;
153
+ /**
154
+ * - Resolved declared/referenced symbol identity.
155
+ */
156
+ symbolId?: string;
157
+ };
158
+ export type SemanticSymbolReference = {
159
+ /**
160
+ * - Referring semantic node identity.
161
+ */
162
+ nodeId: string;
163
+ /**
164
+ * - Reference role.
165
+ */
166
+ role: SemanticSymbolRole;
167
+ /**
168
+ * - Exact reference range.
169
+ */
170
+ location: SourceLocation;
171
+ };
172
+ export type SemanticSymbolProvenance = {
173
+ /**
174
+ * - Deterministic module-local symbol identity.
175
+ */
176
+ id: string;
177
+ /**
178
+ * - Semantic symbol name.
179
+ */
180
+ name: string;
181
+ /**
182
+ * - Symbol category.
183
+ */
184
+ kind: SemanticSymbolKind;
185
+ /**
186
+ * - Declaring node identity.
187
+ */
188
+ declarationNodeId: string;
189
+ /**
190
+ * - Exact declaration-name range.
191
+ */
192
+ location: SourceLocation;
193
+ /**
194
+ * - Ordered resolved references.
195
+ */
196
+ references: SemanticSymbolReference[];
197
+ };
198
+ export type SemanticProvenance = {
199
+ /**
200
+ * - Schema discriminator.
201
+ */
202
+ schema: "SemantifoldProvenance";
203
+ /**
204
+ * - Schema version.
205
+ */
206
+ version: 1;
207
+ /**
208
+ * - Offset and column unit.
209
+ */
210
+ coordinateSystem: "utf16";
211
+ /**
212
+ * - Versioned source registry.
213
+ */
214
+ sources: RegisteredSource[];
215
+ /**
216
+ * - Deterministic node index.
217
+ */
218
+ nodes: SemanticNodeProvenance[];
219
+ /**
220
+ * - Deterministic symbol index.
221
+ */
222
+ symbols: SemanticSymbolProvenance[];
223
+ };
224
+ export type MappingKind = "exact" | "anchor" | "synthetic";
225
+ export type SemantifoldMappingSpan = {
226
+ /**
227
+ * - Generated half-open range.
228
+ */
229
+ generated: SourceLocation;
230
+ /**
231
+ * - Mapping precision.
232
+ */
233
+ mappingKind: MappingKind;
234
+ /**
235
+ * - Closed original provenance.
236
+ */
237
+ origin: SemanticOrigin;
238
+ /**
239
+ * - Related canonical semantic node.
240
+ */
241
+ nodeId?: string;
242
+ /**
243
+ * - Related canonical semantic symbol.
244
+ */
245
+ symbolId?: string;
246
+ /**
247
+ * - Semantic token role.
248
+ */
249
+ role?: string;
250
+ /**
251
+ * - Useful symbol name for Source Map v3.
252
+ */
253
+ name?: string;
254
+ };
255
+ export type GeneratedSource = {
256
+ /**
257
+ * - Output filename.
258
+ */
259
+ filename: string;
260
+ /**
261
+ * - Output language.
262
+ */
263
+ language: SemanticLanguage;
264
+ /**
265
+ * - Exact generated LF source.
266
+ */
267
+ content: string;
268
+ };
269
+ export type SemantifoldMapping = {
270
+ /**
271
+ * - Schema discriminator.
272
+ */
273
+ schema: "SemantifoldMapping";
274
+ /**
275
+ * - Schema version.
276
+ */
277
+ version: 1;
278
+ /**
279
+ * - Offset and column unit.
280
+ */
281
+ coordinateSystem: "utf16";
282
+ /**
283
+ * - Generated program identity and content.
284
+ */
285
+ generated: GeneratedSource;
286
+ /**
287
+ * - Original source registry.
288
+ */
289
+ sources: RegisteredSource[];
290
+ /**
291
+ * - Canonical semantic node index.
292
+ */
293
+ nodes: SemanticNodeProvenance[];
294
+ /**
295
+ * - Canonical semantic symbol index.
296
+ */
297
+ symbols: SemanticSymbolProvenance[];
298
+ /**
299
+ * - Ordered generated ranges.
300
+ */
301
+ spans: SemantifoldMappingSpan[];
302
+ };
303
+ export type GeneratedArtifact = {
304
+ /**
305
+ * - Generated output program, including any requested directive.
306
+ */
307
+ code: string;
308
+ /**
309
+ * - Generated output filename.
310
+ */
311
+ filename: string;
312
+ /**
313
+ * - Output language.
314
+ */
315
+ language: SemanticLanguage;
316
+ /**
317
+ * - Authoritative rich mapping.
318
+ */
319
+ mapping: SemantifoldMapping;
320
+ /**
321
+ * - Source Map v3 projection.
322
+ */
323
+ sourceMap: import("@jridgewell/gen-mapping").EncodedSourceMap;
324
+ /**
325
+ * - Default external Source Map filename.
326
+ */
327
+ sourceMapFilename: string;
328
+ };
329
+ export type TypeReference = {
330
+ /**
331
+ * - Node discriminator.
332
+ */
333
+ kind: "TypeReference";
334
+ /**
335
+ * - Normalized type name.
336
+ */
337
+ name: SemanticTypeName;
338
+ /**
339
+ * - Node-associated provenance that survives semantic transforms.
340
+ */
341
+ sourceProvenance?: SemanticNodeSourceProvenance;
342
+ };
343
+ export type Parameter = {
344
+ /**
345
+ * - Node discriminator.
346
+ */
347
+ kind: "Parameter";
348
+ /**
349
+ * - Parameter name.
350
+ */
351
+ name: string;
352
+ /**
353
+ * - Parameter type.
354
+ */
355
+ type: TypeReference;
356
+ /**
357
+ * - Source location.
358
+ */
359
+ location: SourceLocation;
360
+ /**
361
+ * - Node-associated provenance.
362
+ */
363
+ sourceProvenance?: SemanticNodeSourceProvenance;
364
+ };
365
+ export type IdentifierExpression = {
366
+ /**
367
+ * - Node discriminator.
368
+ */
369
+ kind: "IdentifierExpression";
370
+ /**
371
+ * - Referenced name.
372
+ */
373
+ name: string;
374
+ /**
375
+ * - Source location.
376
+ */
377
+ location: SourceLocation;
378
+ /**
379
+ * - Node-associated provenance.
380
+ */
381
+ sourceProvenance?: SemanticNodeSourceProvenance;
382
+ };
383
+ export type IntegerLiteral = {
384
+ /**
385
+ * - Node discriminator.
386
+ */
387
+ kind: "IntegerLiteral";
388
+ /**
389
+ * - JavaScript-safe integer value.
390
+ */
391
+ value: number;
392
+ /**
393
+ * - Source location.
394
+ */
395
+ location: SourceLocation;
396
+ /**
397
+ * - Node-associated provenance.
398
+ */
399
+ sourceProvenance?: SemanticNodeSourceProvenance;
400
+ };
401
+ export type BooleanLiteral = {
402
+ /**
403
+ * - Node discriminator.
404
+ */
405
+ kind: "BooleanLiteral";
406
+ /**
407
+ * - Boolean value.
408
+ */
409
+ value: boolean;
410
+ /**
411
+ * - Source location.
412
+ */
413
+ location: SourceLocation;
414
+ /**
415
+ * - Node-associated provenance.
416
+ */
417
+ sourceProvenance?: SemanticNodeSourceProvenance;
418
+ };
419
+ export type StringLiteral = {
420
+ /**
421
+ * - Node discriminator.
422
+ */
423
+ kind: "StringLiteral";
424
+ /**
425
+ * - Unicode string value.
426
+ */
427
+ value: string;
428
+ /**
429
+ * - Source location.
430
+ */
431
+ location: SourceLocation;
432
+ /**
433
+ * - Node-associated provenance.
434
+ */
435
+ sourceProvenance?: SemanticNodeSourceProvenance;
436
+ };
437
+ export type UnaryExpression = {
438
+ /**
439
+ * - Node discriminator.
440
+ */
441
+ kind: "UnaryExpression";
442
+ /**
443
+ * - Closed semantic operation.
444
+ */
445
+ operation: SemanticUnaryOperation;
446
+ /**
447
+ * - Operand evaluated exactly once.
448
+ */
449
+ operand: Expression;
450
+ /**
451
+ * - Explicit operation result type.
452
+ */
453
+ type: SemanticTypeName;
454
+ /**
455
+ * - Source location.
456
+ */
457
+ location: SourceLocation;
458
+ /**
459
+ * - Node-associated provenance.
460
+ */
461
+ sourceProvenance?: SemanticNodeSourceProvenance;
462
+ };
463
+ export type BinaryExpression = {
464
+ /**
465
+ * - Node discriminator.
466
+ */
467
+ kind: "BinaryExpression";
468
+ /**
469
+ * - Closed semantic operation.
470
+ */
471
+ operation: SemanticBinaryOperation;
472
+ /**
473
+ * - Left operand.
474
+ */
475
+ left: Expression;
476
+ /**
477
+ * - Right operand.
478
+ */
479
+ right: Expression;
480
+ /**
481
+ * - Explicit operation result type.
482
+ */
483
+ type: SemanticTypeName;
484
+ /**
485
+ * - Source location.
486
+ */
487
+ location: SourceLocation;
488
+ /**
489
+ * - Node-associated provenance.
490
+ */
491
+ sourceProvenance?: SemanticNodeSourceProvenance;
492
+ };
493
+ export type CallExpression = {
494
+ /**
495
+ * - Node discriminator.
496
+ */
497
+ kind: "CallExpression";
498
+ /**
499
+ * - Function name.
500
+ */
501
+ callee: string;
502
+ /**
503
+ * - Positional arguments.
504
+ */
505
+ arguments: Expression[];
506
+ /**
507
+ * - Source location.
508
+ */
509
+ location: SourceLocation;
510
+ /**
511
+ * - Node-associated provenance.
512
+ */
513
+ sourceProvenance?: SemanticNodeSourceProvenance;
514
+ };
515
+ export type Expression = IdentifierExpression | IntegerLiteral | BooleanLiteral | StringLiteral | UnaryExpression | BinaryExpression | CallExpression;
516
+ export type LocalDeclaration = {
517
+ /**
518
+ * - Node discriminator.
519
+ */
520
+ kind: "LocalDeclaration";
521
+ /**
522
+ * - Declared local name.
523
+ */
524
+ name: string;
525
+ /**
526
+ * - Explicit local type.
527
+ */
528
+ type: TypeReference;
529
+ /**
530
+ * - Whether later assignment is allowed.
531
+ */
532
+ mutable: boolean;
533
+ /**
534
+ * - Required initializer expression.
535
+ */
536
+ initializer: Expression;
537
+ /**
538
+ * - Declaration source location.
539
+ */
540
+ location: SourceLocation;
541
+ /**
542
+ * - Node-associated provenance.
543
+ */
544
+ sourceProvenance?: SemanticNodeSourceProvenance;
545
+ };
546
+ export type AssignmentStatement = {
547
+ /**
548
+ * - Node discriminator.
549
+ */
550
+ kind: "AssignmentStatement";
551
+ /**
552
+ * - Simple local assignment target.
553
+ */
554
+ target: IdentifierExpression;
555
+ /**
556
+ * - Assigned expression.
557
+ */
558
+ expression: Expression;
559
+ /**
560
+ * - Assignment source location.
561
+ */
562
+ location: SourceLocation;
563
+ /**
564
+ * - Node-associated provenance.
565
+ */
566
+ sourceProvenance?: SemanticNodeSourceProvenance;
567
+ };
568
+ export type ReturnStatement = {
569
+ /**
570
+ * - Node discriminator.
571
+ */
572
+ kind: "ReturnStatement";
573
+ /**
574
+ * - Returned expression.
575
+ */
576
+ expression: Expression;
577
+ /**
578
+ * - Source location.
579
+ */
580
+ location: SourceLocation;
581
+ /**
582
+ * - Node-associated provenance.
583
+ */
584
+ sourceProvenance?: SemanticNodeSourceProvenance;
585
+ };
586
+ export type IfStatement = {
587
+ /**
588
+ * - Node discriminator.
589
+ */
590
+ kind: "IfStatement";
591
+ /**
592
+ * - Branch condition.
593
+ */
594
+ condition: Expression;
595
+ /**
596
+ * - True branch.
597
+ */
598
+ consequent: Block;
599
+ /**
600
+ * - False branch, absent when execution falls through.
601
+ */
602
+ alternate?: Block;
603
+ /**
604
+ * - Source location.
605
+ */
606
+ location: SourceLocation;
607
+ /**
608
+ * - Node-associated provenance.
609
+ */
610
+ sourceProvenance?: SemanticNodeSourceProvenance;
611
+ };
612
+ export type LocalStatement = LocalDeclaration | AssignmentStatement;
613
+ export type Statement = LocalStatement | IfStatement | ReturnStatement | PrintStatement;
614
+ export type Block = {
615
+ /**
616
+ * - Node discriminator.
617
+ */
618
+ kind: "Block";
619
+ /**
620
+ * - Ordered statements in one lexical scope.
621
+ */
622
+ statements: Statement[];
623
+ /**
624
+ * - Source location.
625
+ */
626
+ location: SourceLocation;
627
+ /**
628
+ * - Node-associated provenance.
629
+ */
630
+ sourceProvenance?: SemanticNodeSourceProvenance;
631
+ };
632
+ export type FunctionDeclaration = {
633
+ /**
634
+ * - Node discriminator.
635
+ */
636
+ kind: "FunctionDeclaration";
637
+ /**
638
+ * - Function name.
639
+ */
640
+ name: string;
641
+ /**
642
+ * - Function parameters.
643
+ */
644
+ parameters: Parameter[];
645
+ /**
646
+ * - Return type.
647
+ */
648
+ returnType: TypeReference;
649
+ /**
650
+ * - Function body.
651
+ */
652
+ body: Block;
653
+ /**
654
+ * - Source location.
655
+ */
656
+ location: SourceLocation;
657
+ /**
658
+ * - Node-associated provenance.
659
+ */
660
+ sourceProvenance?: SemanticNodeSourceProvenance;
661
+ };
662
+ export type PrintStatement = {
663
+ /**
664
+ * - Node discriminator.
665
+ */
666
+ kind: "PrintStatement";
667
+ /**
668
+ * - Printed expression.
669
+ */
670
+ expression: Expression;
671
+ /**
672
+ * - Source location.
673
+ */
674
+ location: SourceLocation;
675
+ /**
676
+ * - Node-associated provenance.
677
+ */
678
+ sourceProvenance?: SemanticNodeSourceProvenance;
679
+ };
680
+ export type EntryPoint = {
681
+ /**
682
+ * - Node discriminator.
683
+ */
684
+ kind: "EntryPoint";
685
+ /**
686
+ * - Entry-point body.
687
+ */
688
+ body: Block;
689
+ /**
690
+ * - Source location.
691
+ */
692
+ location: SourceLocation;
693
+ /**
694
+ * - Node-associated provenance.
695
+ */
696
+ sourceProvenance?: SemanticNodeSourceProvenance;
697
+ };
698
+ export type SemanticModule = {
699
+ /**
700
+ * - Node discriminator.
701
+ */
702
+ kind: "Module";
703
+ /**
704
+ * - Top-level functions.
705
+ */
706
+ functions: FunctionDeclaration[];
707
+ /**
708
+ * - Executable entry point.
709
+ */
710
+ entryPoint: EntryPoint;
711
+ /**
712
+ * - Source location.
713
+ */
714
+ location: SourceLocation;
715
+ /**
716
+ * - Node-associated provenance.
717
+ */
718
+ sourceProvenance?: SemanticNodeSourceProvenance;
719
+ /**
720
+ * - Parser-authored source and identity index; optional for legacy caller-authored modules.
721
+ */
722
+ provenance?: SemanticProvenance;
723
+ };
724
+ export type SemanticNode = SemanticModule | FunctionDeclaration | Parameter | Block | Statement | EntryPoint | Expression | TypeReference;
725
+ export type SemanticNodeWithoutLocations = SemanticNode;
726
+ /** @typedef {"php" | "ruby" | "javascript" | "typescript" | "java"} SemanticLanguage */
727
+ /** @typedef {"integer" | "boolean" | "string"} SemanticTypeName */
728
+ /** @typedef {"IntegerNegate" | "BooleanNot"} SemanticUnaryOperation */
729
+ /** @typedef {"IntegerAdd" | "IntegerSubtract" | "IntegerMultiply" | "BooleanAnd" | "BooleanOr" | "IntegerEqual" | "IntegerNotEqual" | "BooleanEqual" | "BooleanNotEqual" | "StringEqual" | "StringNotEqual" | "IntegerLessThan" | "IntegerLessThanOrEqual" | "IntegerGreaterThan" | "IntegerGreaterThanOrEqual" | "StringConcat"} SemanticBinaryOperation */
730
+ /** @typedef {"function" | "parameter" | "local"} SemanticSymbolKind */
731
+ /** @typedef {"declaration" | "read" | "write" | "call"} SemanticSymbolRole */
732
+ /**
733
+ * @typedef SourcePoint
734
+ * @property {number} line - One-based line.
735
+ * @property {number} column - One-based UTF-16 code-unit column.
736
+ * @property {number} offset - Zero-based UTF-16 source offset.
737
+ */
738
+ /**
739
+ * @typedef SourceLocation
740
+ * @property {string} filename - Originating filename.
741
+ * @property {SourcePoint} start - Inclusive start.
742
+ * @property {SourcePoint} end - Exclusive end.
743
+ */
744
+ /**
745
+ * @typedef RegisteredSource
746
+ * @property {string} id - Registry-local deterministic source identity.
747
+ * @property {string} filename - Original filename, preserved verbatim.
748
+ * @property {string | null} content - Original source content, preserved verbatim when available.
749
+ * @property {SemanticLanguage | null} language - Parser language when known.
750
+ */
751
+ /**
752
+ * @typedef SourceOrigin
753
+ * @property {"source"} kind - Direct source provenance.
754
+ * @property {string} sourceId - Registered source identity.
755
+ * @property {SourceLocation} location - Exact original range.
756
+ */
757
+ /**
758
+ * @typedef RelatedOrigin
759
+ * @property {string} sourceId - Registered source identity.
760
+ * @property {SourceLocation} location - Related original range.
761
+ * @property {string} [nodeId] - Related semantic node identity.
762
+ * @property {string} [symbolId] - Related semantic symbol identity.
763
+ * @property {string} [role] - Relationship role.
764
+ */
765
+ /**
766
+ * @typedef DerivedOrigin
767
+ * @property {"derived"} kind - Provenance derived from one or more origins.
768
+ * @property {RelatedOrigin[]} origins - Ordered, non-empty original ranges.
769
+ */
770
+ /**
771
+ * @typedef SyntheticOrigin
772
+ * @property {"synthetic"} kind - Source-free generated or semantic scaffolding.
773
+ * @property {string} reason - Stable human-readable reason.
774
+ * @property {RelatedOrigin[]} relatedOrigins - Ordered related ranges, possibly empty.
775
+ */
776
+ /** @typedef {SourceOrigin | DerivedOrigin | SyntheticOrigin} SemanticOrigin */
777
+ /**
778
+ * @typedef SemanticNodeSourceProvenance
779
+ * @property {"SemantifoldNodeProvenance"} schema - Association discriminator.
780
+ * @property {1} version - Association version.
781
+ * @property {SemanticOrigin} origin - Source association independent of traversal position.
782
+ * @property {Readonly<Record<string, SourceLocation>>} ranges - Exact semantic-token subranges by role.
783
+ */
784
+ /**
785
+ * @typedef SemanticNodeProvenance
786
+ * @property {string} id - Deterministic module-local node identity.
787
+ * @property {string} path - JSON Pointer from the semantic module root.
788
+ * @property {SemanticNode["kind"] | "TypeReference"} kind - Semantic node kind.
789
+ * @property {SemanticOrigin} origin - Closed provenance value.
790
+ * @property {Readonly<Record<string, SourceLocation>>} ranges - Exact semantic-token subranges by role.
791
+ * @property {string} [symbolId] - Resolved declared/referenced symbol identity.
792
+ */
793
+ /**
794
+ * @typedef SemanticSymbolReference
795
+ * @property {string} nodeId - Referring semantic node identity.
796
+ * @property {SemanticSymbolRole} role - Reference role.
797
+ * @property {SourceLocation} location - Exact reference range.
798
+ */
799
+ /**
800
+ * @typedef SemanticSymbolProvenance
801
+ * @property {string} id - Deterministic module-local symbol identity.
802
+ * @property {string} name - Semantic symbol name.
803
+ * @property {SemanticSymbolKind} kind - Symbol category.
804
+ * @property {string} declarationNodeId - Declaring node identity.
805
+ * @property {SourceLocation} location - Exact declaration-name range.
806
+ * @property {SemanticSymbolReference[]} references - Ordered resolved references.
807
+ */
808
+ /**
809
+ * @typedef SemanticProvenance
810
+ * @property {"SemantifoldProvenance"} schema - Schema discriminator.
811
+ * @property {1} version - Schema version.
812
+ * @property {"utf16"} coordinateSystem - Offset and column unit.
813
+ * @property {RegisteredSource[]} sources - Versioned source registry.
814
+ * @property {SemanticNodeProvenance[]} nodes - Deterministic node index.
815
+ * @property {SemanticSymbolProvenance[]} symbols - Deterministic symbol index.
816
+ */
817
+ /** @typedef {"exact" | "anchor" | "synthetic"} MappingKind */
818
+ /**
819
+ * @typedef SemantifoldMappingSpan
820
+ * @property {SourceLocation} generated - Generated half-open range.
821
+ * @property {MappingKind} mappingKind - Mapping precision.
822
+ * @property {SemanticOrigin} origin - Closed original provenance.
823
+ * @property {string} [nodeId] - Related canonical semantic node.
824
+ * @property {string} [symbolId] - Related canonical semantic symbol.
825
+ * @property {string} [role] - Semantic token role.
826
+ * @property {string} [name] - Useful symbol name for Source Map v3.
827
+ */
828
+ /**
829
+ * @typedef GeneratedSource
830
+ * @property {string} filename - Output filename.
831
+ * @property {SemanticLanguage} language - Output language.
832
+ * @property {string} content - Exact generated LF source.
833
+ */
834
+ /**
835
+ * @typedef SemantifoldMapping
836
+ * @property {"SemantifoldMapping"} schema - Schema discriminator.
837
+ * @property {1} version - Schema version.
838
+ * @property {"utf16"} coordinateSystem - Offset and column unit.
839
+ * @property {GeneratedSource} generated - Generated program identity and content.
840
+ * @property {RegisteredSource[]} sources - Original source registry.
841
+ * @property {SemanticNodeProvenance[]} nodes - Canonical semantic node index.
842
+ * @property {SemanticSymbolProvenance[]} symbols - Canonical semantic symbol index.
843
+ * @property {SemantifoldMappingSpan[]} spans - Ordered generated ranges.
844
+ */
845
+ /**
846
+ * @typedef GeneratedArtifact
847
+ * @property {string} code - Generated output program, including any requested directive.
848
+ * @property {string} filename - Generated output filename.
849
+ * @property {SemanticLanguage} language - Output language.
850
+ * @property {SemantifoldMapping} mapping - Authoritative rich mapping.
851
+ * @property {import("@jridgewell/gen-mapping").EncodedSourceMap} sourceMap - Source Map v3 projection.
852
+ * @property {string} sourceMapFilename - Default external Source Map filename.
853
+ */
854
+ /**
855
+ * @typedef TypeReference
856
+ * @property {"TypeReference"} kind - Node discriminator.
857
+ * @property {SemanticTypeName} name - Normalized type name.
858
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance that survives semantic transforms.
859
+ */
860
+ /**
861
+ * @typedef Parameter
862
+ * @property {"Parameter"} kind - Node discriminator.
863
+ * @property {string} name - Parameter name.
864
+ * @property {TypeReference} type - Parameter type.
865
+ * @property {SourceLocation} location - Source location.
866
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
867
+ */
868
+ /**
869
+ * @typedef IdentifierExpression
870
+ * @property {"IdentifierExpression"} kind - Node discriminator.
871
+ * @property {string} name - Referenced name.
872
+ * @property {SourceLocation} location - Source location.
873
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
874
+ */
875
+ /**
876
+ * @typedef IntegerLiteral
877
+ * @property {"IntegerLiteral"} kind - Node discriminator.
878
+ * @property {number} value - JavaScript-safe integer value.
879
+ * @property {SourceLocation} location - Source location.
880
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
881
+ */
882
+ /**
883
+ * @typedef BooleanLiteral
884
+ * @property {"BooleanLiteral"} kind - Node discriminator.
885
+ * @property {boolean} value - Boolean value.
886
+ * @property {SourceLocation} location - Source location.
887
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
888
+ */
889
+ /**
890
+ * @typedef StringLiteral
891
+ * @property {"StringLiteral"} kind - Node discriminator.
892
+ * @property {string} value - Unicode string value.
893
+ * @property {SourceLocation} location - Source location.
894
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
895
+ */
896
+ /**
897
+ * @typedef UnaryExpression
898
+ * @property {"UnaryExpression"} kind - Node discriminator.
899
+ * @property {SemanticUnaryOperation} operation - Closed semantic operation.
900
+ * @property {Expression} operand - Operand evaluated exactly once.
901
+ * @property {SemanticTypeName} type - Explicit operation result type.
902
+ * @property {SourceLocation} location - Source location.
903
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
904
+ */
905
+ /**
906
+ * @typedef BinaryExpression
907
+ * @property {"BinaryExpression"} kind - Node discriminator.
908
+ * @property {SemanticBinaryOperation} operation - Closed semantic operation.
909
+ * @property {Expression} left - Left operand.
910
+ * @property {Expression} right - Right operand.
911
+ * @property {SemanticTypeName} type - Explicit operation result type.
912
+ * @property {SourceLocation} location - Source location.
913
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
914
+ */
915
+ /**
916
+ * @typedef CallExpression
917
+ * @property {"CallExpression"} kind - Node discriminator.
918
+ * @property {string} callee - Function name.
919
+ * @property {Expression[]} arguments - Positional arguments.
920
+ * @property {SourceLocation} location - Source location.
921
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
922
+ */
923
+ /** @typedef {IdentifierExpression | IntegerLiteral | BooleanLiteral | StringLiteral | UnaryExpression | BinaryExpression | CallExpression} Expression */
924
+ /**
925
+ * @typedef LocalDeclaration
926
+ * @property {"LocalDeclaration"} kind - Node discriminator.
927
+ * @property {string} name - Declared local name.
928
+ * @property {TypeReference} type - Explicit local type.
929
+ * @property {boolean} mutable - Whether later assignment is allowed.
930
+ * @property {Expression} initializer - Required initializer expression.
931
+ * @property {SourceLocation} location - Declaration source location.
932
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
933
+ */
934
+ /**
935
+ * @typedef AssignmentStatement
936
+ * @property {"AssignmentStatement"} kind - Node discriminator.
937
+ * @property {IdentifierExpression} target - Simple local assignment target.
938
+ * @property {Expression} expression - Assigned expression.
939
+ * @property {SourceLocation} location - Assignment source location.
940
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
941
+ */
942
+ /**
943
+ * @typedef ReturnStatement
944
+ * @property {"ReturnStatement"} kind - Node discriminator.
945
+ * @property {Expression} expression - Returned expression.
946
+ * @property {SourceLocation} location - Source location.
947
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
948
+ */
949
+ /**
950
+ * @typedef IfStatement
951
+ * @property {"IfStatement"} kind - Node discriminator.
952
+ * @property {Expression} condition - Branch condition.
953
+ * @property {Block} consequent - True branch.
954
+ * @property {Block} [alternate] - False branch, absent when execution falls through.
955
+ * @property {SourceLocation} location - Source location.
956
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
957
+ */
958
+ /** @typedef {LocalDeclaration | AssignmentStatement} LocalStatement */
959
+ /** @typedef {LocalStatement | IfStatement | ReturnStatement | PrintStatement} Statement */
960
+ /**
961
+ * @typedef Block
962
+ * @property {"Block"} kind - Node discriminator.
963
+ * @property {Statement[]} statements - Ordered statements in one lexical scope.
964
+ * @property {SourceLocation} location - Source location.
965
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
966
+ */
967
+ /**
968
+ * @typedef FunctionDeclaration
969
+ * @property {"FunctionDeclaration"} kind - Node discriminator.
970
+ * @property {string} name - Function name.
971
+ * @property {Parameter[]} parameters - Function parameters.
972
+ * @property {TypeReference} returnType - Return type.
973
+ * @property {Block} body - Function body.
974
+ * @property {SourceLocation} location - Source location.
975
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
976
+ */
977
+ /**
978
+ * @typedef PrintStatement
979
+ * @property {"PrintStatement"} kind - Node discriminator.
980
+ * @property {Expression} expression - Printed expression.
981
+ * @property {SourceLocation} location - Source location.
982
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
983
+ */
984
+ /**
985
+ * @typedef EntryPoint
986
+ * @property {"EntryPoint"} kind - Node discriminator.
987
+ * @property {Block} body - Entry-point body.
988
+ * @property {SourceLocation} location - Source location.
989
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
990
+ */
991
+ /**
992
+ * @typedef SemanticModule
993
+ * @property {"Module"} kind - Node discriminator.
994
+ * @property {FunctionDeclaration[]} functions - Top-level functions.
995
+ * @property {EntryPoint} entryPoint - Executable entry point.
996
+ * @property {SourceLocation} location - Source location.
997
+ * @property {SemanticNodeSourceProvenance} [sourceProvenance] - Node-associated provenance.
998
+ * @property {SemanticProvenance} [provenance] - Parser-authored source and identity index; optional for legacy caller-authored modules.
999
+ */
1000
+ /** @typedef {SemanticModule | FunctionDeclaration | Parameter | Block | Statement | EntryPoint | Expression | TypeReference} SemanticNode */
1001
+ /** @typedef {SemanticNode} SemanticNodeWithoutLocations */
1002
+ export {};
1003
+ //# sourceMappingURL=types.d.ts.map