@prodara/compiler 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 (494) hide show
  1. package/README.md +204 -0
  2. package/dist/agent/agent.d.ts +10 -0
  3. package/dist/agent/agent.d.ts.map +1 -0
  4. package/dist/agent/agent.js +122 -0
  5. package/dist/agent/agent.js.map +1 -0
  6. package/dist/agent/api-client.d.ts +29 -0
  7. package/dist/agent/api-client.d.ts.map +1 -0
  8. package/dist/agent/api-client.js +167 -0
  9. package/dist/agent/api-client.js.map +1 -0
  10. package/dist/agent/index.d.ts +5 -0
  11. package/dist/agent/index.d.ts.map +1 -0
  12. package/dist/agent/index.js +3 -0
  13. package/dist/agent/index.js.map +1 -0
  14. package/dist/agent/party.d.ts +48 -0
  15. package/dist/agent/party.d.ts.map +1 -0
  16. package/dist/agent/party.js +79 -0
  17. package/dist/agent/party.js.map +1 -0
  18. package/dist/agent/types.d.ts +35 -0
  19. package/dist/agent/types.d.ts.map +1 -0
  20. package/dist/agent/types.js +5 -0
  21. package/dist/agent/types.js.map +1 -0
  22. package/dist/audit/audit.d.ts +32 -0
  23. package/dist/audit/audit.d.ts.map +1 -0
  24. package/dist/audit/audit.js +120 -0
  25. package/dist/audit/audit.js.map +1 -0
  26. package/dist/audit/index.d.ts +3 -0
  27. package/dist/audit/index.d.ts.map +1 -0
  28. package/dist/audit/index.js +2 -0
  29. package/dist/audit/index.js.map +1 -0
  30. package/dist/audit/types.d.ts +25 -0
  31. package/dist/audit/types.d.ts.map +1 -0
  32. package/dist/audit/types.js +5 -0
  33. package/dist/audit/types.js.map +1 -0
  34. package/dist/binder/binder.d.ts +34 -0
  35. package/dist/binder/binder.d.ts.map +1 -0
  36. package/dist/binder/binder.js +202 -0
  37. package/dist/binder/binder.js.map +1 -0
  38. package/dist/binder/index.d.ts +3 -0
  39. package/dist/binder/index.d.ts.map +1 -0
  40. package/dist/binder/index.js +2 -0
  41. package/dist/binder/index.js.map +1 -0
  42. package/dist/build-state/build-state.d.ts +40 -0
  43. package/dist/build-state/build-state.d.ts.map +1 -0
  44. package/dist/build-state/build-state.js +180 -0
  45. package/dist/build-state/build-state.js.map +1 -0
  46. package/dist/build-state/index.d.ts +3 -0
  47. package/dist/build-state/index.d.ts.map +1 -0
  48. package/dist/build-state/index.js +2 -0
  49. package/dist/build-state/index.js.map +1 -0
  50. package/dist/checker/index.d.ts +5 -0
  51. package/dist/checker/index.d.ts.map +1 -0
  52. package/dist/checker/index.js +3 -0
  53. package/dist/checker/index.js.map +1 -0
  54. package/dist/checker/type-checker.d.ts +8 -0
  55. package/dist/checker/type-checker.d.ts.map +1 -0
  56. package/dist/checker/type-checker.js +136 -0
  57. package/dist/checker/type-checker.js.map +1 -0
  58. package/dist/checker/validator.d.ts +8 -0
  59. package/dist/checker/validator.d.ts.map +1 -0
  60. package/dist/checker/validator.js +251 -0
  61. package/dist/checker/validator.js.map +1 -0
  62. package/dist/cli/agent-setup.d.ts +27 -0
  63. package/dist/cli/agent-setup.d.ts.map +1 -0
  64. package/dist/cli/agent-setup.js +829 -0
  65. package/dist/cli/agent-setup.js.map +1 -0
  66. package/dist/cli/analyze.d.ts +28 -0
  67. package/dist/cli/analyze.d.ts.map +1 -0
  68. package/dist/cli/analyze.js +188 -0
  69. package/dist/cli/analyze.js.map +1 -0
  70. package/dist/cli/checklist.d.ts +27 -0
  71. package/dist/cli/checklist.d.ts.map +1 -0
  72. package/dist/cli/checklist.js +153 -0
  73. package/dist/cli/checklist.js.map +1 -0
  74. package/dist/cli/compile.d.ts +26 -0
  75. package/dist/cli/compile.d.ts.map +1 -0
  76. package/dist/cli/compile.js +112 -0
  77. package/dist/cli/compile.js.map +1 -0
  78. package/dist/cli/dashboard.d.ts +19 -0
  79. package/dist/cli/dashboard.d.ts.map +1 -0
  80. package/dist/cli/dashboard.js +73 -0
  81. package/dist/cli/dashboard.js.map +1 -0
  82. package/dist/cli/explain.d.ts +23 -0
  83. package/dist/cli/explain.d.ts.map +1 -0
  84. package/dist/cli/explain.js +144 -0
  85. package/dist/cli/explain.js.map +1 -0
  86. package/dist/cli/git.d.ts +14 -0
  87. package/dist/cli/git.d.ts.map +1 -0
  88. package/dist/cli/git.js +44 -0
  89. package/dist/cli/git.js.map +1 -0
  90. package/dist/cli/lifecycle.d.ts +28 -0
  91. package/dist/cli/lifecycle.d.ts.map +1 -0
  92. package/dist/cli/lifecycle.js +82 -0
  93. package/dist/cli/lifecycle.js.map +1 -0
  94. package/dist/cli/main.d.ts +10 -0
  95. package/dist/cli/main.d.ts.map +1 -0
  96. package/dist/cli/main.js +1072 -0
  97. package/dist/cli/main.js.map +1 -0
  98. package/dist/cli/notify.d.ts +13 -0
  99. package/dist/cli/notify.d.ts.map +1 -0
  100. package/dist/cli/notify.js +36 -0
  101. package/dist/cli/notify.js.map +1 -0
  102. package/dist/cli/starters.d.ts +12 -0
  103. package/dist/cli/starters.d.ts.map +1 -0
  104. package/dist/cli/starters.js +439 -0
  105. package/dist/cli/starters.js.map +1 -0
  106. package/dist/config/config.d.ts +194 -0
  107. package/dist/config/config.d.ts.map +1 -0
  108. package/dist/config/config.js +434 -0
  109. package/dist/config/config.js.map +1 -0
  110. package/dist/config/index.d.ts +3 -0
  111. package/dist/config/index.d.ts.map +1 -0
  112. package/dist/config/index.js +5 -0
  113. package/dist/config/index.js.map +1 -0
  114. package/dist/diagnostics/diagnostic.d.ts +44 -0
  115. package/dist/diagnostics/diagnostic.d.ts.map +1 -0
  116. package/dist/diagnostics/diagnostic.js +44 -0
  117. package/dist/diagnostics/diagnostic.js.map +1 -0
  118. package/dist/diagnostics/index.d.ts +4 -0
  119. package/dist/diagnostics/index.d.ts.map +1 -0
  120. package/dist/diagnostics/index.js +3 -0
  121. package/dist/diagnostics/index.js.map +1 -0
  122. package/dist/diagnostics/reporter.d.ts +43 -0
  123. package/dist/diagnostics/reporter.d.ts.map +1 -0
  124. package/dist/diagnostics/reporter.js +74 -0
  125. package/dist/diagnostics/reporter.js.map +1 -0
  126. package/dist/discovery/discovery.d.ts +6 -0
  127. package/dist/discovery/discovery.d.ts.map +1 -0
  128. package/dist/discovery/discovery.js +66 -0
  129. package/dist/discovery/discovery.js.map +1 -0
  130. package/dist/discovery/index.d.ts +2 -0
  131. package/dist/discovery/index.d.ts.map +1 -0
  132. package/dist/discovery/index.js +2 -0
  133. package/dist/discovery/index.js.map +1 -0
  134. package/dist/doc-gen/doc-gen-types.d.ts +174 -0
  135. package/dist/doc-gen/doc-gen-types.d.ts.map +1 -0
  136. package/dist/doc-gen/doc-gen-types.js +7 -0
  137. package/dist/doc-gen/doc-gen-types.js.map +1 -0
  138. package/dist/doc-gen/doc-renderer.d.ts +17 -0
  139. package/dist/doc-gen/doc-renderer.d.ts.map +1 -0
  140. package/dist/doc-gen/doc-renderer.js +65 -0
  141. package/dist/doc-gen/doc-renderer.js.map +1 -0
  142. package/dist/doc-gen/format-helpers.d.ts +18 -0
  143. package/dist/doc-gen/format-helpers.d.ts.map +1 -0
  144. package/dist/doc-gen/format-helpers.js +92 -0
  145. package/dist/doc-gen/format-helpers.js.map +1 -0
  146. package/dist/doc-gen/index.d.ts +5 -0
  147. package/dist/doc-gen/index.d.ts.map +1 -0
  148. package/dist/doc-gen/index.js +5 -0
  149. package/dist/doc-gen/index.js.map +1 -0
  150. package/dist/doc-gen/link-resolver.d.ts +10 -0
  151. package/dist/doc-gen/link-resolver.d.ts.map +1 -0
  152. package/dist/doc-gen/link-resolver.js +87 -0
  153. package/dist/doc-gen/link-resolver.js.map +1 -0
  154. package/dist/doc-gen/mermaid-renderers.d.ts +12 -0
  155. package/dist/doc-gen/mermaid-renderers.d.ts.map +1 -0
  156. package/dist/doc-gen/mermaid-renderers.js +197 -0
  157. package/dist/doc-gen/mermaid-renderers.js.map +1 -0
  158. package/dist/doc-gen/module-renderer.d.ts +6 -0
  159. package/dist/doc-gen/module-renderer.d.ts.map +1 -0
  160. package/dist/doc-gen/module-renderer.js +54 -0
  161. package/dist/doc-gen/module-renderer.js.map +1 -0
  162. package/dist/doc-gen/product-renderer.d.ts +6 -0
  163. package/dist/doc-gen/product-renderer.d.ts.map +1 -0
  164. package/dist/doc-gen/product-renderer.js +101 -0
  165. package/dist/doc-gen/product-renderer.js.map +1 -0
  166. package/dist/doc-gen/section-renderers.d.ts +20 -0
  167. package/dist/doc-gen/section-renderers.d.ts.map +1 -0
  168. package/dist/doc-gen/section-renderers.js +357 -0
  169. package/dist/doc-gen/section-renderers.js.map +1 -0
  170. package/dist/doc-gen/string-resolver.d.ts +8 -0
  171. package/dist/doc-gen/string-resolver.d.ts.map +1 -0
  172. package/dist/doc-gen/string-resolver.js +47 -0
  173. package/dist/doc-gen/string-resolver.js.map +1 -0
  174. package/dist/doc-gen/surface-ascii.d.ts +7 -0
  175. package/dist/doc-gen/surface-ascii.d.ts.map +1 -0
  176. package/dist/doc-gen/surface-ascii.js +87 -0
  177. package/dist/doc-gen/surface-ascii.js.map +1 -0
  178. package/dist/drift/drift.d.ts +16 -0
  179. package/dist/drift/drift.d.ts.map +1 -0
  180. package/dist/drift/drift.js +149 -0
  181. package/dist/drift/drift.js.map +1 -0
  182. package/dist/drift/index.d.ts +3 -0
  183. package/dist/drift/index.d.ts.map +1 -0
  184. package/dist/drift/index.js +2 -0
  185. package/dist/drift/index.js.map +1 -0
  186. package/dist/extensions/index.d.ts +6 -0
  187. package/dist/extensions/index.d.ts.map +1 -0
  188. package/dist/extensions/index.js +7 -0
  189. package/dist/extensions/index.js.map +1 -0
  190. package/dist/extensions/loader.d.ts +21 -0
  191. package/dist/extensions/loader.d.ts.map +1 -0
  192. package/dist/extensions/loader.js +101 -0
  193. package/dist/extensions/loader.js.map +1 -0
  194. package/dist/extensions/marketplace.d.ts +22 -0
  195. package/dist/extensions/marketplace.d.ts.map +1 -0
  196. package/dist/extensions/marketplace.js +40 -0
  197. package/dist/extensions/marketplace.js.map +1 -0
  198. package/dist/extensions/registry.d.ts +45 -0
  199. package/dist/extensions/registry.d.ts.map +1 -0
  200. package/dist/extensions/registry.js +82 -0
  201. package/dist/extensions/registry.js.map +1 -0
  202. package/dist/extensions/types.d.ts +41 -0
  203. package/dist/extensions/types.d.ts.map +1 -0
  204. package/dist/extensions/types.js +5 -0
  205. package/dist/extensions/types.js.map +1 -0
  206. package/dist/generator/contracts.d.ts +67 -0
  207. package/dist/generator/contracts.d.ts.map +1 -0
  208. package/dist/generator/contracts.js +94 -0
  209. package/dist/generator/contracts.js.map +1 -0
  210. package/dist/generator/index.d.ts +3 -0
  211. package/dist/generator/index.d.ts.map +1 -0
  212. package/dist/generator/index.js +2 -0
  213. package/dist/generator/index.js.map +1 -0
  214. package/dist/governance/governance.d.ts +24 -0
  215. package/dist/governance/governance.d.ts.map +1 -0
  216. package/dist/governance/governance.js +238 -0
  217. package/dist/governance/governance.js.map +1 -0
  218. package/dist/governance/index.d.ts +3 -0
  219. package/dist/governance/index.d.ts.map +1 -0
  220. package/dist/governance/index.js +2 -0
  221. package/dist/governance/index.js.map +1 -0
  222. package/dist/governance/types.d.ts +14 -0
  223. package/dist/governance/types.d.ts.map +1 -0
  224. package/dist/governance/types.js +5 -0
  225. package/dist/governance/types.js.map +1 -0
  226. package/dist/graph/builder.d.ts +10 -0
  227. package/dist/graph/builder.d.ts.map +1 -0
  228. package/dist/graph/builder.js +573 -0
  229. package/dist/graph/builder.js.map +1 -0
  230. package/dist/graph/graph-types.d.ts +64 -0
  231. package/dist/graph/graph-types.d.ts.map +1 -0
  232. package/dist/graph/graph-types.js +29 -0
  233. package/dist/graph/graph-types.js.map +1 -0
  234. package/dist/graph/index.d.ts +8 -0
  235. package/dist/graph/index.d.ts.map +1 -0
  236. package/dist/graph/index.js +5 -0
  237. package/dist/graph/index.js.map +1 -0
  238. package/dist/graph/serializer.d.ts +9 -0
  239. package/dist/graph/serializer.d.ts.map +1 -0
  240. package/dist/graph/serializer.js +31 -0
  241. package/dist/graph/serializer.js.map +1 -0
  242. package/dist/graph/validator.d.ts +14 -0
  243. package/dist/graph/validator.d.ts.map +1 -0
  244. package/dist/graph/validator.js +96 -0
  245. package/dist/graph/validator.js.map +1 -0
  246. package/dist/implement/implement.d.ts +30 -0
  247. package/dist/implement/implement.d.ts.map +1 -0
  248. package/dist/implement/implement.js +299 -0
  249. package/dist/implement/implement.js.map +1 -0
  250. package/dist/implement/index.d.ts +3 -0
  251. package/dist/implement/index.d.ts.map +1 -0
  252. package/dist/implement/index.js +2 -0
  253. package/dist/implement/index.js.map +1 -0
  254. package/dist/implement/types.d.ts +41 -0
  255. package/dist/implement/types.d.ts.map +1 -0
  256. package/dist/implement/types.js +5 -0
  257. package/dist/implement/types.js.map +1 -0
  258. package/dist/incremental/incremental-spec.d.ts +12 -0
  259. package/dist/incremental/incremental-spec.d.ts.map +1 -0
  260. package/dist/incremental/incremental-spec.js +100 -0
  261. package/dist/incremental/incremental-spec.js.map +1 -0
  262. package/dist/incremental/index.d.ts +3 -0
  263. package/dist/incremental/index.d.ts.map +1 -0
  264. package/dist/incremental/index.js +5 -0
  265. package/dist/incremental/index.js.map +1 -0
  266. package/dist/incremental/types.d.ts +28 -0
  267. package/dist/incremental/types.d.ts.map +1 -0
  268. package/dist/incremental/types.js +7 -0
  269. package/dist/incremental/types.js.map +1 -0
  270. package/dist/index.d.ts +106 -0
  271. package/dist/index.d.ts.map +1 -0
  272. package/dist/index.js +106 -0
  273. package/dist/index.js.map +1 -0
  274. package/dist/lexer/index.d.ts +6 -0
  275. package/dist/lexer/index.d.ts.map +1 -0
  276. package/dist/lexer/index.js +5 -0
  277. package/dist/lexer/index.js.map +1 -0
  278. package/dist/lexer/keywords.d.ts +3 -0
  279. package/dist/lexer/keywords.d.ts.map +1 -0
  280. package/dist/lexer/keywords.js +142 -0
  281. package/dist/lexer/keywords.js.map +1 -0
  282. package/dist/lexer/lexer.d.ts +19 -0
  283. package/dist/lexer/lexer.d.ts.map +1 -0
  284. package/dist/lexer/lexer.js +286 -0
  285. package/dist/lexer/lexer.js.map +1 -0
  286. package/dist/lexer/source.d.ts +13 -0
  287. package/dist/lexer/source.d.ts.map +1 -0
  288. package/dist/lexer/source.js +59 -0
  289. package/dist/lexer/source.js.map +1 -0
  290. package/dist/lexer/tokens.d.ts +157 -0
  291. package/dist/lexer/tokens.d.ts.map +1 -0
  292. package/dist/lexer/tokens.js +173 -0
  293. package/dist/lexer/tokens.js.map +1 -0
  294. package/dist/orchestrator/index.d.ts +5 -0
  295. package/dist/orchestrator/index.d.ts.map +1 -0
  296. package/dist/orchestrator/index.js +3 -0
  297. package/dist/orchestrator/index.js.map +1 -0
  298. package/dist/orchestrator/orchestrator.d.ts +14 -0
  299. package/dist/orchestrator/orchestrator.d.ts.map +1 -0
  300. package/dist/orchestrator/orchestrator.js +129 -0
  301. package/dist/orchestrator/orchestrator.js.map +1 -0
  302. package/dist/orchestrator/pipeline.d.ts +31 -0
  303. package/dist/orchestrator/pipeline.d.ts.map +1 -0
  304. package/dist/orchestrator/pipeline.js +290 -0
  305. package/dist/orchestrator/pipeline.js.map +1 -0
  306. package/dist/orchestrator/types.d.ts +60 -0
  307. package/dist/orchestrator/types.d.ts.map +1 -0
  308. package/dist/orchestrator/types.js +8 -0
  309. package/dist/orchestrator/types.js.map +1 -0
  310. package/dist/parser/ast.d.ts +502 -0
  311. package/dist/parser/ast.d.ts.map +1 -0
  312. package/dist/parser/ast.js +7 -0
  313. package/dist/parser/ast.js.map +1 -0
  314. package/dist/parser/expressions.d.ts +18 -0
  315. package/dist/parser/expressions.d.ts.map +1 -0
  316. package/dist/parser/expressions.js +230 -0
  317. package/dist/parser/expressions.js.map +1 -0
  318. package/dist/parser/index.d.ts +4 -0
  319. package/dist/parser/index.d.ts.map +1 -0
  320. package/dist/parser/index.js +2 -0
  321. package/dist/parser/index.js.map +1 -0
  322. package/dist/parser/parser.d.ts +83 -0
  323. package/dist/parser/parser.d.ts.map +1 -0
  324. package/dist/parser/parser.js +2149 -0
  325. package/dist/parser/parser.js.map +1 -0
  326. package/dist/planner/differ.d.ts +4 -0
  327. package/dist/planner/differ.d.ts.map +1 -0
  328. package/dist/planner/differ.js +96 -0
  329. package/dist/planner/differ.js.map +1 -0
  330. package/dist/planner/index.d.ts +7 -0
  331. package/dist/planner/index.d.ts.map +1 -0
  332. package/dist/planner/index.js +5 -0
  333. package/dist/planner/index.js.map +1 -0
  334. package/dist/planner/plan-types.d.ts +26 -0
  335. package/dist/planner/plan-types.d.ts.map +1 -0
  336. package/dist/planner/plan-types.js +5 -0
  337. package/dist/planner/plan-types.js.map +1 -0
  338. package/dist/planner/planner.d.ts +8 -0
  339. package/dist/planner/planner.d.ts.map +1 -0
  340. package/dist/planner/planner.js +83 -0
  341. package/dist/planner/planner.js.map +1 -0
  342. package/dist/planner/propagator.d.ts +4 -0
  343. package/dist/planner/propagator.d.ts.map +1 -0
  344. package/dist/planner/propagator.js +45 -0
  345. package/dist/planner/propagator.js.map +1 -0
  346. package/dist/planner/semantic-diff.d.ts +27 -0
  347. package/dist/planner/semantic-diff.d.ts.map +1 -0
  348. package/dist/planner/semantic-diff.js +253 -0
  349. package/dist/planner/semantic-diff.js.map +1 -0
  350. package/dist/presets/index.d.ts +3 -0
  351. package/dist/presets/index.d.ts.map +1 -0
  352. package/dist/presets/index.js +5 -0
  353. package/dist/presets/index.js.map +1 -0
  354. package/dist/presets/loader.d.ts +28 -0
  355. package/dist/presets/loader.d.ts.map +1 -0
  356. package/dist/presets/loader.js +99 -0
  357. package/dist/presets/loader.js.map +1 -0
  358. package/dist/presets/types.d.ts +21 -0
  359. package/dist/presets/types.d.ts.map +1 -0
  360. package/dist/presets/types.js +5 -0
  361. package/dist/presets/types.js.map +1 -0
  362. package/dist/proposal/index.d.ts +3 -0
  363. package/dist/proposal/index.d.ts.map +1 -0
  364. package/dist/proposal/index.js +7 -0
  365. package/dist/proposal/index.js.map +1 -0
  366. package/dist/proposal/proposal.d.ts +9 -0
  367. package/dist/proposal/proposal.d.ts.map +1 -0
  368. package/dist/proposal/proposal.js +169 -0
  369. package/dist/proposal/proposal.js.map +1 -0
  370. package/dist/proposal/types.d.ts +15 -0
  371. package/dist/proposal/types.d.ts.map +1 -0
  372. package/dist/proposal/types.js +5 -0
  373. package/dist/proposal/types.js.map +1 -0
  374. package/dist/registry/index.d.ts +3 -0
  375. package/dist/registry/index.d.ts.map +1 -0
  376. package/dist/registry/index.js +2 -0
  377. package/dist/registry/index.js.map +1 -0
  378. package/dist/registry/resolution.d.ts +39 -0
  379. package/dist/registry/resolution.d.ts.map +1 -0
  380. package/dist/registry/resolution.js +70 -0
  381. package/dist/registry/resolution.js.map +1 -0
  382. package/dist/reviewers/adversarial.d.ts +3 -0
  383. package/dist/reviewers/adversarial.d.ts.map +1 -0
  384. package/dist/reviewers/adversarial.js +111 -0
  385. package/dist/reviewers/adversarial.js.map +1 -0
  386. package/dist/reviewers/architecture.d.ts +3 -0
  387. package/dist/reviewers/architecture.d.ts.map +1 -0
  388. package/dist/reviewers/architecture.js +71 -0
  389. package/dist/reviewers/architecture.js.map +1 -0
  390. package/dist/reviewers/code-quality.d.ts +3 -0
  391. package/dist/reviewers/code-quality.d.ts.map +1 -0
  392. package/dist/reviewers/code-quality.js +72 -0
  393. package/dist/reviewers/code-quality.js.map +1 -0
  394. package/dist/reviewers/edge-case.d.ts +3 -0
  395. package/dist/reviewers/edge-case.d.ts.map +1 -0
  396. package/dist/reviewers/edge-case.js +107 -0
  397. package/dist/reviewers/edge-case.js.map +1 -0
  398. package/dist/reviewers/index.d.ts +21 -0
  399. package/dist/reviewers/index.d.ts.map +1 -0
  400. package/dist/reviewers/index.js +39 -0
  401. package/dist/reviewers/index.js.map +1 -0
  402. package/dist/reviewers/prompt-loader.d.ts +24 -0
  403. package/dist/reviewers/prompt-loader.d.ts.map +1 -0
  404. package/dist/reviewers/prompt-loader.js +67 -0
  405. package/dist/reviewers/prompt-loader.js.map +1 -0
  406. package/dist/reviewers/quality.d.ts +3 -0
  407. package/dist/reviewers/quality.d.ts.map +1 -0
  408. package/dist/reviewers/quality.js +76 -0
  409. package/dist/reviewers/quality.js.map +1 -0
  410. package/dist/reviewers/reviewer.d.ts +39 -0
  411. package/dist/reviewers/reviewer.d.ts.map +1 -0
  412. package/dist/reviewers/reviewer.js +149 -0
  413. package/dist/reviewers/reviewer.js.map +1 -0
  414. package/dist/reviewers/security.d.ts +3 -0
  415. package/dist/reviewers/security.d.ts.map +1 -0
  416. package/dist/reviewers/security.js +87 -0
  417. package/dist/reviewers/security.js.map +1 -0
  418. package/dist/reviewers/specification.d.ts +3 -0
  419. package/dist/reviewers/specification.d.ts.map +1 -0
  420. package/dist/reviewers/specification.js +79 -0
  421. package/dist/reviewers/specification.js.map +1 -0
  422. package/dist/reviewers/test-quality.d.ts +3 -0
  423. package/dist/reviewers/test-quality.d.ts.map +1 -0
  424. package/dist/reviewers/test-quality.js +88 -0
  425. package/dist/reviewers/test-quality.js.map +1 -0
  426. package/dist/reviewers/types.d.ts +32 -0
  427. package/dist/reviewers/types.d.ts.map +1 -0
  428. package/dist/reviewers/types.js +5 -0
  429. package/dist/reviewers/types.js.map +1 -0
  430. package/dist/reviewers/ux.d.ts +3 -0
  431. package/dist/reviewers/ux.d.ts.map +1 -0
  432. package/dist/reviewers/ux.js +94 -0
  433. package/dist/reviewers/ux.js.map +1 -0
  434. package/dist/runtime/index.d.ts +3 -0
  435. package/dist/runtime/index.d.ts.map +1 -0
  436. package/dist/runtime/index.js +2 -0
  437. package/dist/runtime/index.js.map +1 -0
  438. package/dist/runtime/resolution.d.ts +30 -0
  439. package/dist/runtime/resolution.d.ts.map +1 -0
  440. package/dist/runtime/resolution.js +59 -0
  441. package/dist/runtime/resolution.js.map +1 -0
  442. package/dist/testing/index.d.ts +3 -0
  443. package/dist/testing/index.d.ts.map +1 -0
  444. package/dist/testing/index.js +2 -0
  445. package/dist/testing/index.js.map +1 -0
  446. package/dist/testing/test-runner.d.ts +18 -0
  447. package/dist/testing/test-runner.d.ts.map +1 -0
  448. package/dist/testing/test-runner.js +131 -0
  449. package/dist/testing/test-runner.js.map +1 -0
  450. package/dist/types.d.ts +36 -0
  451. package/dist/types.d.ts.map +1 -0
  452. package/dist/types.js +127 -0
  453. package/dist/types.js.map +1 -0
  454. package/dist/validation/index.d.ts +3 -0
  455. package/dist/validation/index.d.ts.map +1 -0
  456. package/dist/validation/index.js +2 -0
  457. package/dist/validation/index.js.map +1 -0
  458. package/dist/validation/types.d.ts +16 -0
  459. package/dist/validation/types.d.ts.map +1 -0
  460. package/dist/validation/types.js +5 -0
  461. package/dist/validation/types.js.map +1 -0
  462. package/dist/validation/validation.d.ts +8 -0
  463. package/dist/validation/validation.d.ts.map +1 -0
  464. package/dist/validation/validation.js +101 -0
  465. package/dist/validation/validation.js.map +1 -0
  466. package/dist/verification/index.d.ts +3 -0
  467. package/dist/verification/index.d.ts.map +1 -0
  468. package/dist/verification/index.js +5 -0
  469. package/dist/verification/index.js.map +1 -0
  470. package/dist/verification/types.d.ts +14 -0
  471. package/dist/verification/types.d.ts.map +1 -0
  472. package/dist/verification/types.js +5 -0
  473. package/dist/verification/types.js.map +1 -0
  474. package/dist/verification/verify.d.ts +7 -0
  475. package/dist/verification/verify.d.ts.map +1 -0
  476. package/dist/verification/verify.js +127 -0
  477. package/dist/verification/verify.js.map +1 -0
  478. package/dist/workflow/clarify.d.ts +7 -0
  479. package/dist/workflow/clarify.d.ts.map +1 -0
  480. package/dist/workflow/clarify.js +165 -0
  481. package/dist/workflow/clarify.js.map +1 -0
  482. package/dist/workflow/engine.d.ts +19 -0
  483. package/dist/workflow/engine.d.ts.map +1 -0
  484. package/dist/workflow/engine.js +265 -0
  485. package/dist/workflow/engine.js.map +1 -0
  486. package/dist/workflow/index.d.ts +6 -0
  487. package/dist/workflow/index.d.ts.map +1 -0
  488. package/dist/workflow/index.js +7 -0
  489. package/dist/workflow/index.js.map +1 -0
  490. package/dist/workflow/types.d.ts +95 -0
  491. package/dist/workflow/types.d.ts.map +1 -0
  492. package/dist/workflow/types.js +18 -0
  493. package/dist/workflow/types.js.map +1 -0
  494. package/package.json +63 -0
@@ -0,0 +1,2149 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Prodara Compiler — Recursive Descent Parser
3
+ // ---------------------------------------------------------------------------
4
+ import { PRIMITIVE_TYPES } from '../types.js';
5
+ import { TokenKind } from '../lexer/tokens.js';
6
+ import { Lexer } from '../lexer/lexer.js';
7
+ import { parseExpression } from './expressions.js';
8
+ export class Parser {
9
+ tokens;
10
+ bag;
11
+ file;
12
+ pos = 0;
13
+ constructor(source, bag) {
14
+ this.file = source.path;
15
+ this.bag = bag;
16
+ const lexer = new Lexer(source, bag);
17
+ this.tokens = lexer.tokenize();
18
+ }
19
+ parse() {
20
+ const declarations = [];
21
+ while (!this.isEof()) {
22
+ const decl = this.parseTopLevel();
23
+ if (decl)
24
+ declarations.push(decl);
25
+ else
26
+ this.advance(); // recovery: skip token
27
+ }
28
+ return { path: this.file, declarations };
29
+ }
30
+ // -----------------------------------------------------------------------
31
+ // Top-level
32
+ // -----------------------------------------------------------------------
33
+ parseTopLevel() {
34
+ const tok = this.peek();
35
+ if (tok.kind === TokenKind.ProductKw)
36
+ return this.parseProduct();
37
+ if (tok.kind === TokenKind.ModuleKw)
38
+ return this.parseModule();
39
+ this.error(tok, `Expected 'product' or 'module', got '${tok.text}'`);
40
+ return null;
41
+ }
42
+ // -----------------------------------------------------------------------
43
+ // Product
44
+ // -----------------------------------------------------------------------
45
+ parseProduct() {
46
+ const start = this.expect(TokenKind.ProductKw);
47
+ const name = this.expectIdentText();
48
+ this.expect(TokenKind.OpenBrace);
49
+ let title;
50
+ let version;
51
+ let description;
52
+ let modules;
53
+ let publishes;
54
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
55
+ const prop = this.peek();
56
+ if (prop.kind === TokenKind.TitleKw) {
57
+ this.advance();
58
+ this.expect(TokenKind.Colon);
59
+ title = this.expectStringValue();
60
+ }
61
+ else if (prop.kind === TokenKind.VersionKw) {
62
+ this.advance();
63
+ this.expect(TokenKind.Colon);
64
+ version = this.expectStringValue();
65
+ }
66
+ else if (prop.kind === TokenKind.DescriptionKw) {
67
+ this.advance();
68
+ this.expect(TokenKind.Colon);
69
+ description = this.expectStringValue();
70
+ }
71
+ else if (prop.kind === TokenKind.ModulesKw) {
72
+ this.advance();
73
+ this.expect(TokenKind.Colon);
74
+ modules = this.parseIdentList();
75
+ }
76
+ else if (prop.kind === TokenKind.PublishesKw) {
77
+ this.advance();
78
+ this.expect(TokenKind.OpenBrace);
79
+ const entries = [];
80
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
81
+ const cat = this.expectIdentText();
82
+ this.expect(TokenKind.Colon);
83
+ const syms = this.parseSymbolRefList();
84
+ entries.push({ category: cat, symbols: syms });
85
+ }
86
+ this.expect(TokenKind.CloseBrace);
87
+ publishes = { entries };
88
+ }
89
+ else {
90
+ this.error(prop, `Unexpected property in product: '${prop.text}'`);
91
+ this.advance();
92
+ }
93
+ }
94
+ this.expect(TokenKind.CloseBrace);
95
+ return { kind: 'product', name, title, version, description, modules, publishes, location: this.loc(start) };
96
+ }
97
+ // -----------------------------------------------------------------------
98
+ // Module
99
+ // -----------------------------------------------------------------------
100
+ parseModule() {
101
+ const start = this.expect(TokenKind.ModuleKw);
102
+ const name = this.expectIdentText();
103
+ this.expect(TokenKind.OpenBrace);
104
+ const items = [];
105
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
106
+ const item = this.parseModuleItem();
107
+ if (item)
108
+ items.push(item);
109
+ else
110
+ this.advance();
111
+ }
112
+ this.expect(TokenKind.CloseBrace);
113
+ return { kind: 'module', name, items, location: this.loc(start) };
114
+ }
115
+ parseModuleItem() {
116
+ const tok = this.peek();
117
+ switch (tok.kind) {
118
+ case TokenKind.ImportKw: return this.parseImport();
119
+ case TokenKind.EntityKw: return this.parseEntity();
120
+ case TokenKind.ValueKw: return this.parseValue();
121
+ case TokenKind.EnumKw: return this.parseEnum();
122
+ case TokenKind.RuleKw: return this.parseRule();
123
+ case TokenKind.ActorKw: return this.parseActor();
124
+ case TokenKind.CapabilityKw: return this.parseCapability();
125
+ case TokenKind.WorkflowKw: return this.parseWorkflow();
126
+ case TokenKind.ActionKw: return this.parseAction();
127
+ case TokenKind.EventKw: return this.parseEvent();
128
+ case TokenKind.ScheduleKw: return this.parseSchedule();
129
+ case TokenKind.SurfaceKw: return this.parseSurface();
130
+ case TokenKind.RenderingKw: return this.parseRendering();
131
+ case TokenKind.TokensKw: return this.parseTokens();
132
+ case TokenKind.ThemeKw: return this.parseTheme();
133
+ case TokenKind.StringsKw: return this.parseStrings();
134
+ case TokenKind.SerializationKw: return this.parseSerialization();
135
+ case TokenKind.IntegrationKw: return this.parseIntegration();
136
+ case TokenKind.TransportKw: return this.parseTransport();
137
+ case TokenKind.StorageKw: return this.parseStorage();
138
+ case TokenKind.ExecutionKw: return this.parseExecution();
139
+ case TokenKind.ExtensionKw: return this.parseExtension();
140
+ case TokenKind.ConstitutionKw: return this.parseConstitution();
141
+ case TokenKind.SecurityKw: return this.parseSecurity();
142
+ case TokenKind.PrivacyKw: return this.parsePrivacy();
143
+ case TokenKind.ValidationKw: return this.parseValidation();
144
+ case TokenKind.SecretKw: return this.parseSecret();
145
+ case TokenKind.EnvironmentKw: return this.parseEnvironment();
146
+ case TokenKind.DeploymentKw: return this.parseDeployment();
147
+ case TokenKind.TestKw: return this.parseTest();
148
+ case TokenKind.ProductRefKw: return this.parseProductRef();
149
+ default:
150
+ this.error(tok, `Expected module item, got '${tok.text}'`);
151
+ return null;
152
+ }
153
+ }
154
+ // -----------------------------------------------------------------------
155
+ // Import
156
+ // -----------------------------------------------------------------------
157
+ parseImport() {
158
+ const start = this.expect(TokenKind.ImportKw);
159
+ const symbol = this.expectIdentText();
160
+ let alias;
161
+ if (this.check(TokenKind.AsKw)) {
162
+ this.advance();
163
+ alias = this.expectIdentText();
164
+ }
165
+ this.expect(TokenKind.FromKw);
166
+ const from = this.expectIdentText();
167
+ return { kind: 'import', symbol, alias, from, location: this.loc(start) };
168
+ }
169
+ // -----------------------------------------------------------------------
170
+ // Domain: entity, value, enum, rule
171
+ // -----------------------------------------------------------------------
172
+ parseEntity() {
173
+ const start = this.expect(TokenKind.EntityKw);
174
+ const name = this.expectIdentText();
175
+ this.expect(TokenKind.OpenBrace);
176
+ const fields = this.parseFieldList();
177
+ this.expect(TokenKind.CloseBrace);
178
+ return { kind: 'entity', name, fields, location: this.loc(start) };
179
+ }
180
+ parseValue() {
181
+ const start = this.expect(TokenKind.ValueKw);
182
+ const name = this.expectIdentText();
183
+ this.expect(TokenKind.OpenBrace);
184
+ const fields = this.parseFieldList();
185
+ this.expect(TokenKind.CloseBrace);
186
+ return { kind: 'value', name, fields, location: this.loc(start) };
187
+ }
188
+ parseEnum() {
189
+ const start = this.expect(TokenKind.EnumKw);
190
+ const name = this.expectIdentText();
191
+ this.expect(TokenKind.OpenBrace);
192
+ const members = [];
193
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
194
+ const memTok = this.peek();
195
+ const memName = this.expectIdentText();
196
+ let metadata;
197
+ if (this.check(TokenKind.OpenBrace)) {
198
+ this.advance();
199
+ metadata = [];
200
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
201
+ const key = this.expectIdentText();
202
+ this.expect(TokenKind.Colon);
203
+ const val = this.parseValueNode();
204
+ metadata.push({ key, value: val });
205
+ }
206
+ this.expect(TokenKind.CloseBrace);
207
+ }
208
+ members.push({ name: memName, metadata, location: this.loc(memTok) });
209
+ }
210
+ this.expect(TokenKind.CloseBrace);
211
+ return { kind: 'enum', name, members, location: this.loc(start) };
212
+ }
213
+ parseRule() {
214
+ const start = this.expect(TokenKind.RuleKw);
215
+ const name = this.expectIdentText();
216
+ this.expect(TokenKind.OpenBrace);
217
+ let entity = [];
218
+ let condition;
219
+ let message = [];
220
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
221
+ const prop = this.peek();
222
+ if (prop.kind === TokenKind.EntityKw) {
223
+ this.advance();
224
+ this.expect(TokenKind.Colon);
225
+ entity = this.parseSymbolRef();
226
+ }
227
+ else if (prop.kind === TokenKind.ConditionKw) {
228
+ this.advance();
229
+ this.expect(TokenKind.Colon);
230
+ condition = this.parseExpressionUntilNewline();
231
+ }
232
+ else if (prop.kind === TokenKind.MessageKw) {
233
+ this.advance();
234
+ this.expect(TokenKind.Colon);
235
+ message = this.parseSymbolRef();
236
+ }
237
+ else {
238
+ this.error(prop, `Unexpected property in rule: '${prop.text}'`);
239
+ this.advance();
240
+ }
241
+ }
242
+ this.expect(TokenKind.CloseBrace);
243
+ const fallbackCondition = condition ?? {
244
+ kind: 'literal', value: true, literalType: 'boolean',
245
+ location: this.loc(start),
246
+ };
247
+ return { kind: 'rule', name, entity, condition: fallbackCondition, message, location: this.loc(start) };
248
+ }
249
+ // -----------------------------------------------------------------------
250
+ // Actors / Capabilities
251
+ // -----------------------------------------------------------------------
252
+ parseActor() {
253
+ const start = this.expect(TokenKind.ActorKw);
254
+ const name = this.expectIdentText();
255
+ this.expect(TokenKind.OpenBrace);
256
+ let title;
257
+ let description;
258
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
259
+ const p = this.peek();
260
+ if (p.kind === TokenKind.TitleKw) {
261
+ this.advance();
262
+ this.expect(TokenKind.Colon);
263
+ title = this.expectStringValue();
264
+ }
265
+ else if (p.kind === TokenKind.DescriptionKw) {
266
+ this.advance();
267
+ this.expect(TokenKind.Colon);
268
+ description = this.expectStringValue();
269
+ }
270
+ else {
271
+ this.error(p, `Unexpected property in actor: '${p.text}'`);
272
+ this.advance();
273
+ }
274
+ }
275
+ this.expect(TokenKind.CloseBrace);
276
+ return { kind: 'actor', name, title, description, location: this.loc(start) };
277
+ }
278
+ parseCapability() {
279
+ const start = this.expect(TokenKind.CapabilityKw);
280
+ const name = this.expectIdentText();
281
+ this.expect(TokenKind.OpenBrace);
282
+ let title;
283
+ let description;
284
+ let actors;
285
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
286
+ const p = this.peek();
287
+ if (p.kind === TokenKind.TitleKw) {
288
+ this.advance();
289
+ this.expect(TokenKind.Colon);
290
+ title = this.expectStringValue();
291
+ }
292
+ else if (p.kind === TokenKind.DescriptionKw) {
293
+ this.advance();
294
+ this.expect(TokenKind.Colon);
295
+ description = this.expectStringValue();
296
+ }
297
+ else if (p.kind === TokenKind.ActorsKw) {
298
+ this.advance();
299
+ this.expect(TokenKind.Colon);
300
+ actors = this.parseSymbolRefList();
301
+ }
302
+ else {
303
+ this.error(p, `Unexpected property in capability: '${p.text}'`);
304
+ this.advance();
305
+ }
306
+ }
307
+ this.expect(TokenKind.CloseBrace);
308
+ return { kind: 'capability', name, title, description, actors, location: this.loc(start) };
309
+ }
310
+ // -----------------------------------------------------------------------
311
+ // Workflow
312
+ // -----------------------------------------------------------------------
313
+ parseWorkflow() {
314
+ const start = this.expect(TokenKind.WorkflowKw);
315
+ const name = this.expectIdentText();
316
+ this.expect(TokenKind.OpenBrace);
317
+ let capability;
318
+ let authorization;
319
+ let input;
320
+ let reads;
321
+ let writes;
322
+ let rules;
323
+ let steps;
324
+ let transitions;
325
+ let effects;
326
+ let returns;
327
+ let trigger;
328
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
329
+ const p = this.peek();
330
+ if (p.kind === TokenKind.CapabilityKw) {
331
+ this.advance();
332
+ this.expect(TokenKind.Colon);
333
+ capability = this.parseSymbolRef();
334
+ }
335
+ else if (p.kind === TokenKind.AuthorizationKw) {
336
+ this.advance();
337
+ this.expect(TokenKind.OpenBrace);
338
+ authorization = [];
339
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
340
+ const actor = this.expectIdentText();
341
+ this.expect(TokenKind.Colon);
342
+ const perms = this.parsePermissionList();
343
+ authorization.push({ actor, permissions: perms });
344
+ }
345
+ this.expect(TokenKind.CloseBrace);
346
+ }
347
+ else if (p.kind === TokenKind.InputKw) {
348
+ this.advance();
349
+ this.expect(TokenKind.OpenBrace);
350
+ input = [...this.parseFieldList()];
351
+ this.expect(TokenKind.CloseBrace);
352
+ }
353
+ else if (p.kind === TokenKind.ReadsKw) {
354
+ this.advance();
355
+ this.expect(TokenKind.OpenBrace);
356
+ reads = this.parseSymbolRefBlock();
357
+ this.expect(TokenKind.CloseBrace);
358
+ }
359
+ else if (p.kind === TokenKind.WritesKw) {
360
+ this.advance();
361
+ this.expect(TokenKind.OpenBrace);
362
+ writes = this.parseSymbolRefBlock();
363
+ this.expect(TokenKind.CloseBrace);
364
+ }
365
+ else if (p.kind === TokenKind.RulesKw) {
366
+ this.advance();
367
+ this.expect(TokenKind.OpenBrace);
368
+ rules = this.parseSymbolRefBlock();
369
+ this.expect(TokenKind.CloseBrace);
370
+ }
371
+ else if (p.kind === TokenKind.StepsKw) {
372
+ this.advance();
373
+ this.expect(TokenKind.OpenBrace);
374
+ steps = this.parseSteps();
375
+ this.expect(TokenKind.CloseBrace);
376
+ }
377
+ else if (p.kind === TokenKind.TransitionsKw) {
378
+ this.advance();
379
+ this.expect(TokenKind.OpenBrace);
380
+ transitions = this.parseTransitions();
381
+ this.expect(TokenKind.CloseBrace);
382
+ }
383
+ else if (p.kind === TokenKind.EffectsKw) {
384
+ this.advance();
385
+ this.expect(TokenKind.OpenBrace);
386
+ effects = this.parseEffects();
387
+ this.expect(TokenKind.CloseBrace);
388
+ }
389
+ else if (p.kind === TokenKind.ReturnsKw) {
390
+ this.advance();
391
+ this.expect(TokenKind.OpenBrace);
392
+ returns = [];
393
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
394
+ const rname = this.expectIdentText();
395
+ this.expect(TokenKind.Colon);
396
+ const rtype = this.parseType();
397
+ returns.push({ name: rname, type: rtype });
398
+ }
399
+ this.expect(TokenKind.CloseBrace);
400
+ }
401
+ else if (p.kind === TokenKind.OnKw) {
402
+ this.advance();
403
+ this.expect(TokenKind.Colon);
404
+ trigger = this.parseSymbolRef();
405
+ }
406
+ else {
407
+ this.error(p, `Unexpected property in workflow: '${p.text}'`);
408
+ this.advance();
409
+ }
410
+ }
411
+ this.expect(TokenKind.CloseBrace);
412
+ return {
413
+ kind: 'workflow', name, capability, authorization, input, reads, writes,
414
+ rules, steps, transitions, effects, returns, trigger,
415
+ location: this.loc(start),
416
+ };
417
+ }
418
+ // -----------------------------------------------------------------------
419
+ // Action / Event / Schedule
420
+ // -----------------------------------------------------------------------
421
+ parseAction() {
422
+ const start = this.expect(TokenKind.ActionKw);
423
+ const name = this.expectIdentText();
424
+ this.expect(TokenKind.OpenBrace);
425
+ let title;
426
+ let workflow;
427
+ let description;
428
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
429
+ const p = this.peek();
430
+ if (p.kind === TokenKind.TitleKw) {
431
+ this.advance();
432
+ this.expect(TokenKind.Colon);
433
+ title = this.expectStringValue();
434
+ }
435
+ else if (p.kind === TokenKind.WorkflowKw) {
436
+ this.advance();
437
+ this.expect(TokenKind.Colon);
438
+ workflow = this.parseSymbolRef();
439
+ }
440
+ else if (p.kind === TokenKind.DescriptionKw) {
441
+ this.advance();
442
+ this.expect(TokenKind.Colon);
443
+ description = this.expectStringValue();
444
+ }
445
+ else {
446
+ this.error(p, `Unexpected property in action: '${p.text}'`);
447
+ this.advance();
448
+ }
449
+ }
450
+ this.expect(TokenKind.CloseBrace);
451
+ return { kind: 'action', name, title, workflow, description, location: this.loc(start) };
452
+ }
453
+ parseEvent() {
454
+ const start = this.expect(TokenKind.EventKw);
455
+ const name = this.expectIdentText();
456
+ this.expect(TokenKind.OpenBrace);
457
+ let payload;
458
+ let description;
459
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
460
+ const p = this.peek();
461
+ if (p.kind === TokenKind.PayloadKw) {
462
+ this.advance();
463
+ this.expect(TokenKind.Colon);
464
+ payload = this.parseType();
465
+ }
466
+ else if (p.kind === TokenKind.DescriptionKw) {
467
+ this.advance();
468
+ this.expect(TokenKind.Colon);
469
+ description = this.expectStringValue();
470
+ }
471
+ else {
472
+ this.error(p, `Unexpected property in event: '${p.text}'`);
473
+ this.advance();
474
+ }
475
+ }
476
+ this.expect(TokenKind.CloseBrace);
477
+ return { kind: 'event', name, payload, description, location: this.loc(start) };
478
+ }
479
+ parseSchedule() {
480
+ const start = this.expect(TokenKind.ScheduleKw);
481
+ const name = this.expectIdentText();
482
+ this.expect(TokenKind.OpenBrace);
483
+ let cron;
484
+ let description;
485
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
486
+ const p = this.peek();
487
+ if (p.kind === TokenKind.CronKw) {
488
+ this.advance();
489
+ this.expect(TokenKind.Colon);
490
+ cron = this.expectStringValue();
491
+ }
492
+ else if (p.kind === TokenKind.DescriptionKw) {
493
+ this.advance();
494
+ this.expect(TokenKind.Colon);
495
+ description = this.expectStringValue();
496
+ }
497
+ else {
498
+ this.error(p, `Unexpected property in schedule: '${p.text}'`);
499
+ this.advance();
500
+ }
501
+ }
502
+ this.expect(TokenKind.CloseBrace);
503
+ return { kind: 'schedule', name, cron, description, location: this.loc(start) };
504
+ }
505
+ // -----------------------------------------------------------------------
506
+ // Surface
507
+ // -----------------------------------------------------------------------
508
+ parseSurface() {
509
+ const start = this.expect(TokenKind.SurfaceKw);
510
+ const name = this.expectIdentText();
511
+ this.expect(TokenKind.OpenBrace);
512
+ let surfaceKind;
513
+ let title;
514
+ let description;
515
+ let capability;
516
+ let binds;
517
+ let serialization;
518
+ let surfaces;
519
+ let actions;
520
+ let rules;
521
+ let hooks;
522
+ let fields;
523
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
524
+ const p = this.peek();
525
+ if (p.kind === TokenKind.KindKw) {
526
+ this.advance();
527
+ this.expect(TokenKind.Colon);
528
+ surfaceKind = this.expectIdentText();
529
+ }
530
+ else if (p.kind === TokenKind.TitleKw) {
531
+ this.advance();
532
+ this.expect(TokenKind.Colon);
533
+ if (this.check(TokenKind.StringLiteral)) {
534
+ title = this.expectStringValue();
535
+ }
536
+ else {
537
+ title = this.parseSymbolRef();
538
+ }
539
+ }
540
+ else if (p.kind === TokenKind.DescriptionKw) {
541
+ this.advance();
542
+ this.expect(TokenKind.Colon);
543
+ description = this.expectStringValue();
544
+ }
545
+ else if (p.kind === TokenKind.CapabilityKw) {
546
+ this.advance();
547
+ this.expect(TokenKind.Colon);
548
+ capability = this.parseSymbolRef();
549
+ }
550
+ else if (p.kind === TokenKind.BindsKw) {
551
+ this.advance();
552
+ this.expect(TokenKind.Colon);
553
+ binds = this.parseSymbolRef();
554
+ }
555
+ else if (p.kind === TokenKind.SerializationKw) {
556
+ this.advance();
557
+ this.expect(TokenKind.Colon);
558
+ serialization = this.parseSymbolRef();
559
+ }
560
+ else if (p.kind === TokenKind.SurfaceKw) { /* nested 'surfaces' is a keyword collision — use plural */
561
+ this.advance();
562
+ this.expect(TokenKind.Colon);
563
+ surfaces = this.parseSymbolRefList();
564
+ }
565
+ else if (p.kind === TokenKind.ActionsKw) {
566
+ this.advance();
567
+ this.expect(TokenKind.Colon);
568
+ actions = this.parseSymbolRefList();
569
+ }
570
+ else if (p.kind === TokenKind.RulesKw) {
571
+ this.advance();
572
+ this.expect(TokenKind.Colon);
573
+ rules = this.parseSymbolRefList();
574
+ }
575
+ else if (p.kind === TokenKind.HooksKw) {
576
+ this.advance();
577
+ this.expect(TokenKind.OpenBrace);
578
+ hooks = [];
579
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
580
+ const hname = this.expectIdentText();
581
+ this.expect(TokenKind.Colon);
582
+ const htarget = this.parseSymbolRef();
583
+ hooks.push({ name: hname, target: htarget });
584
+ }
585
+ this.expect(TokenKind.CloseBrace);
586
+ }
587
+ else if (p.kind === TokenKind.FieldsKw) {
588
+ this.advance();
589
+ this.expect(TokenKind.OpenBrace);
590
+ fields = [...this.parseFieldList()];
591
+ this.expect(TokenKind.CloseBrace);
592
+ }
593
+ else {
594
+ this.error(p, `Unexpected property in surface: '${p.text}'`);
595
+ this.advance();
596
+ }
597
+ }
598
+ this.expect(TokenKind.CloseBrace);
599
+ return {
600
+ kind: 'surface', name, surfaceKind, title, description, capability,
601
+ binds, serialization, surfaces, actions, rules, hooks, fields,
602
+ location: this.loc(start),
603
+ };
604
+ }
605
+ // -----------------------------------------------------------------------
606
+ // Rendering (simplified — handles target, platform, layout, grid, placement, style)
607
+ // -----------------------------------------------------------------------
608
+ parseRendering() {
609
+ const start = this.expect(TokenKind.RenderingKw);
610
+ const name = this.expectIdentText();
611
+ this.expect(TokenKind.OpenBrace);
612
+ let target;
613
+ let platform;
614
+ let layout;
615
+ let grid;
616
+ let placements;
617
+ let styles;
618
+ let bindings;
619
+ let components;
620
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
621
+ const p = this.peek();
622
+ if (p.kind === TokenKind.TargetKw) {
623
+ this.advance();
624
+ this.expect(TokenKind.Colon);
625
+ target = this.parseSymbolRef();
626
+ }
627
+ else if (p.kind === TokenKind.PlatformKw) {
628
+ this.advance();
629
+ this.expect(TokenKind.Colon);
630
+ platform = this.expectIdentText();
631
+ }
632
+ else if (p.kind === TokenKind.LayoutKw) {
633
+ this.advance();
634
+ this.expect(TokenKind.Colon);
635
+ layout = this.expectIdentText();
636
+ }
637
+ else if (p.kind === TokenKind.GridKw) {
638
+ this.advance();
639
+ this.expect(TokenKind.OpenBrace);
640
+ grid = this.parseGridBlock();
641
+ this.expect(TokenKind.CloseBrace);
642
+ }
643
+ else if (p.kind === TokenKind.PlacementKw) {
644
+ this.advance();
645
+ this.expect(TokenKind.OpenBrace);
646
+ placements = this.parsePlacementBlock();
647
+ this.expect(TokenKind.CloseBrace);
648
+ }
649
+ else if (p.kind === TokenKind.StyleKw) {
650
+ this.advance();
651
+ this.expect(TokenKind.OpenBrace);
652
+ styles = this.parseStyleBlock();
653
+ this.expect(TokenKind.CloseBrace);
654
+ }
655
+ else if (p.kind === TokenKind.BindKw) {
656
+ this.advance();
657
+ this.expect(TokenKind.OpenBrace);
658
+ bindings = this.parseBindBlock();
659
+ this.expect(TokenKind.CloseBrace);
660
+ }
661
+ else if (p.kind === TokenKind.ComponentsKw) {
662
+ this.advance();
663
+ this.expect(TokenKind.Colon);
664
+ components = this.parseSymbolRefList();
665
+ }
666
+ else {
667
+ this.error(p, `Unexpected property in rendering: '${p.text}'`);
668
+ this.advance();
669
+ }
670
+ }
671
+ this.expect(TokenKind.CloseBrace);
672
+ return {
673
+ kind: 'rendering', name, target, platform, layout, grid, placements,
674
+ styles, bindings, components, location: this.loc(start),
675
+ };
676
+ }
677
+ // -----------------------------------------------------------------------
678
+ // Design: tokens, theme, strings
679
+ // -----------------------------------------------------------------------
680
+ parseTokens() {
681
+ const start = this.expect(TokenKind.TokensKw);
682
+ const name = this.expectIdentText();
683
+ this.expect(TokenKind.OpenBrace);
684
+ const categories = [];
685
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
686
+ const catName = this.expectIdentText();
687
+ this.expect(TokenKind.Colon);
688
+ this.expect(TokenKind.OpenBrace);
689
+ const tokens = [];
690
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
691
+ const tName = this.expectIdentText();
692
+ this.expect(TokenKind.Colon);
693
+ const tVal = this.parseValueNode();
694
+ tokens.push({ name: tName, value: tVal });
695
+ }
696
+ this.expect(TokenKind.CloseBrace);
697
+ categories.push({ name: catName, tokens });
698
+ }
699
+ this.expect(TokenKind.CloseBrace);
700
+ return { kind: 'tokens', name, categories, location: this.loc(start) };
701
+ }
702
+ parseTheme() {
703
+ const start = this.expect(TokenKind.ThemeKw);
704
+ const name = this.expectIdentText();
705
+ this.expect(TokenKind.OpenBrace);
706
+ let extendsName = '';
707
+ if (this.check(TokenKind.ExtendsKw)) {
708
+ this.advance();
709
+ this.expect(TokenKind.Colon);
710
+ extendsName = this.expectIdentText();
711
+ }
712
+ const overrides = [];
713
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
714
+ const catName = this.expectIdentText();
715
+ this.expect(TokenKind.Colon);
716
+ this.expect(TokenKind.OpenBrace);
717
+ const tokens = [];
718
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
719
+ const tName = this.expectIdentText();
720
+ this.expect(TokenKind.Colon);
721
+ const tVal = this.parseValueNode();
722
+ tokens.push({ name: tName, value: tVal });
723
+ }
724
+ this.expect(TokenKind.CloseBrace);
725
+ overrides.push({ name: catName, tokens });
726
+ }
727
+ this.expect(TokenKind.CloseBrace);
728
+ return { kind: 'theme', name, extends: extendsName, overrides, location: this.loc(start) };
729
+ }
730
+ parseStrings() {
731
+ const start = this.expect(TokenKind.StringsKw);
732
+ const name = this.expectIdentText();
733
+ this.expect(TokenKind.OpenBrace);
734
+ const entries = [];
735
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
736
+ const key = this.expectIdentText();
737
+ this.expect(TokenKind.Colon);
738
+ const val = this.expectStringValue();
739
+ entries.push({ key, value: val });
740
+ }
741
+ this.expect(TokenKind.CloseBrace);
742
+ return { kind: 'strings', name, entries, location: this.loc(start) };
743
+ }
744
+ // -----------------------------------------------------------------------
745
+ // Serialization
746
+ // -----------------------------------------------------------------------
747
+ parseSerialization() {
748
+ const start = this.expect(TokenKind.SerializationKw);
749
+ const name = this.expectIdentText();
750
+ this.expect(TokenKind.OpenBrace);
751
+ const properties = [];
752
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
753
+ const key = this.expectIdentText();
754
+ this.expect(TokenKind.Colon);
755
+ const val = this.parseValueNode();
756
+ properties.push({ key, value: val });
757
+ }
758
+ this.expect(TokenKind.CloseBrace);
759
+ return { kind: 'serialization', name, properties, location: this.loc(start) };
760
+ }
761
+ // -----------------------------------------------------------------------
762
+ // Integration
763
+ // -----------------------------------------------------------------------
764
+ parseIntegration() {
765
+ const start = this.expect(TokenKind.IntegrationKw);
766
+ const name = this.expectIdentText();
767
+ this.expect(TokenKind.OpenBrace);
768
+ let title;
769
+ let description;
770
+ let integrationKind;
771
+ let protocol;
772
+ let ser;
773
+ let auth;
774
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
775
+ const p = this.peek();
776
+ if (p.kind === TokenKind.TitleKw) {
777
+ this.advance();
778
+ this.expect(TokenKind.Colon);
779
+ title = this.expectStringValue();
780
+ }
781
+ else if (p.kind === TokenKind.DescriptionKw) {
782
+ this.advance();
783
+ this.expect(TokenKind.Colon);
784
+ description = this.expectStringValue();
785
+ }
786
+ else if (p.kind === TokenKind.KindKw) {
787
+ this.advance();
788
+ this.expect(TokenKind.Colon);
789
+ integrationKind = this.expectIdentText();
790
+ }
791
+ else if (p.kind === TokenKind.ProtocolKw) {
792
+ this.advance();
793
+ this.expect(TokenKind.Colon);
794
+ protocol = this.expectIdentText();
795
+ }
796
+ else if (p.kind === TokenKind.SerializationKw) {
797
+ this.advance();
798
+ this.expect(TokenKind.Colon);
799
+ ser = this.parseSymbolRef();
800
+ }
801
+ else if (p.kind === TokenKind.AuthKw) {
802
+ this.advance();
803
+ this.expect(TokenKind.OpenBrace);
804
+ auth = [];
805
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
806
+ const k = this.expectIdentText();
807
+ this.expect(TokenKind.Colon);
808
+ const v = this.parseValueNode();
809
+ auth.push({ key: k, value: v });
810
+ }
811
+ this.expect(TokenKind.CloseBrace);
812
+ }
813
+ else {
814
+ this.error(p, `Unexpected property in integration: '${p.text}'`);
815
+ this.advance();
816
+ }
817
+ }
818
+ this.expect(TokenKind.CloseBrace);
819
+ return { kind: 'integration', name, title, description, integrationKind, protocol, serialization: ser, auth, location: this.loc(start) };
820
+ }
821
+ // -----------------------------------------------------------------------
822
+ // Platform: transport, storage, execution, extension
823
+ // -----------------------------------------------------------------------
824
+ parseTransport() {
825
+ const start = this.expect(TokenKind.TransportKw);
826
+ const name = this.expectIdentText();
827
+ this.expect(TokenKind.OpenBrace);
828
+ let target;
829
+ let protocol;
830
+ let style;
831
+ let description;
832
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
833
+ const p = this.peek();
834
+ if (p.kind === TokenKind.TargetKw) {
835
+ this.advance();
836
+ this.expect(TokenKind.Colon);
837
+ target = this.parseSymbolRef();
838
+ }
839
+ else if (p.kind === TokenKind.ProtocolKw) {
840
+ this.advance();
841
+ this.expect(TokenKind.Colon);
842
+ protocol = this.expectIdentText();
843
+ }
844
+ else if (p.kind === TokenKind.StyleKw) {
845
+ this.advance();
846
+ this.expect(TokenKind.Colon);
847
+ style = this.expectIdentText();
848
+ }
849
+ else if (p.kind === TokenKind.DescriptionKw) {
850
+ this.advance();
851
+ this.expect(TokenKind.Colon);
852
+ description = this.expectStringValue();
853
+ }
854
+ else {
855
+ this.error(p, `Unexpected in transport: '${p.text}'`);
856
+ this.advance();
857
+ }
858
+ }
859
+ this.expect(TokenKind.CloseBrace);
860
+ return { kind: 'transport', name, target, protocol, style, description, location: this.loc(start) };
861
+ }
862
+ parseStorage() {
863
+ const start = this.expect(TokenKind.StorageKw);
864
+ const name = this.expectIdentText();
865
+ this.expect(TokenKind.OpenBrace);
866
+ let target;
867
+ let model;
868
+ let table;
869
+ let indexes;
870
+ let description;
871
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
872
+ const p = this.peek();
873
+ if (p.kind === TokenKind.TargetKw) {
874
+ this.advance();
875
+ this.expect(TokenKind.Colon);
876
+ target = this.parseSymbolRef();
877
+ }
878
+ else if (p.kind === TokenKind.ModelKw) {
879
+ this.advance();
880
+ this.expect(TokenKind.Colon);
881
+ model = this.expectIdentText();
882
+ }
883
+ else if (p.kind === TokenKind.TableKw) {
884
+ this.advance();
885
+ this.expect(TokenKind.Colon);
886
+ table = this.expectStringValue();
887
+ }
888
+ else if (p.kind === TokenKind.IndexesKw) {
889
+ this.advance();
890
+ this.expect(TokenKind.Colon);
891
+ indexes = this.parseIndexList();
892
+ }
893
+ else if (p.kind === TokenKind.DescriptionKw) {
894
+ this.advance();
895
+ this.expect(TokenKind.Colon);
896
+ description = this.expectStringValue();
897
+ }
898
+ else {
899
+ this.error(p, `Unexpected in storage: '${p.text}'`);
900
+ this.advance();
901
+ }
902
+ }
903
+ this.expect(TokenKind.CloseBrace);
904
+ return { kind: 'storage', name, target, model, table, indexes, description, location: this.loc(start) };
905
+ }
906
+ parseExecution() {
907
+ const start = this.expect(TokenKind.ExecutionKw);
908
+ const name = this.expectIdentText();
909
+ this.expect(TokenKind.OpenBrace);
910
+ let target;
911
+ let mode;
912
+ let description;
913
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
914
+ const p = this.peek();
915
+ if (p.kind === TokenKind.TargetKw) {
916
+ this.advance();
917
+ this.expect(TokenKind.Colon);
918
+ target = this.parseSymbolRef();
919
+ }
920
+ else if (p.kind === TokenKind.ModeKw) {
921
+ this.advance();
922
+ this.expect(TokenKind.Colon);
923
+ mode = this.expectIdentText();
924
+ }
925
+ else if (p.kind === TokenKind.DescriptionKw) {
926
+ this.advance();
927
+ this.expect(TokenKind.Colon);
928
+ description = this.expectStringValue();
929
+ }
930
+ else {
931
+ this.error(p, `Unexpected in execution: '${p.text}'`);
932
+ this.advance();
933
+ }
934
+ }
935
+ this.expect(TokenKind.CloseBrace);
936
+ return { kind: 'execution', name, target, mode, description, location: this.loc(start) };
937
+ }
938
+ parseExtension() {
939
+ const start = this.expect(TokenKind.ExtensionKw);
940
+ const name = this.expectIdentText();
941
+ this.expect(TokenKind.OpenBrace);
942
+ let target;
943
+ let extensionKind;
944
+ let language;
945
+ let description;
946
+ let contract;
947
+ let body;
948
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
949
+ const p = this.peek();
950
+ if (p.kind === TokenKind.TargetKw) {
951
+ this.advance();
952
+ this.expect(TokenKind.Colon);
953
+ target = this.parseSymbolRef();
954
+ }
955
+ else if (p.kind === TokenKind.KindKw) {
956
+ this.advance();
957
+ this.expect(TokenKind.Colon);
958
+ extensionKind = this.expectIdentText();
959
+ }
960
+ else if (p.kind === TokenKind.LanguageKw) {
961
+ this.advance();
962
+ this.expect(TokenKind.Colon);
963
+ language = this.expectStringValue();
964
+ }
965
+ else if (p.kind === TokenKind.DescriptionKw) {
966
+ this.advance();
967
+ this.expect(TokenKind.Colon);
968
+ description = this.expectStringValue();
969
+ }
970
+ else if (p.kind === TokenKind.ContractKw) {
971
+ this.advance();
972
+ this.expect(TokenKind.OpenBrace);
973
+ contract = this.parseContractBlock();
974
+ this.expect(TokenKind.CloseBrace);
975
+ }
976
+ else if (p.kind === TokenKind.BodyKw) {
977
+ this.advance();
978
+ body = this.expectCodeLiteral();
979
+ }
980
+ else {
981
+ this.error(p, `Unexpected in extension: '${p.text}'`);
982
+ this.advance();
983
+ }
984
+ }
985
+ this.expect(TokenKind.CloseBrace);
986
+ return { kind: 'extension', name, target, extensionKind, language, description, contract, body, location: this.loc(start) };
987
+ }
988
+ // -----------------------------------------------------------------------
989
+ // Governance
990
+ // -----------------------------------------------------------------------
991
+ parseConstitution() {
992
+ const start = this.expect(TokenKind.ConstitutionKw);
993
+ const name = this.expectIdentText();
994
+ this.expect(TokenKind.OpenBrace);
995
+ let description;
996
+ let appliesTo;
997
+ let packages;
998
+ let policies;
999
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1000
+ const p = this.peek();
1001
+ if (p.kind === TokenKind.DescriptionKw) {
1002
+ this.advance();
1003
+ this.expect(TokenKind.Colon);
1004
+ description = this.expectStringValue();
1005
+ }
1006
+ else if (p.kind === TokenKind.AppliesToKw) {
1007
+ this.advance();
1008
+ this.expect(TokenKind.Colon);
1009
+ appliesTo = this.parseSymbolRefList();
1010
+ }
1011
+ else if (p.kind === TokenKind.UseKw) {
1012
+ this.advance();
1013
+ this.expect(TokenKind.Colon);
1014
+ packages = this.parsePackageRefList();
1015
+ }
1016
+ else if (p.kind === TokenKind.PoliciesKw) {
1017
+ this.advance();
1018
+ this.expect(TokenKind.OpenBrace);
1019
+ policies = [];
1020
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1021
+ const pName = this.expectIdentText();
1022
+ this.expect(TokenKind.OpenBrace);
1023
+ const props = [];
1024
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1025
+ const k = this.expectIdentText();
1026
+ this.expect(TokenKind.Colon);
1027
+ const v = this.parseValueNode();
1028
+ props.push({ key: k, value: v });
1029
+ }
1030
+ this.expect(TokenKind.CloseBrace);
1031
+ policies.push({ name: pName, properties: props });
1032
+ }
1033
+ this.expect(TokenKind.CloseBrace);
1034
+ }
1035
+ else {
1036
+ this.error(p, `Unexpected in constitution: '${p.text}'`);
1037
+ this.advance();
1038
+ }
1039
+ }
1040
+ this.expect(TokenKind.CloseBrace);
1041
+ return { kind: 'constitution', name, description, appliesTo, packages, policies, location: this.loc(start) };
1042
+ }
1043
+ parseSecurity() {
1044
+ const start = this.expect(TokenKind.SecurityKw);
1045
+ const name = this.expectIdentText();
1046
+ this.expect(TokenKind.OpenBrace);
1047
+ let appliesTo;
1048
+ let requires;
1049
+ let description;
1050
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1051
+ const p = this.peek();
1052
+ if (p.kind === TokenKind.AppliesToKw) {
1053
+ this.advance();
1054
+ this.expect(TokenKind.Colon);
1055
+ appliesTo = this.parseSymbolRefList();
1056
+ }
1057
+ else if (p.kind === TokenKind.RequiresKw) {
1058
+ this.advance();
1059
+ this.expect(TokenKind.Colon);
1060
+ requires = this.parseSymbolRefList();
1061
+ }
1062
+ else if (p.kind === TokenKind.DescriptionKw) {
1063
+ this.advance();
1064
+ this.expect(TokenKind.Colon);
1065
+ description = this.expectStringValue();
1066
+ }
1067
+ else {
1068
+ this.error(p, `Unexpected in security: '${p.text}'`);
1069
+ this.advance();
1070
+ }
1071
+ }
1072
+ this.expect(TokenKind.CloseBrace);
1073
+ return { kind: 'security', name, appliesTo, requires, description, location: this.loc(start) };
1074
+ }
1075
+ parsePrivacy() {
1076
+ const start = this.expect(TokenKind.PrivacyKw);
1077
+ const name = this.expectIdentText();
1078
+ this.expect(TokenKind.OpenBrace);
1079
+ let appliesTo;
1080
+ let classification;
1081
+ let retention;
1082
+ let redactOn;
1083
+ let exportable;
1084
+ let erasable;
1085
+ let description;
1086
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1087
+ const p = this.peek();
1088
+ if (p.kind === TokenKind.AppliesToKw) {
1089
+ this.advance();
1090
+ this.expect(TokenKind.Colon);
1091
+ appliesTo = this.parseSymbolRefList();
1092
+ }
1093
+ else if (p.kind === TokenKind.ClassificationKw) {
1094
+ this.advance();
1095
+ this.expect(TokenKind.Colon);
1096
+ classification = this.expectIdentText();
1097
+ }
1098
+ else if (p.kind === TokenKind.RetentionKw) {
1099
+ this.advance();
1100
+ this.expect(TokenKind.Colon);
1101
+ retention = this.expectStringValue();
1102
+ }
1103
+ else if (p.kind === TokenKind.RedactOnKw) {
1104
+ this.advance();
1105
+ this.expect(TokenKind.Colon);
1106
+ redactOn = this.parseSymbolRefList();
1107
+ }
1108
+ else if (p.kind === TokenKind.ExportableKw) {
1109
+ this.advance();
1110
+ this.expect(TokenKind.Colon);
1111
+ exportable = this.expectBooleanValue();
1112
+ }
1113
+ else if (p.kind === TokenKind.ErasableKw) {
1114
+ this.advance();
1115
+ this.expect(TokenKind.Colon);
1116
+ erasable = this.expectBooleanValue();
1117
+ }
1118
+ else if (p.kind === TokenKind.DescriptionKw) {
1119
+ this.advance();
1120
+ this.expect(TokenKind.Colon);
1121
+ description = this.expectStringValue();
1122
+ }
1123
+ else {
1124
+ this.error(p, `Unexpected in privacy: '${p.text}'`);
1125
+ this.advance();
1126
+ }
1127
+ }
1128
+ this.expect(TokenKind.CloseBrace);
1129
+ return { kind: 'privacy', name, appliesTo, classification, retention, redactOn, exportable, erasable, description, location: this.loc(start) };
1130
+ }
1131
+ parseValidation() {
1132
+ const start = this.expect(TokenKind.ValidationKw);
1133
+ const name = this.expectIdentText();
1134
+ this.expect(TokenKind.OpenBrace);
1135
+ let appliesTo;
1136
+ let requires;
1137
+ let description;
1138
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1139
+ const p = this.peek();
1140
+ if (p.kind === TokenKind.AppliesToKw) {
1141
+ this.advance();
1142
+ this.expect(TokenKind.Colon);
1143
+ appliesTo = this.parseSymbolRefList();
1144
+ }
1145
+ else if (p.kind === TokenKind.RequiresKw) {
1146
+ this.advance();
1147
+ this.expect(TokenKind.Colon);
1148
+ requires = this.parseSymbolRefList();
1149
+ }
1150
+ else if (p.kind === TokenKind.DescriptionKw) {
1151
+ this.advance();
1152
+ this.expect(TokenKind.Colon);
1153
+ description = this.expectStringValue();
1154
+ }
1155
+ else {
1156
+ this.error(p, `Unexpected in validation: '${p.text}'`);
1157
+ this.advance();
1158
+ }
1159
+ }
1160
+ this.expect(TokenKind.CloseBrace);
1161
+ return { kind: 'validation', name, appliesTo, requires, description, location: this.loc(start) };
1162
+ }
1163
+ // -----------------------------------------------------------------------
1164
+ // Runtime
1165
+ // -----------------------------------------------------------------------
1166
+ parseSecret() {
1167
+ const start = this.expect(TokenKind.SecretKw);
1168
+ const name = this.expectIdentText();
1169
+ this.expect(TokenKind.OpenBrace);
1170
+ let description;
1171
+ let source;
1172
+ let env;
1173
+ let path;
1174
+ let scope;
1175
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1176
+ const p = this.peek();
1177
+ if (p.kind === TokenKind.DescriptionKw) {
1178
+ this.advance();
1179
+ this.expect(TokenKind.Colon);
1180
+ description = this.expectStringValue();
1181
+ }
1182
+ else if (p.kind === TokenKind.SourceKw) {
1183
+ this.advance();
1184
+ this.expect(TokenKind.Colon);
1185
+ source = this.expectIdentText();
1186
+ }
1187
+ else if (p.kind === TokenKind.EnvKw) {
1188
+ this.advance();
1189
+ this.expect(TokenKind.Colon);
1190
+ env = this.expectStringValue();
1191
+ }
1192
+ else if (p.kind === TokenKind.PathKw) {
1193
+ this.advance();
1194
+ this.expect(TokenKind.Colon);
1195
+ path = this.expectStringValue();
1196
+ }
1197
+ else if (p.kind === TokenKind.ScopeKw) {
1198
+ this.advance();
1199
+ this.expect(TokenKind.Colon);
1200
+ scope = this.parseSymbolRefList();
1201
+ }
1202
+ else {
1203
+ this.error(p, `Unexpected in secret: '${p.text}'`);
1204
+ this.advance();
1205
+ }
1206
+ }
1207
+ this.expect(TokenKind.CloseBrace);
1208
+ return { kind: 'secret', name, description, source, env, path, scope, location: this.loc(start) };
1209
+ }
1210
+ parseEnvironment() {
1211
+ const start = this.expect(TokenKind.EnvironmentKw);
1212
+ const name = this.expectIdentText();
1213
+ this.expect(TokenKind.OpenBrace);
1214
+ let url;
1215
+ let description;
1216
+ let secrets;
1217
+ let integrations;
1218
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1219
+ const p = this.peek();
1220
+ if (p.kind === TokenKind.UrlKw) {
1221
+ this.advance();
1222
+ this.expect(TokenKind.Colon);
1223
+ url = this.expectStringValue();
1224
+ }
1225
+ else if (p.kind === TokenKind.DescriptionKw) {
1226
+ this.advance();
1227
+ this.expect(TokenKind.Colon);
1228
+ description = this.expectStringValue();
1229
+ }
1230
+ else if (p.kind === TokenKind.SecretsKw) {
1231
+ this.advance();
1232
+ this.expect(TokenKind.OpenBrace);
1233
+ secrets = [];
1234
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1235
+ const sn = this.expectIdentText();
1236
+ this.expect(TokenKind.Colon);
1237
+ const sv = this.parseValueNode();
1238
+ secrets.push({ name: sn, value: sv });
1239
+ }
1240
+ this.expect(TokenKind.CloseBrace);
1241
+ }
1242
+ else if (p.kind === TokenKind.IntegrationsKw) {
1243
+ this.advance();
1244
+ this.expect(TokenKind.OpenBrace);
1245
+ integrations = [];
1246
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1247
+ const ref = this.parseSymbolRef();
1248
+ this.expect(TokenKind.Colon);
1249
+ const iv = this.parseValueNode();
1250
+ integrations.push({ ref, value: iv });
1251
+ }
1252
+ this.expect(TokenKind.CloseBrace);
1253
+ }
1254
+ else {
1255
+ this.error(p, `Unexpected in environment: '${p.text}'`);
1256
+ this.advance();
1257
+ }
1258
+ }
1259
+ this.expect(TokenKind.CloseBrace);
1260
+ return { kind: 'environment', name, url, description, secrets, integrations, location: this.loc(start) };
1261
+ }
1262
+ parseDeployment() {
1263
+ const start = this.expect(TokenKind.DeploymentKw);
1264
+ const name = this.expectIdentText();
1265
+ this.expect(TokenKind.OpenBrace);
1266
+ let environments;
1267
+ let description;
1268
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1269
+ const p = this.peek();
1270
+ if (p.kind === TokenKind.EnvironmentsKw) {
1271
+ this.advance();
1272
+ this.expect(TokenKind.Colon);
1273
+ environments = this.parseSymbolRefList();
1274
+ }
1275
+ else if (p.kind === TokenKind.DescriptionKw) {
1276
+ this.advance();
1277
+ this.expect(TokenKind.Colon);
1278
+ description = this.expectStringValue();
1279
+ }
1280
+ else {
1281
+ this.error(p, `Unexpected in deployment: '${p.text}'`);
1282
+ this.advance();
1283
+ }
1284
+ }
1285
+ this.expect(TokenKind.CloseBrace);
1286
+ return { kind: 'deployment', name, environments, description, location: this.loc(start) };
1287
+ }
1288
+ // -----------------------------------------------------------------------
1289
+ // Test
1290
+ // -----------------------------------------------------------------------
1291
+ parseTest() {
1292
+ const start = this.expect(TokenKind.TestKw);
1293
+ const name = this.expectIdentText();
1294
+ this.expect(TokenKind.OpenBrace);
1295
+ let target = [];
1296
+ let description;
1297
+ let given;
1298
+ let expect = [];
1299
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1300
+ const p = this.peek();
1301
+ if (p.kind === TokenKind.TargetKw) {
1302
+ this.advance();
1303
+ this.expect(TokenKind.Colon);
1304
+ target = this.parseSymbolRef();
1305
+ }
1306
+ else if (p.kind === TokenKind.DescriptionKw) {
1307
+ this.advance();
1308
+ this.expect(TokenKind.Colon);
1309
+ description = this.expectStringValue();
1310
+ }
1311
+ else if (p.kind === TokenKind.GivenKw) {
1312
+ this.advance();
1313
+ this.expect(TokenKind.OpenBrace);
1314
+ given = [];
1315
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1316
+ const ref = this.parseSymbolRef();
1317
+ this.expect(TokenKind.Colon);
1318
+ const val = this.parseValueNode();
1319
+ given.push({ ref, value: val });
1320
+ }
1321
+ this.expect(TokenKind.CloseBrace);
1322
+ }
1323
+ else if (p.kind === TokenKind.ExpectKw) {
1324
+ this.advance();
1325
+ this.expect(TokenKind.OpenBrace);
1326
+ expect = this.parseExpectBlock();
1327
+ this.expect(TokenKind.CloseBrace);
1328
+ }
1329
+ else {
1330
+ this.error(p, `Unexpected in test: '${p.text}'`);
1331
+ this.advance();
1332
+ }
1333
+ }
1334
+ this.expect(TokenKind.CloseBrace);
1335
+ return { kind: 'test', name, target, description, given, expect, location: this.loc(start) };
1336
+ }
1337
+ // -----------------------------------------------------------------------
1338
+ // Product ref
1339
+ // -----------------------------------------------------------------------
1340
+ parseProductRef() {
1341
+ const start = this.expect(TokenKind.ProductRefKw);
1342
+ const name = this.expectIdentText();
1343
+ this.expect(TokenKind.OpenBrace);
1344
+ let product;
1345
+ let version;
1346
+ let description;
1347
+ let consumes;
1348
+ let auth;
1349
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1350
+ const p = this.peek();
1351
+ if (p.kind === TokenKind.ProductKw) {
1352
+ this.advance();
1353
+ this.expect(TokenKind.Colon);
1354
+ product = this.expectStringValue();
1355
+ }
1356
+ else if (p.kind === TokenKind.VersionKw) {
1357
+ this.advance();
1358
+ this.expect(TokenKind.Colon);
1359
+ version = this.expectStringValue();
1360
+ }
1361
+ else if (p.kind === TokenKind.DescriptionKw) {
1362
+ this.advance();
1363
+ this.expect(TokenKind.Colon);
1364
+ description = this.expectStringValue();
1365
+ }
1366
+ else if (p.kind === TokenKind.ConsumesKw) {
1367
+ this.advance();
1368
+ this.expect(TokenKind.OpenBrace);
1369
+ const entries = [];
1370
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1371
+ const cat = this.expectIdentText();
1372
+ this.expect(TokenKind.Colon);
1373
+ const syms = this.parseSymbolRefList();
1374
+ entries.push({ category: cat, symbols: syms });
1375
+ }
1376
+ this.expect(TokenKind.CloseBrace);
1377
+ consumes = { entries };
1378
+ }
1379
+ else if (p.kind === TokenKind.AuthKw) {
1380
+ this.advance();
1381
+ this.expect(TokenKind.OpenBrace);
1382
+ auth = [];
1383
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1384
+ const k = this.expectIdentText();
1385
+ this.expect(TokenKind.Colon);
1386
+ const v = this.parseValueNode();
1387
+ auth.push({ key: k, value: v });
1388
+ }
1389
+ this.expect(TokenKind.CloseBrace);
1390
+ }
1391
+ else {
1392
+ this.error(p, `Unexpected in product_ref: '${p.text}'`);
1393
+ this.advance();
1394
+ }
1395
+ }
1396
+ this.expect(TokenKind.CloseBrace);
1397
+ return { kind: 'product_ref', name, product, version, description, consumes, auth, location: this.loc(start) };
1398
+ }
1399
+ // =======================================================================
1400
+ // Helper parsers
1401
+ // =======================================================================
1402
+ parseFieldList() {
1403
+ const fields = [];
1404
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1405
+ const tok = this.peek();
1406
+ if (!this.isIdentLike(tok))
1407
+ break;
1408
+ const fname = this.expectIdentText();
1409
+ this.expect(TokenKind.Colon);
1410
+ const ftype = this.parseType();
1411
+ let defaultValue;
1412
+ if (this.check(TokenKind.Equals)) {
1413
+ this.advance();
1414
+ defaultValue = this.parseValueNode();
1415
+ }
1416
+ fields.push({ name: fname, type: ftype, defaultValue, location: this.loc(tok) });
1417
+ }
1418
+ return fields;
1419
+ }
1420
+ parseType() {
1421
+ const tok = this.peek();
1422
+ const loc = this.loc(tok);
1423
+ // Check for primitive
1424
+ if (tok.kind === TokenKind.Identifier || this.isIdentLike(tok)) {
1425
+ const name = tok.text;
1426
+ if (PRIMITIVE_TYPES.includes(name)) {
1427
+ this.advance();
1428
+ return { kind: 'primitive', name: name, location: loc };
1429
+ }
1430
+ // Generic: optional<T> or list<T>
1431
+ if ((name === 'optional' || name === 'list') && this.tokens[this.pos + 1]?.kind === TokenKind.LessThan) {
1432
+ this.advance(); // skip wrapper name
1433
+ this.advance(); // skip <
1434
+ const inner = this.parseType();
1435
+ if (this.check(TokenKind.GreaterThan))
1436
+ this.advance();
1437
+ return { kind: 'generic', wrapper: name, inner, location: loc };
1438
+ }
1439
+ // Domain reference (possibly qualified)
1440
+ return this.parseTypeRef();
1441
+ }
1442
+ // Fallback
1443
+ this.error(tok, `Expected type, got '${tok.text}'`);
1444
+ this.advance();
1445
+ return { kind: 'primitive', name: 'string', location: loc };
1446
+ }
1447
+ parseTypeRef() {
1448
+ const segments = this.parseSymbolRef();
1449
+ /* v8 ignore start */
1450
+ const loc = segments.length > 0
1451
+ ? this.loc(this.tokens[this.pos - 1])
1452
+ : { file: this.file, line: 1, column: 1, endLine: 1, endColumn: 1 };
1453
+ /* v8 ignore stop */
1454
+ return { kind: 'ref', segments, location: loc };
1455
+ }
1456
+ parseSymbolRef() {
1457
+ const segments = [];
1458
+ const tok = this.peek();
1459
+ if (this.isIdentLike(tok)) {
1460
+ segments.push(this.expectIdentText());
1461
+ while (this.check(TokenKind.Dot)) {
1462
+ this.advance();
1463
+ segments.push(this.expectIdentText());
1464
+ }
1465
+ }
1466
+ return segments;
1467
+ }
1468
+ parseSymbolRefList() {
1469
+ this.expect(TokenKind.OpenBracket);
1470
+ const refs = [];
1471
+ while (!this.check(TokenKind.CloseBracket) && !this.isEof()) {
1472
+ refs.push(this.parseSymbolRef());
1473
+ if (this.check(TokenKind.Comma))
1474
+ this.advance(); // allow trailing comma
1475
+ }
1476
+ this.expect(TokenKind.CloseBracket);
1477
+ return refs;
1478
+ }
1479
+ parseIdentList() {
1480
+ this.expect(TokenKind.OpenBracket);
1481
+ const items = [];
1482
+ while (!this.check(TokenKind.CloseBracket) && !this.isEof()) {
1483
+ items.push(this.expectIdentText());
1484
+ if (this.check(TokenKind.Comma))
1485
+ this.advance();
1486
+ }
1487
+ this.expect(TokenKind.CloseBracket);
1488
+ return items;
1489
+ }
1490
+ parseSymbolRefBlock() {
1491
+ const refs = [];
1492
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1493
+ refs.push(this.parseSymbolRef());
1494
+ }
1495
+ return refs;
1496
+ }
1497
+ parsePermissionList() {
1498
+ this.expect(TokenKind.OpenBracket);
1499
+ const perms = [];
1500
+ while (!this.check(TokenKind.CloseBracket) && !this.isEof()) {
1501
+ // permissions can be dotted: invoice.create
1502
+ const segments = this.parseSymbolRef();
1503
+ perms.push(segments.join('.'));
1504
+ if (this.check(TokenKind.Comma))
1505
+ this.advance();
1506
+ }
1507
+ this.expect(TokenKind.CloseBracket);
1508
+ return perms;
1509
+ }
1510
+ parseSteps() {
1511
+ const steps = [];
1512
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1513
+ const p = this.peek();
1514
+ if (p.kind === TokenKind.CallKw) {
1515
+ this.advance();
1516
+ const target = this.parseSymbolRef();
1517
+ steps.push({ kind: 'call', target });
1518
+ }
1519
+ else if (p.kind === TokenKind.DecideKw) {
1520
+ this.advance();
1521
+ const decideName = this.expectIdentText();
1522
+ this.expect(TokenKind.OpenBrace);
1523
+ const branches = [];
1524
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1525
+ this.expect(TokenKind.WhenKw);
1526
+ const whenName = this.expectIdentText();
1527
+ this.expect(TokenKind.Arrow);
1528
+ const bp = this.peek();
1529
+ let branchAction;
1530
+ if (bp.kind === TokenKind.CallKw) {
1531
+ this.advance();
1532
+ branchAction = { kind: 'call', target: this.parseSymbolRef() };
1533
+ }
1534
+ else if (bp.kind === TokenKind.FailKw) {
1535
+ this.advance();
1536
+ branchAction = { kind: 'fail', code: this.expectIdentText() };
1537
+ }
1538
+ else {
1539
+ this.error(bp, `Expected 'call' or 'fail' in when branch`);
1540
+ branchAction = { kind: 'fail', code: 'error' };
1541
+ this.advance();
1542
+ }
1543
+ branches.push({ when: whenName, action: branchAction });
1544
+ }
1545
+ this.expect(TokenKind.CloseBrace);
1546
+ steps.push({ kind: 'decide', name: decideName, branches });
1547
+ }
1548
+ else if (p.kind === TokenKind.FailKw) {
1549
+ this.advance();
1550
+ const code = this.expectIdentText();
1551
+ steps.push({ kind: 'fail', code });
1552
+ }
1553
+ else {
1554
+ this.error(p, `Expected step ('call', 'decide', or 'fail'), got '${p.text}'`);
1555
+ this.advance();
1556
+ }
1557
+ }
1558
+ return steps;
1559
+ }
1560
+ parseTransitions() {
1561
+ const transitions = [];
1562
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1563
+ // Parse full dotted path: Entity.field or module.Entity.field
1564
+ // parseSymbolRef greedily consumes dots, so we split: last segment = field, rest = entity ref
1565
+ const fullRef = this.parseSymbolRef();
1566
+ /* v8 ignore start */
1567
+ if (fullRef.length < 2) {
1568
+ this.error(this.peek(), `Expected Entity.field in transition, got '${fullRef.join('.')}'`);
1569
+ break;
1570
+ }
1571
+ /* v8 ignore stop */
1572
+ const field = fullRef.pop();
1573
+ const entityRef = fullRef;
1574
+ this.expect(TokenKind.Colon);
1575
+ const from = this.expectIdentText();
1576
+ this.expect(TokenKind.Arrow);
1577
+ const to = this.expectIdentText();
1578
+ transitions.push({ entity: entityRef, field, from, to });
1579
+ }
1580
+ return transitions;
1581
+ }
1582
+ parseEffects() {
1583
+ const effects = [];
1584
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1585
+ const p = this.peek();
1586
+ if (p.kind === TokenKind.AuditKw) {
1587
+ this.advance();
1588
+ const msg = this.expectStringValue();
1589
+ effects.push({ kind: 'audit', value: msg });
1590
+ }
1591
+ else if (p.kind === TokenKind.NotifyKw) {
1592
+ this.advance();
1593
+ effects.push({ kind: 'notify', value: this.parseSymbolRef() });
1594
+ }
1595
+ else if (p.kind === TokenKind.EmitKw) {
1596
+ this.advance();
1597
+ effects.push({ kind: 'emit', value: this.parseSymbolRef() });
1598
+ /* v8 ignore start */
1599
+ }
1600
+ else {
1601
+ // generic symbol ref effect
1602
+ effects.push({ kind: 'ref', value: this.parseSymbolRef() });
1603
+ }
1604
+ /* v8 ignore stop */
1605
+ }
1606
+ return effects;
1607
+ }
1608
+ parseExpectBlock() {
1609
+ const entries = [];
1610
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1611
+ const p = this.peek();
1612
+ if (p.kind === TokenKind.AuthorizationKw) {
1613
+ this.advance();
1614
+ this.expect(TokenKind.OpenBrace);
1615
+ const auths = [];
1616
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1617
+ const actor = this.expectIdentText();
1618
+ this.expect(TokenKind.Colon);
1619
+ const expected = this.expectIdentText();
1620
+ auths.push({ actor, expected });
1621
+ }
1622
+ this.expect(TokenKind.CloseBrace);
1623
+ entries.push({ key: 'authorization', value: auths });
1624
+ }
1625
+ else {
1626
+ const key = this.expectIdentText();
1627
+ this.expect(TokenKind.Colon);
1628
+ if (this.check(TokenKind.StringLiteral)) {
1629
+ entries.push({ key, value: this.expectStringValue() });
1630
+ }
1631
+ else {
1632
+ const v = this.parseValueNode();
1633
+ entries.push({ key, value: v });
1634
+ }
1635
+ }
1636
+ }
1637
+ return entries;
1638
+ }
1639
+ parseValueNode() {
1640
+ const tok = this.peek();
1641
+ if (tok.kind === TokenKind.StringLiteral) {
1642
+ this.advance();
1643
+ return { kind: 'string', value: unquote(tok.text) };
1644
+ }
1645
+ if (tok.kind === TokenKind.IntegerLiteral) {
1646
+ this.advance();
1647
+ return { kind: 'integer', value: parseInt(tok.text, 10) };
1648
+ }
1649
+ if (tok.kind === TokenKind.DecimalLiteral) {
1650
+ this.advance();
1651
+ return { kind: 'decimal', value: parseFloat(tok.text) };
1652
+ }
1653
+ if (tok.kind === TokenKind.BooleanTrue) {
1654
+ this.advance();
1655
+ return { kind: 'boolean', value: true };
1656
+ }
1657
+ if (tok.kind === TokenKind.BooleanFalse) {
1658
+ this.advance();
1659
+ return { kind: 'boolean', value: false };
1660
+ }
1661
+ if (tok.kind === TokenKind.OpenBracket) {
1662
+ this.advance();
1663
+ const items = [];
1664
+ while (!this.check(TokenKind.CloseBracket) && !this.isEof()) {
1665
+ items.push(this.parseValueNode());
1666
+ if (this.check(TokenKind.Comma))
1667
+ this.advance();
1668
+ }
1669
+ this.expect(TokenKind.CloseBracket);
1670
+ return { kind: 'list', items };
1671
+ }
1672
+ // Identifier or dotted ref
1673
+ /* v8 ignore start */
1674
+ if (this.isIdentLike(tok)) {
1675
+ /* v8 ignore stop */
1676
+ const segments = this.parseSymbolRef();
1677
+ if (segments.length === 1) {
1678
+ return { kind: 'identifier', value: segments[0] };
1679
+ }
1680
+ return { kind: 'ref', segments };
1681
+ /* v8 ignore start */
1682
+ }
1683
+ this.error(tok, `Expected value, got '${tok.text}'`);
1684
+ this.advance();
1685
+ return { kind: 'string', value: '' };
1686
+ /* v8 ignore stop */
1687
+ }
1688
+ parseExpressionUntilNewline() {
1689
+ // Collect tokens until we hit a keyword that starts a new property,
1690
+ // a closing brace, or EOF
1691
+ const exprTokens = [];
1692
+ while (!this.isEof()) {
1693
+ const t = this.peek();
1694
+ if (t.kind === TokenKind.CloseBrace)
1695
+ break;
1696
+ // Stop at property-starting keywords only when followed by ':'
1697
+ // (a bare keyword like 'title' can also be a field reference in an expression)
1698
+ if (isPropertyKeyword(t.kind) && this.tokens[this.pos + 1]?.kind === TokenKind.Colon)
1699
+ break;
1700
+ exprTokens.push(t);
1701
+ this.advance();
1702
+ }
1703
+ exprTokens.push({
1704
+ kind: TokenKind.EOF, text: '', pos: 0, line: 0, column: 0, end: 0,
1705
+ });
1706
+ const pos = { value: 0 };
1707
+ return parseExpression(exprTokens, pos, this.file);
1708
+ }
1709
+ parseGridBlock() {
1710
+ let columns;
1711
+ let rows;
1712
+ let gap;
1713
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1714
+ const p = this.peek();
1715
+ if (p.kind === TokenKind.ColumnsKw) {
1716
+ this.advance();
1717
+ this.expect(TokenKind.Colon);
1718
+ columns = this.parseGridTrackList();
1719
+ }
1720
+ else if (p.kind === TokenKind.RowsKw) {
1721
+ this.advance();
1722
+ this.expect(TokenKind.Colon);
1723
+ rows = this.parseGridTrackList();
1724
+ }
1725
+ else if (p.kind === TokenKind.GapKw) {
1726
+ this.advance();
1727
+ this.expect(TokenKind.Colon);
1728
+ gap = this.parseValueNode();
1729
+ }
1730
+ else {
1731
+ this.error(p, `Unexpected in grid: '${p.text}'`);
1732
+ this.advance();
1733
+ }
1734
+ }
1735
+ return { columns, rows, gap };
1736
+ }
1737
+ parseGridTrackList() {
1738
+ this.expect(TokenKind.OpenBracket);
1739
+ const tracks = [];
1740
+ while (!this.check(TokenKind.CloseBracket) && !this.isEof()) {
1741
+ const t = this.peek();
1742
+ if (t.kind === TokenKind.AutoKw) {
1743
+ this.advance();
1744
+ tracks.push({ kind: 'auto' });
1745
+ }
1746
+ else if (t.kind === TokenKind.DimensionLiteral) {
1747
+ this.advance();
1748
+ const match = t.text.match(/^(\d+(?:\.\d+)?)(.+)$/);
1749
+ if (match) {
1750
+ tracks.push({ kind: 'dimension', value: parseFloat(match[1]), unit: match[2] });
1751
+ }
1752
+ /* v8 ignore start */
1753
+ }
1754
+ else if (t.kind === TokenKind.IntegerLiteral || t.kind === TokenKind.DecimalLiteral) {
1755
+ this.advance();
1756
+ tracks.push({ kind: 'number', value: parseFloat(t.text) });
1757
+ }
1758
+ else {
1759
+ this.advance();
1760
+ }
1761
+ /* v8 ignore stop */
1762
+ if (this.check(TokenKind.Comma))
1763
+ this.advance();
1764
+ }
1765
+ this.expect(TokenKind.CloseBracket);
1766
+ return tracks;
1767
+ }
1768
+ parsePlacementBlock() {
1769
+ const placements = [];
1770
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1771
+ const name = this.expectIdentText();
1772
+ this.expect(TokenKind.Colon);
1773
+ this.expect(TokenKind.OpenBrace);
1774
+ let row;
1775
+ let column;
1776
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1777
+ const pp = this.peek();
1778
+ /* v8 ignore start */
1779
+ if (pp.kind === TokenKind.RowKw) {
1780
+ this.advance();
1781
+ this.expect(TokenKind.Colon);
1782
+ row = this.parseGridValue();
1783
+ }
1784
+ else if (pp.kind === TokenKind.ColumnKw) {
1785
+ this.advance();
1786
+ this.expect(TokenKind.Colon);
1787
+ column = this.parseGridValue();
1788
+ }
1789
+ else {
1790
+ this.advance();
1791
+ }
1792
+ /* v8 ignore stop */
1793
+ }
1794
+ this.expect(TokenKind.CloseBrace);
1795
+ placements.push({ name, row, column });
1796
+ }
1797
+ return placements;
1798
+ }
1799
+ /* v8 ignore start */
1800
+ parseGridValue() {
1801
+ const tok = this.peek();
1802
+ if (tok.kind === TokenKind.IntegerLiteral) {
1803
+ const val = parseInt(tok.text, 10);
1804
+ this.advance();
1805
+ if (this.check(TokenKind.DotDot)) {
1806
+ this.advance();
1807
+ const end = parseInt(this.expectIntText(), 10);
1808
+ return { from: val, to: end };
1809
+ }
1810
+ return val;
1811
+ }
1812
+ this.advance();
1813
+ return 1;
1814
+ }
1815
+ /* v8 ignore stop */
1816
+ parseStyleBlock() {
1817
+ const props = [];
1818
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1819
+ const pname = this.expectIdentText();
1820
+ this.expect(TokenKind.Colon);
1821
+ if (this.isIdentLike(this.peek()) && this.tokens[this.pos + 1]?.kind === TokenKind.Dot) {
1822
+ props.push({ name: pname, value: this.parseSymbolRef() });
1823
+ }
1824
+ else {
1825
+ props.push({ name: pname, value: this.parseValueNode() });
1826
+ }
1827
+ }
1828
+ return props;
1829
+ }
1830
+ parseBindBlock() {
1831
+ const entries = [];
1832
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1833
+ const from = this.parseSymbolRef();
1834
+ this.expect(TokenKind.Colon);
1835
+ const to = this.parseSymbolRef();
1836
+ entries.push({ from, to });
1837
+ }
1838
+ return entries;
1839
+ }
1840
+ parseContractBlock() {
1841
+ let input;
1842
+ let output;
1843
+ while (!this.check(TokenKind.CloseBrace) && !this.isEof()) {
1844
+ const p = this.peek();
1845
+ if (p.kind === TokenKind.InputKw) {
1846
+ this.advance();
1847
+ this.expect(TokenKind.Colon);
1848
+ input = this.parseType();
1849
+ }
1850
+ else if (p.text === 'output') {
1851
+ this.advance();
1852
+ this.expect(TokenKind.Colon);
1853
+ output = this.parseType();
1854
+ }
1855
+ else {
1856
+ this.error(p, `Unexpected in contract: '${p.text}'`);
1857
+ this.advance();
1858
+ }
1859
+ }
1860
+ return { input, output };
1861
+ }
1862
+ parseIndexList() {
1863
+ this.expect(TokenKind.OpenBracket);
1864
+ const indexes = [];
1865
+ while (!this.check(TokenKind.CloseBracket) && !this.isEof()) {
1866
+ let unique = false;
1867
+ if (this.check(TokenKind.UniqueKw)) {
1868
+ this.advance();
1869
+ unique = true;
1870
+ }
1871
+ this.expect(TokenKind.OpenBracket);
1872
+ const fields = [];
1873
+ while (!this.check(TokenKind.CloseBracket) && !this.isEof()) {
1874
+ fields.push(this.expectIdentText());
1875
+ if (this.check(TokenKind.Comma))
1876
+ this.advance();
1877
+ }
1878
+ this.expect(TokenKind.CloseBracket);
1879
+ indexes.push({ fields, unique });
1880
+ if (this.check(TokenKind.Comma))
1881
+ this.advance();
1882
+ }
1883
+ this.expect(TokenKind.CloseBracket);
1884
+ return indexes;
1885
+ }
1886
+ parsePackageRefList() {
1887
+ this.expect(TokenKind.OpenBracket);
1888
+ const refs = [];
1889
+ while (!this.check(TokenKind.CloseBracket) && !this.isEof()) {
1890
+ // Parse: registry/backend/nestjs@1.1
1891
+ let path = '';
1892
+ while (!this.isEof()) {
1893
+ const t = this.peek();
1894
+ if (t.kind === TokenKind.AtSign)
1895
+ break;
1896
+ /* v8 ignore next */
1897
+ if (t.kind === TokenKind.Comma || t.kind === TokenKind.CloseBracket)
1898
+ break;
1899
+ path += t.text;
1900
+ this.advance();
1901
+ }
1902
+ let version = '';
1903
+ if (this.check(TokenKind.AtSign)) {
1904
+ this.advance();
1905
+ // version: could be number, decimal, or string
1906
+ while (!this.isEof()) {
1907
+ const t = this.peek();
1908
+ if (t.kind === TokenKind.Comma || t.kind === TokenKind.CloseBracket)
1909
+ break;
1910
+ version += t.text;
1911
+ this.advance();
1912
+ }
1913
+ }
1914
+ refs.push({ path: path.trim(), version: version.trim() });
1915
+ if (this.check(TokenKind.Comma))
1916
+ this.advance();
1917
+ }
1918
+ this.expect(TokenKind.CloseBracket);
1919
+ return refs;
1920
+ }
1921
+ // =======================================================================
1922
+ // Token helpers
1923
+ // =======================================================================
1924
+ peek() {
1925
+ /* v8 ignore next */
1926
+ return this.tokens[this.pos] ?? { kind: TokenKind.EOF, text: '', pos: 0, line: 0, column: 0, end: 0 };
1927
+ }
1928
+ advance() {
1929
+ const tok = this.peek();
1930
+ if (tok.kind !== TokenKind.EOF)
1931
+ this.pos++;
1932
+ return tok;
1933
+ }
1934
+ check(kind) {
1935
+ return this.peek().kind === kind;
1936
+ }
1937
+ isEof() {
1938
+ return this.peek().kind === TokenKind.EOF;
1939
+ }
1940
+ expect(kind) {
1941
+ const tok = this.peek();
1942
+ /* v8 ignore start */
1943
+ if (tok.kind === kind) {
1944
+ return this.advance();
1945
+ }
1946
+ /* v8 ignore stop */
1947
+ /* v8 ignore start */
1948
+ this.error(tok, `Expected '${kind}', got '${tok.text || 'EOF'}'`);
1949
+ return tok;
1950
+ /* v8 ignore stop */
1951
+ }
1952
+ expectIdentText() {
1953
+ const tok = this.peek();
1954
+ /* v8 ignore start */
1955
+ if (this.isIdentLike(tok)) {
1956
+ this.advance();
1957
+ return tok.text;
1958
+ }
1959
+ /* v8 ignore stop */
1960
+ this.error(tok, `Expected identifier, got '${tok.text || 'EOF'}'`);
1961
+ this.advance();
1962
+ return '_error_';
1963
+ }
1964
+ expectIntText() {
1965
+ const tok = this.peek();
1966
+ if (tok.kind === TokenKind.IntegerLiteral) {
1967
+ this.advance();
1968
+ return tok.text;
1969
+ }
1970
+ this.error(tok, `Expected integer, got '${tok.text}'`);
1971
+ this.advance();
1972
+ return '0';
1973
+ }
1974
+ expectStringValue() {
1975
+ const tok = this.peek();
1976
+ if (tok.kind === TokenKind.StringLiteral) {
1977
+ this.advance();
1978
+ return unquote(tok.text);
1979
+ }
1980
+ this.error(tok, `Expected string literal, got '${tok.text}'`);
1981
+ this.advance();
1982
+ return '';
1983
+ }
1984
+ expectBooleanValue() {
1985
+ const tok = this.peek();
1986
+ if (tok.kind === TokenKind.BooleanTrue) {
1987
+ this.advance();
1988
+ return true;
1989
+ }
1990
+ if (tok.kind === TokenKind.BooleanFalse) {
1991
+ this.advance();
1992
+ return false;
1993
+ }
1994
+ this.error(tok, `Expected boolean, got '${tok.text}'`);
1995
+ this.advance();
1996
+ return false;
1997
+ }
1998
+ expectCodeLiteral() {
1999
+ const tok = this.peek();
2000
+ if (tok.kind === TokenKind.CodeLiteral) {
2001
+ this.advance();
2002
+ return extractCodeLiteral(tok.text);
2003
+ }
2004
+ this.error(tok, `Expected code literal ("""), got '${tok.text}'`);
2005
+ this.advance();
2006
+ return '';
2007
+ }
2008
+ isIdentLike(tok) {
2009
+ if (tok.kind === TokenKind.Identifier)
2010
+ return true;
2011
+ // Many keywords can appear as identifiers in property/field positions
2012
+ // since Prodara has a large keyword set. We allow keywords in identifier
2013
+ // positions when they serve as names.
2014
+ return isKeywordToken(tok.kind);
2015
+ }
2016
+ error(tok, message) {
2017
+ this.bag.add({
2018
+ phase: 'parser',
2019
+ category: 'syntax_error',
2020
+ severity: 'error',
2021
+ code: 'PRD0100',
2022
+ message,
2023
+ file: this.file,
2024
+ line: tok.line,
2025
+ column: tok.column,
2026
+ });
2027
+ }
2028
+ loc(tok) {
2029
+ return {
2030
+ file: this.file,
2031
+ line: tok.line,
2032
+ column: tok.column,
2033
+ endLine: tok.line,
2034
+ endColumn: tok.column + tok.text.length,
2035
+ };
2036
+ }
2037
+ }
2038
+ // =======================================================================
2039
+ // Utilities
2040
+ // =======================================================================
2041
+ /* v8 ignore start */
2042
+ function unquote(s) {
2043
+ if (s.startsWith('"') && s.endsWith('"')) {
2044
+ return s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\t/g, '\t');
2045
+ }
2046
+ return s;
2047
+ }
2048
+ /* v8 ignore stop */
2049
+ function extractCodeLiteral(s) {
2050
+ // Strip opening/closing """ and dedent
2051
+ let inner = s.slice(3);
2052
+ if (inner.endsWith('"""'))
2053
+ inner = inner.slice(0, -3);
2054
+ // Remove leading newline
2055
+ if (inner.startsWith('\n'))
2056
+ inner = inner.slice(1);
2057
+ else if (inner.startsWith('\r\n'))
2058
+ inner = inner.slice(2);
2059
+ // Remove trailing newline before closing
2060
+ /* v8 ignore next */
2061
+ if (inner.endsWith('\n'))
2062
+ inner = inner.slice(0, -1);
2063
+ // Dedent: find minimum leading whitespace
2064
+ const lines = inner.split('\n');
2065
+ let minIndent = Infinity;
2066
+ for (const line of lines) {
2067
+ if (line.trim().length === 0)
2068
+ continue;
2069
+ const indent = line.length - line.trimStart().length;
2070
+ /* v8 ignore start */
2071
+ if (indent < minIndent)
2072
+ minIndent = indent;
2073
+ /* v8 ignore stop */
2074
+ }
2075
+ /* v8 ignore next */
2076
+ if (minIndent === Infinity)
2077
+ minIndent = 0;
2078
+ return lines.map((l) => l.slice(minIndent)).join('\n');
2079
+ }
2080
+ function isPropertyKeyword(kind) {
2081
+ switch (kind) {
2082
+ case TokenKind.EntityKw:
2083
+ case TokenKind.ConditionKw:
2084
+ case TokenKind.MessageKw:
2085
+ case TokenKind.CapabilityKw:
2086
+ case TokenKind.AuthorizationKw:
2087
+ case TokenKind.InputKw:
2088
+ case TokenKind.ReadsKw:
2089
+ case TokenKind.WritesKw:
2090
+ case TokenKind.RulesKw:
2091
+ case TokenKind.StepsKw:
2092
+ case TokenKind.TransitionsKw:
2093
+ case TokenKind.EffectsKw:
2094
+ case TokenKind.ReturnsKw:
2095
+ case TokenKind.OnKw:
2096
+ case TokenKind.TitleKw:
2097
+ case TokenKind.DescriptionKw:
2098
+ case TokenKind.KindKw:
2099
+ case TokenKind.TargetKw:
2100
+ /* v8 ignore start */
2101
+ case TokenKind.WorkflowKw:
2102
+ return true;
2103
+ default:
2104
+ return false;
2105
+ }
2106
+ }
2107
+ /* v8 ignore stop */
2108
+ /** Check if a TokenKind is a keyword (used for allowing keywords-as-identifiers). */
2109
+ /* v8 ignore start */
2110
+ function isKeywordToken(kind) {
2111
+ switch (kind) {
2112
+ case TokenKind.Identifier:
2113
+ case TokenKind.StringLiteral:
2114
+ case TokenKind.IntegerLiteral:
2115
+ case TokenKind.DecimalLiteral:
2116
+ case TokenKind.BooleanTrue:
2117
+ case TokenKind.BooleanFalse:
2118
+ case TokenKind.CodeLiteral:
2119
+ case TokenKind.DimensionLiteral:
2120
+ case TokenKind.OpenBrace:
2121
+ case TokenKind.CloseBrace:
2122
+ case TokenKind.OpenBracket:
2123
+ case TokenKind.CloseBracket:
2124
+ case TokenKind.OpenParen:
2125
+ case TokenKind.CloseParen:
2126
+ case TokenKind.Colon:
2127
+ case TokenKind.Comma:
2128
+ case TokenKind.Dot:
2129
+ case TokenKind.Equals:
2130
+ case TokenKind.LessThan:
2131
+ case TokenKind.GreaterThan:
2132
+ case TokenKind.Arrow:
2133
+ case TokenKind.DotDot:
2134
+ case TokenKind.AtSign:
2135
+ case TokenKind.Slash:
2136
+ case TokenKind.GreaterEqual:
2137
+ case TokenKind.LessEqual:
2138
+ case TokenKind.EqualsEquals:
2139
+ case TokenKind.BangEquals:
2140
+ case TokenKind.EOF:
2141
+ case TokenKind.Unknown:
2142
+ return false;
2143
+ default:
2144
+ // All keyword tokens return true
2145
+ return true;
2146
+ }
2147
+ }
2148
+ /* v8 ignore stop */
2149
+ //# sourceMappingURL=parser.js.map