@aexol/spectral 0.9.230 → 0.9.234

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 (265) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/agent/index.d.ts.map +1 -1
  3. package/dist/agent/index.js +89 -14
  4. package/dist/backend/generated-images.d.ts +1 -1
  5. package/dist/backend/generated-images.d.ts.map +1 -1
  6. package/dist/commands/serve.d.ts.map +1 -1
  7. package/dist/commands/serve.js +12 -1
  8. package/dist/designer/data/skills/blog-post.d.ts +3 -0
  9. package/dist/designer/data/skills/blog-post.d.ts.map +1 -0
  10. package/dist/designer/data/skills/blog-post.js +84 -0
  11. package/dist/designer/data/skills/blog-post.ts +87 -0
  12. package/dist/designer/data/skills/critique.d.ts +3 -0
  13. package/dist/designer/data/skills/critique.d.ts.map +1 -0
  14. package/dist/designer/data/skills/critique.js +109 -0
  15. package/dist/designer/data/skills/critique.ts +112 -0
  16. package/dist/designer/data/skills/dashboard.d.ts +3 -0
  17. package/dist/designer/data/skills/dashboard.d.ts.map +1 -0
  18. package/dist/designer/data/skills/dashboard.js +165 -0
  19. package/dist/designer/data/skills/dashboard.ts +168 -0
  20. package/dist/designer/data/skills/design-brief.d.ts +3 -0
  21. package/dist/designer/data/skills/design-brief.d.ts.map +1 -0
  22. package/dist/designer/data/skills/design-brief.js +141 -0
  23. package/dist/designer/data/skills/design-brief.ts +144 -0
  24. package/dist/designer/data/skills/design-skill.d.ts +10 -0
  25. package/dist/designer/data/skills/design-skill.d.ts.map +1 -0
  26. package/dist/designer/data/skills/design-skill.js +1 -0
  27. package/dist/designer/data/skills/design-skill.ts +9 -0
  28. package/dist/designer/data/skills/docs-page.d.ts +3 -0
  29. package/dist/designer/data/skills/docs-page.d.ts.map +1 -0
  30. package/dist/designer/data/skills/docs-page.js +68 -0
  31. package/dist/designer/data/skills/docs-page.ts +71 -0
  32. package/dist/designer/data/skills/index.d.ts +3 -0
  33. package/dist/designer/data/skills/index.d.ts.map +1 -0
  34. package/dist/designer/data/skills/index.js +28 -0
  35. package/dist/designer/data/skills/index.ts +30 -0
  36. package/dist/designer/data/skills/magazine-poster.d.ts +3 -0
  37. package/dist/designer/data/skills/magazine-poster.d.ts.map +1 -0
  38. package/dist/designer/data/skills/magazine-poster.js +70 -0
  39. package/dist/designer/data/skills/magazine-poster.ts +73 -0
  40. package/dist/designer/data/skills/mobile-app.d.ts +3 -0
  41. package/dist/designer/data/skills/mobile-app.d.ts.map +1 -0
  42. package/dist/designer/data/skills/mobile-app.js +229 -0
  43. package/dist/designer/data/skills/mobile-app.ts +232 -0
  44. package/dist/designer/data/skills/motion-frames.d.ts +3 -0
  45. package/dist/designer/data/skills/motion-frames.d.ts.map +1 -0
  46. package/dist/designer/data/skills/motion-frames.js +121 -0
  47. package/dist/designer/data/skills/motion-frames.ts +124 -0
  48. package/dist/designer/data/skills/pricing-page.d.ts +3 -0
  49. package/dist/designer/data/skills/pricing-page.d.ts.map +1 -0
  50. package/dist/designer/data/skills/pricing-page.js +76 -0
  51. package/dist/designer/data/skills/pricing-page.ts +79 -0
  52. package/dist/designer/data/skills/saas-landing.d.ts +3 -0
  53. package/dist/designer/data/skills/saas-landing.d.ts.map +1 -0
  54. package/dist/designer/data/skills/saas-landing.js +71 -0
  55. package/dist/designer/data/skills/saas-landing.ts +74 -0
  56. package/dist/designer/data/skills/slide-deck.d.ts +3 -0
  57. package/dist/designer/data/skills/slide-deck.d.ts.map +1 -0
  58. package/dist/designer/data/skills/slide-deck.js +213 -0
  59. package/dist/designer/data/skills/slide-deck.ts +216 -0
  60. package/dist/designer/data/skills/social-carousel.d.ts +3 -0
  61. package/dist/designer/data/skills/social-carousel.d.ts.map +1 -0
  62. package/dist/designer/data/skills/social-carousel.js +135 -0
  63. package/dist/designer/data/skills/social-carousel.ts +138 -0
  64. package/dist/designer/data/skills/web-prototype.d.ts +3 -0
  65. package/dist/designer/data/skills/web-prototype.d.ts.map +1 -0
  66. package/dist/designer/data/skills/web-prototype.js +159 -0
  67. package/dist/designer/data/skills/web-prototype.ts +162 -0
  68. package/dist/designer/skills.d.ts +4 -10
  69. package/dist/designer/skills.d.ts.map +1 -1
  70. package/dist/designer/skills.js +2 -1643
  71. package/dist/extensions/logic-trace.d.ts +1 -1
  72. package/dist/extensions/logic-trace.d.ts.map +1 -1
  73. package/dist/extensions/logic-trace.js +199 -70
  74. package/dist/extensions/video-generation/index.d.ts +3 -0
  75. package/dist/extensions/video-generation/index.d.ts.map +1 -0
  76. package/dist/extensions/video-generation/index.js +299 -0
  77. package/dist/extensions/wizard/index.js +9 -1
  78. package/dist/generated/parser/ast/nodes.d.ts +115 -0
  79. package/dist/generated/parser/ast/nodes.d.ts.map +1 -0
  80. package/dist/generated/parser/ast/nodes.js +8 -0
  81. package/dist/generated/parser/lexer/lexer.d.ts +28 -0
  82. package/dist/generated/parser/lexer/lexer.d.ts.map +1 -0
  83. package/dist/generated/parser/{lexer.js → lexer/lexer.js} +1 -180
  84. package/dist/generated/parser/{lexer.d.ts → lexer/tokens.d.ts} +5 -24
  85. package/dist/generated/parser/lexer/tokens.d.ts.map +1 -0
  86. package/dist/generated/parser/lexer/tokens.js +187 -0
  87. package/dist/generated/parser/mod.d.ts +5 -7
  88. package/dist/generated/parser/mod.d.ts.map +1 -1
  89. package/dist/generated/parser/mod.js +2 -1
  90. package/dist/generated/parser/parser/cursor.d.ts +47 -0
  91. package/dist/generated/parser/parser/cursor.d.ts.map +1 -0
  92. package/dist/generated/parser/parser/cursor.js +12 -0
  93. package/dist/generated/parser/parser/definitions.d.ts +16 -0
  94. package/dist/generated/parser/parser/definitions.d.ts.map +1 -0
  95. package/dist/generated/parser/parser/definitions.js +353 -0
  96. package/dist/generated/parser/parser/expressions.d.ts +17 -0
  97. package/dist/generated/parser/parser/expressions.d.ts.map +1 -0
  98. package/dist/generated/parser/parser/expressions.js +165 -0
  99. package/dist/generated/parser/parser.d.ts +18 -133
  100. package/dist/generated/parser/parser.d.ts.map +1 -1
  101. package/dist/generated/parser/parser.js +9 -505
  102. package/dist/generated/parser/tokenizer.d.ts +1 -2
  103. package/dist/generated/parser/tokenizer.d.ts.map +1 -1
  104. package/dist/generated/parser/tokenizer.js +2 -1
  105. package/dist/generated/parser/validator.d.ts +1 -1
  106. package/dist/generated/parser/validator.d.ts.map +1 -1
  107. package/dist/generated/zeus/const.d.ts.map +1 -1
  108. package/dist/generated/zeus/const.js +30 -0
  109. package/dist/generated/zeus/index.d.ts +140 -0
  110. package/dist/generated/zeus/index.d.ts.map +1 -1
  111. package/dist/generated/zeus/index.js +5 -0
  112. package/dist/mcp/glimpse-ui.js +9 -1
  113. package/dist/relay/dispatcher.d.ts +23 -104
  114. package/dist/relay/dispatcher.d.ts.map +1 -1
  115. package/dist/relay/dispatcher.js +21 -1130
  116. package/dist/relay/rest.d.ts +31 -0
  117. package/dist/relay/rest.d.ts.map +1 -0
  118. package/dist/relay/rest.js +85 -0
  119. package/dist/relay/routing.d.ts +109 -0
  120. package/dist/relay/routing.d.ts.map +1 -0
  121. package/dist/relay/routing.js +669 -0
  122. package/dist/relay/wizard-login.d.ts +17 -0
  123. package/dist/relay/wizard-login.d.ts.map +1 -0
  124. package/dist/relay/wizard-login.js +419 -0
  125. package/dist/sdk/agent-core/agent-loop.d.ts +2 -9
  126. package/dist/sdk/agent-core/agent-loop.d.ts.map +1 -1
  127. package/dist/sdk/agent-core/agent-loop.js +17 -291
  128. package/dist/sdk/agent-core/agent.d.ts +11 -4
  129. package/dist/sdk/agent-core/agent.d.ts.map +1 -1
  130. package/dist/sdk/agent-core/agent.js +16 -4
  131. package/dist/sdk/agent-core/tool-call-registry.d.ts +75 -0
  132. package/dist/sdk/agent-core/tool-call-registry.d.ts.map +1 -0
  133. package/dist/sdk/agent-core/tool-call-registry.js +131 -0
  134. package/dist/sdk/agent-core/tool-execution.d.ts +33 -0
  135. package/dist/sdk/agent-core/tool-execution.d.ts.map +1 -0
  136. package/dist/sdk/agent-core/tool-execution.js +399 -0
  137. package/dist/sdk/agent-core/types.d.ts +15 -4
  138. package/dist/sdk/agent-core/types.d.ts.map +1 -1
  139. package/dist/sdk/ai/env-api-keys.js +9 -1
  140. package/dist/sdk/ai/index.d.ts +3 -0
  141. package/dist/sdk/ai/index.d.ts.map +1 -1
  142. package/dist/sdk/ai/index.js +3 -0
  143. package/dist/sdk/ai/providers/faux.d.ts.map +1 -1
  144. package/dist/sdk/ai/providers/faux.js +3 -0
  145. package/dist/sdk/ai/providers/leaked-tool-call-parser.d.ts +39 -6
  146. package/dist/sdk/ai/providers/leaked-tool-call-parser.d.ts.map +1 -1
  147. package/dist/sdk/ai/providers/leaked-tool-call-parser.js +159 -18
  148. package/dist/sdk/ai/providers/openai/reasoning-replay.d.ts +48 -0
  149. package/dist/sdk/ai/providers/openai/reasoning-replay.d.ts.map +1 -0
  150. package/dist/sdk/ai/providers/openai/reasoning-replay.js +209 -0
  151. package/dist/sdk/ai/providers/openai-completions.d.ts.map +1 -1
  152. package/dist/sdk/ai/providers/openai-completions.js +23 -211
  153. package/dist/sdk/ai/providers/openrouter-videos.d.ts +3 -0
  154. package/dist/sdk/ai/providers/openrouter-videos.d.ts.map +1 -0
  155. package/dist/sdk/ai/providers/openrouter-videos.js +412 -0
  156. package/dist/sdk/ai/providers/register-builtins.d.ts.map +1 -1
  157. package/dist/sdk/ai/providers/register-builtins.js +6 -0
  158. package/dist/sdk/ai/providers/simple-options.d.ts +1 -6
  159. package/dist/sdk/ai/providers/simple-options.d.ts.map +1 -1
  160. package/dist/sdk/ai/providers/simple-options.js +0 -22
  161. package/dist/sdk/ai/providers/transform-messages.d.ts.map +1 -1
  162. package/dist/sdk/ai/providers/transform-messages.js +52 -1
  163. package/dist/sdk/ai/types.d.ts +91 -10
  164. package/dist/sdk/ai/types.d.ts.map +1 -1
  165. package/dist/sdk/ai/video-models.d.ts +10 -0
  166. package/dist/sdk/ai/video-models.d.ts.map +1 -0
  167. package/dist/sdk/ai/video-models.generated.d.ts +440 -0
  168. package/dist/sdk/ai/video-models.generated.d.ts.map +1 -0
  169. package/dist/sdk/ai/video-models.generated.js +441 -0
  170. package/dist/sdk/ai/video-models.js +22 -0
  171. package/dist/sdk/ai/videos-api-registry.d.ts +14 -0
  172. package/dist/sdk/ai/videos-api-registry.d.ts.map +1 -0
  173. package/dist/sdk/ai/videos-api-registry.js +21 -0
  174. package/dist/sdk/ai/videos.d.ts +4 -0
  175. package/dist/sdk/ai/videos.d.ts.map +1 -0
  176. package/dist/sdk/ai/videos.js +13 -0
  177. package/dist/sdk/coding-agent/core/agent-session.d.ts +8 -0
  178. package/dist/sdk/coding-agent/core/agent-session.d.ts.map +1 -1
  179. package/dist/sdk/coding-agent/core/agent-session.js +11 -0
  180. package/dist/sdk/coding-agent/core/compaction/compaction.d.ts +6 -118
  181. package/dist/sdk/coding-agent/core/compaction/compaction.d.ts.map +1 -1
  182. package/dist/sdk/coding-agent/core/compaction/compaction.js +11 -733
  183. package/dist/sdk/coding-agent/core/compaction/cut-points.d.ts +58 -0
  184. package/dist/sdk/coding-agent/core/compaction/cut-points.d.ts.map +1 -0
  185. package/dist/sdk/coding-agent/core/compaction/cut-points.js +191 -0
  186. package/dist/sdk/coding-agent/core/compaction/dedupe.d.ts +28 -0
  187. package/dist/sdk/coding-agent/core/compaction/dedupe.d.ts.map +1 -0
  188. package/dist/sdk/coding-agent/core/compaction/dedupe.js +156 -0
  189. package/dist/sdk/coding-agent/core/compaction/summarize.d.ts +21 -0
  190. package/dist/sdk/coding-agent/core/compaction/summarize.d.ts.map +1 -0
  191. package/dist/sdk/coding-agent/core/compaction/summarize.js +181 -0
  192. package/dist/sdk/coding-agent/core/compaction/tokens.d.ts +47 -0
  193. package/dist/sdk/coding-agent/core/compaction/tokens.d.ts.map +1 -0
  194. package/dist/sdk/coding-agent/core/compaction/tokens.js +224 -0
  195. package/dist/sdk/coding-agent/core/extensions/loader.d.ts.map +1 -1
  196. package/dist/sdk/coding-agent/core/extensions/loader.js +14 -0
  197. package/dist/sdk/coding-agent/core/extensions/native-extensions.d.ts +26 -0
  198. package/dist/sdk/coding-agent/core/extensions/native-extensions.d.ts.map +1 -1
  199. package/dist/sdk/coding-agent/core/extensions/native-extensions.js +23 -0
  200. package/dist/sdk/coding-agent/core/extensions/session-events.d.ts +157 -0
  201. package/dist/sdk/coding-agent/core/extensions/session-events.d.ts.map +1 -0
  202. package/dist/sdk/coding-agent/core/extensions/session-events.js +13 -0
  203. package/dist/sdk/coding-agent/core/extensions/types.d.ts +10 -367
  204. package/dist/sdk/coding-agent/core/extensions/types.d.ts.map +1 -1
  205. package/dist/sdk/coding-agent/core/extensions/types.js +2 -10
  206. package/dist/sdk/coding-agent/core/extensions/ui-types.d.ts +219 -0
  207. package/dist/sdk/coding-agent/core/extensions/ui-types.d.ts.map +1 -0
  208. package/dist/sdk/coding-agent/core/extensions/ui-types.js +4 -0
  209. package/dist/sdk/coding-agent/core/messages.d.ts.map +1 -1
  210. package/dist/sdk/coding-agent/core/messages.js +42 -2
  211. package/dist/sdk/coding-agent/core/package/default-package-manager.d.ts +115 -0
  212. package/dist/sdk/coding-agent/core/package/default-package-manager.d.ts.map +1 -0
  213. package/dist/sdk/coding-agent/core/package/default-package-manager.js +1184 -0
  214. package/dist/sdk/coding-agent/core/package/discovery.d.ts +20 -0
  215. package/dist/sdk/coding-agent/core/package/discovery.d.ts.map +1 -0
  216. package/dist/sdk/coding-agent/core/package/discovery.js +283 -0
  217. package/dist/sdk/coding-agent/core/package/ignore.d.ts +29 -0
  218. package/dist/sdk/coding-agent/core/package/ignore.d.ts.map +1 -0
  219. package/dist/sdk/coding-agent/core/package/ignore.js +235 -0
  220. package/dist/sdk/coding-agent/core/package/types.d.ts +128 -0
  221. package/dist/sdk/coding-agent/core/package/types.d.ts.map +1 -0
  222. package/dist/sdk/coding-agent/core/package/types.js +18 -0
  223. package/dist/sdk/coding-agent/core/package/update-check.d.ts +43 -0
  224. package/dist/sdk/coding-agent/core/package/update-check.d.ts.map +1 -0
  225. package/dist/sdk/coding-agent/core/package/update-check.js +253 -0
  226. package/dist/sdk/coding-agent/core/package-manager.d.ts +2 -188
  227. package/dist/sdk/coding-agent/core/package-manager.d.ts.map +1 -1
  228. package/dist/sdk/coding-agent/core/package-manager.js +1 -1940
  229. package/dist/sdk/coding-agent/core/resource-loader.d.ts +11 -0
  230. package/dist/sdk/coding-agent/core/resource-loader.d.ts.map +1 -1
  231. package/dist/sdk/coding-agent/core/resource-loader.js +23 -6
  232. package/dist/sdk/coding-agent/core/sdk.d.ts +24 -2
  233. package/dist/sdk/coding-agent/core/sdk.d.ts.map +1 -1
  234. package/dist/sdk/coding-agent/core/sdk.js +15 -3
  235. package/dist/sdk/coding-agent/core/session/migrate.d.ts +18 -0
  236. package/dist/sdk/coding-agent/core/session/migrate.d.ts.map +1 -0
  237. package/dist/sdk/coding-agent/core/session/migrate.js +78 -0
  238. package/dist/sdk/coding-agent/core/session/types.d.ts +165 -0
  239. package/dist/sdk/coding-agent/core/session/types.d.ts.map +1 -0
  240. package/dist/sdk/coding-agent/core/session/types.js +4 -0
  241. package/dist/sdk/coding-agent/core/session-manager.d.ts +3 -161
  242. package/dist/sdk/coding-agent/core/session-manager.d.ts.map +1 -1
  243. package/dist/sdk/coding-agent/core/session-manager.js +4 -72
  244. package/dist/sdk/coding-agent/core/settings-manager.d.ts +0 -8
  245. package/dist/sdk/coding-agent/core/settings-manager.d.ts.map +1 -1
  246. package/dist/sdk/coding-agent/core/settings-manager.js +3 -3
  247. package/dist/sdk/coding-agent/index.d.ts +2 -2
  248. package/dist/sdk/coding-agent/index.d.ts.map +1 -1
  249. package/dist/sdk/coding-agent/index.js +1 -1
  250. package/dist/sdk-public.d.ts +96 -0
  251. package/dist/sdk-public.d.ts.map +1 -0
  252. package/dist/sdk-public.js +109 -0
  253. package/dist/server/agent-bridge/rehydrate.d.ts +2 -2
  254. package/dist/server/agent-bridge/rehydrate.d.ts.map +1 -1
  255. package/dist/server/agent-bridge/rehydrate.js +14 -0
  256. package/dist/server/agent-bridge.d.ts +8 -2
  257. package/dist/server/agent-bridge.d.ts.map +1 -1
  258. package/dist/server/agent-bridge.js +25 -2
  259. package/dist/server/session-stream.d.ts +19 -0
  260. package/dist/server/session-stream.d.ts.map +1 -1
  261. package/dist/server/session-stream.js +35 -0
  262. package/dist/server/wire.d.ts +13 -0
  263. package/dist/server/wire.d.ts.map +1 -1
  264. package/package.json +8 -2
  265. package/dist/generated/parser/lexer.d.ts.map +0 -1
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Aexol Language Parser — Cursor Interface
3
+ *
4
+ * Low-level token navigation contract shared by the Parser class and the
5
+ * extracted definition/expression parse functions. The Parser class
6
+ * implements this interface; the extracted functions receive it as their
7
+ * parsing context.
8
+ *
9
+ * Pure type definitions — zero runtime dependencies.
10
+ */
11
+ import type { CapabilityNode } from "../ast/nodes.ts";
12
+ import type { Token, TokenType } from "../lexer/tokens.ts";
13
+ export interface ParserCursor {
14
+ /** Current token under the cursor (used for locations and error messages). */
15
+ readonly currentToken: Token;
16
+ /** Consume and return the current token, advancing the cursor. */
17
+ advance(): Token;
18
+ /** Check whether the current token has the given type. */
19
+ check(type: TokenType): boolean;
20
+ /** Check whether the current token has any of the given types. */
21
+ checkAny(...types: TokenType[]): boolean;
22
+ /** Consume the current token if it has the given type, else throw. */
23
+ consume(type: TokenType, message?: string): Token;
24
+ /** Consume the current token if it has any of the given types. */
25
+ match(...types: TokenType[]): Token | null;
26
+ /**
27
+ * Consume a token usable as an identifier (IDENTIFIER or keyword used
28
+ * in identifier position, e.g. field names, enum values).
29
+ */
30
+ consumeIdentifierOrKeyword(message?: string): Token;
31
+ /**
32
+ * Check whether the current token is a keyword being used as an
33
+ * identifier in a capability context (e.g. "can import catalog").
34
+ */
35
+ isKeywordUsedAsIdentifier(): boolean;
36
+ /** Skip newline/indent/dedent/comment tokens. */
37
+ skipNewlines(): void;
38
+ /** Check whether the cursor is at the EOF token. */
39
+ isAtEnd(): boolean;
40
+ /** Consume a description (PROMPT token) if present. */
41
+ parseDescriptionIfPresent(): string | undefined;
42
+ /** Parse a capability (with nesting and conditions) — shared helper. */
43
+ parseCapability(): CapabilityNode;
44
+ /** Parse a string array: [item1, item2, item3] — shared helper. */
45
+ parseStringArray(): string[];
46
+ }
47
+ //# sourceMappingURL=cursor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../../../src/generated/parser/parser/cursor.ts"],"names":[],"mappings":"AACA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC;IAE7B,kEAAkE;IAClE,OAAO,IAAI,KAAK,CAAC;IAEjB,0DAA0D;IAC1D,KAAK,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAEhC,kEAAkE;IAClE,QAAQ,CAAC,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEzC,sEAAsE;IACtE,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAElD,kEAAkE;IAClE,KAAK,CAAC,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,GAAG,IAAI,CAAC;IAE3C;;;OAGG;IACH,0BAA0B,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAEpD;;;OAGG;IACH,yBAAyB,IAAI,OAAO,CAAC;IAErC,iDAAiD;IACjD,YAAY,IAAI,IAAI,CAAC;IAErB,oDAAoD;IACpD,OAAO,IAAI,OAAO,CAAC;IAEnB,uDAAuD;IACvD,yBAAyB,IAAI,MAAM,GAAG,SAAS,CAAC;IAEhD,wEAAwE;IACxE,eAAe,IAAI,cAAc,CAAC;IAElC,mEAAmE;IACnE,gBAAgB,IAAI,MAAM,EAAE,CAAC;CAC9B"}
@@ -0,0 +1,12 @@
1
+ // GENERATED by cli-node/scripts/vendor-parser.mjs — do not edit; regenerate with `node scripts/vendor-parser.mjs`; source: packages/parser/
2
+ /**
3
+ * Aexol Language Parser — Cursor Interface
4
+ *
5
+ * Low-level token navigation contract shared by the Parser class and the
6
+ * extracted definition/expression parse functions. The Parser class
7
+ * implements this interface; the extracted functions receive it as their
8
+ * parsing context.
9
+ *
10
+ * Pure type definitions — zero runtime dependencies.
11
+ */
12
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Aexol Language Parser — Definition Parsing
3
+ *
4
+ * Top-level definition parsers (visitor, role, workflow, agent, type)
5
+ * extracted from the Parser class. Each function receives the ParserCursor
6
+ * as its parsing context; shared helpers (parseCapability, parseStringArray)
7
+ * are reached through the cursor.
8
+ */
9
+ import type { AgentDefinition, RoleDefinition, TypeDefinition, VisitorDefinition, WorkflowDefinition } from "../ast/nodes.ts";
10
+ import type { ParserCursor } from "./cursor.js";
11
+ export declare function parseVisitor(ctx: ParserCursor, description?: string): VisitorDefinition;
12
+ export declare function parseRole(ctx: ParserCursor, description?: string): RoleDefinition;
13
+ export declare function parseWorkflow(ctx: ParserCursor, description?: string): WorkflowDefinition;
14
+ export declare function parseAgent(ctx: ParserCursor, description?: string): AgentDefinition;
15
+ export declare function parseTypeDefinition(ctx: ParserCursor, description?: string): TypeDefinition;
16
+ //# sourceMappingURL=definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../../src/generated/parser/parser/definitions.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,eAAe,EAGf,cAAc,EAEd,cAAc,EAEd,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,YAAY,CAC1B,GAAG,EAAE,YAAY,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,iBAAiB,CAiCnB;AAED,wBAAgB,SAAS,CACvB,GAAG,EAAE,YAAY,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,cAAc,CAuFhB;AAED,wBAAgB,aAAa,CAC3B,GAAG,EAAE,YAAY,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB,CAuGpB;AAED,wBAAgB,UAAU,CACxB,GAAG,EAAE,YAAY,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,CA6FjB;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,YAAY,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,cAAc,CA4FhB"}
@@ -0,0 +1,353 @@
1
+ // GENERATED by cli-node/scripts/vendor-parser.mjs — do not edit; regenerate with `node scripts/vendor-parser.mjs`; source: packages/parser/
2
+ /**
3
+ * Aexol Language Parser — Definition Parsing
4
+ *
5
+ * Top-level definition parsers (visitor, role, workflow, agent, type)
6
+ * extracted from the Parser class. Each function receives the ParserCursor
7
+ * as its parsing context; shared helpers (parseCapability, parseStringArray)
8
+ * are reached through the cursor.
9
+ */
10
+ import { TokenType } from "../lexer/tokens.js";
11
+ export function parseVisitor(ctx, description) {
12
+ const startToken = ctx.consume(TokenType.VISITOR);
13
+ let name;
14
+ if (ctx.check(TokenType.IDENTIFIER)) {
15
+ name = ctx.advance().value;
16
+ }
17
+ ctx.skipNewlines();
18
+ ctx.consume(TokenType.LBRACE, "Expected '{' after visitor");
19
+ ctx.skipNewlines();
20
+ const capabilities = [];
21
+ while (!ctx.check(TokenType.RBRACE) && !ctx.isAtEnd()) {
22
+ capabilities.push(ctx.parseCapability());
23
+ ctx.skipNewlines();
24
+ }
25
+ ctx.consume(TokenType.RBRACE, "Expected '}' after visitor body");
26
+ return {
27
+ type: "VisitorDefinition",
28
+ name,
29
+ description,
30
+ capabilities,
31
+ location: {
32
+ start: startToken.location.offset,
33
+ end: ctx.currentToken.location.offset,
34
+ line: startToken.location.line,
35
+ column: startToken.location.column,
36
+ },
37
+ };
38
+ }
39
+ export function parseRole(ctx, description) {
40
+ const startToken = ctx.consume(TokenType.ROLE);
41
+ const name = ctx.consume(TokenType.IDENTIFIER, "Expected role name").value;
42
+ ctx.skipNewlines();
43
+ ctx.consume(TokenType.LBRACE, "Expected '{' after role name");
44
+ ctx.skipNewlines();
45
+ const permissions = [];
46
+ const inherits = [];
47
+ while (!ctx.check(TokenType.RBRACE) && !ctx.isAtEnd()) {
48
+ const loopStart = ctx.currentToken.location.offset;
49
+ // Check for description before permission
50
+ const permissionDescription = ctx.parseDescriptionIfPresent();
51
+ if (ctx.check(TokenType.PERMISSION)) {
52
+ ctx.advance();
53
+ const resource = ctx.consume(TokenType.IDENTIFIER, "Expected resource name").value;
54
+ const actions = [];
55
+ if (ctx.check(TokenType.LBRACE)) {
56
+ ctx.advance();
57
+ ctx.skipNewlines();
58
+ while (!ctx.check(TokenType.RBRACE) && !ctx.isAtEnd()) {
59
+ actions.push(ctx.consume(TokenType.IDENTIFIER, "Expected action name").value);
60
+ if (ctx.check(TokenType.COMMA)) {
61
+ ctx.advance();
62
+ ctx.skipNewlines();
63
+ }
64
+ ctx.skipNewlines();
65
+ }
66
+ ctx.consume(TokenType.RBRACE, "Expected '}' after actions");
67
+ }
68
+ permissions.push({
69
+ type: "Permission",
70
+ resource,
71
+ description: permissionDescription,
72
+ actions,
73
+ location: {
74
+ start: startToken.location.offset,
75
+ end: ctx.currentToken.location.offset,
76
+ line: startToken.location.line,
77
+ column: startToken.location.column,
78
+ },
79
+ });
80
+ }
81
+ else {
82
+ // If we hit an unexpected token, throw an error instead of hanging
83
+ throw new SyntaxError(`Unexpected token '${ctx.currentToken.value}' (type: ${ctx.currentToken.type}) at line ${ctx.currentToken.location.line}. ` +
84
+ `Expected 'permission' keyword or '}' to close role definition. ` +
85
+ `Note: Role definitions use 'permission resource { actions }' syntax, not field syntax with colons.`);
86
+ }
87
+ ctx.skipNewlines();
88
+ // Safety: ensure we're advancing
89
+ if (ctx.currentToken.location.offset === loopStart &&
90
+ !ctx.check(TokenType.RBRACE)) {
91
+ throw new SyntaxError(`Parser stuck in role definition at line ${ctx.currentToken.location.line}`);
92
+ }
93
+ }
94
+ ctx.consume(TokenType.RBRACE, "Expected '}' after role body");
95
+ return {
96
+ type: "RoleDefinition",
97
+ name,
98
+ description,
99
+ permissions,
100
+ inherits: inherits.length > 0 ? inherits : undefined,
101
+ location: {
102
+ start: startToken.location.offset,
103
+ end: ctx.currentToken.location.offset,
104
+ line: startToken.location.line,
105
+ column: startToken.location.column,
106
+ },
107
+ };
108
+ }
109
+ export function parseWorkflow(ctx, description) {
110
+ const startToken = ctx.consume(TokenType.WORKFLOW);
111
+ const name = ctx.consume(TokenType.IDENTIFIER, "Expected workflow name").value;
112
+ ctx.skipNewlines();
113
+ ctx.consume(TokenType.LBRACE, "Expected '{' after workflow name");
114
+ ctx.skipNewlines();
115
+ const steps = [];
116
+ let initialState = "";
117
+ const finalStates = [];
118
+ while (!ctx.check(TokenType.RBRACE) && !ctx.isAtEnd()) {
119
+ // Check for description before state
120
+ const stepDescription = ctx.parseDescriptionIfPresent();
121
+ // Handle 'initial <stateName>' to set the initial state
122
+ if (ctx.check(TokenType.INITIAL)) {
123
+ ctx.advance();
124
+ initialState = ctx.consume(TokenType.IDENTIFIER, "Expected state name after 'initial'").value;
125
+ ctx.skipNewlines();
126
+ continue;
127
+ }
128
+ if (ctx.check(TokenType.STATE)) {
129
+ ctx.advance();
130
+ const stateName = ctx.consume(TokenType.IDENTIFIER, "Expected state name").value;
131
+ if (ctx.match(TokenType.ARROW)) {
132
+ const transitions = [];
133
+ while (!ctx.check(TokenType.NEWLINE) && !ctx.check(TokenType.RBRACE) &&
134
+ !ctx.isAtEnd()) {
135
+ const toState = ctx.consume(TokenType.IDENTIFIER, "Expected target state").value;
136
+ transitions.push({
137
+ type: "Transition",
138
+ from: stateName,
139
+ to: toState,
140
+ location: {
141
+ start: startToken.location.offset,
142
+ end: ctx.currentToken.location.offset,
143
+ line: startToken.location.line,
144
+ column: startToken.location.column,
145
+ },
146
+ });
147
+ if (ctx.match(TokenType.COMMA)) {
148
+ // Continue parsing transitions
149
+ }
150
+ else {
151
+ break;
152
+ }
153
+ }
154
+ steps.push({
155
+ type: "WorkflowStep",
156
+ name: stateName,
157
+ description: stepDescription,
158
+ action: "transition",
159
+ transitions,
160
+ location: {
161
+ start: startToken.location.offset,
162
+ end: ctx.currentToken.location.offset,
163
+ line: startToken.location.line,
164
+ column: startToken.location.column,
165
+ },
166
+ });
167
+ }
168
+ ctx.skipNewlines();
169
+ continue;
170
+ }
171
+ // If we reach here, we have an unexpected token in the workflow body
172
+ throw new SyntaxError(`Unexpected token '${ctx.currentToken.type}' in workflow definition at line ${ctx.currentToken.location.line}:${ctx.currentToken.location.column}. ` +
173
+ `Workflows should contain 'initial <state>' or 'state <name> -> <transitions>' declarations. ` +
174
+ `Note: Workflows use state machine syntax, not method declarations.`);
175
+ }
176
+ ctx.consume(TokenType.RBRACE, "Expected '}' after workflow body");
177
+ return {
178
+ type: "WorkflowDefinition",
179
+ name,
180
+ description,
181
+ steps,
182
+ initialState,
183
+ finalStates,
184
+ location: {
185
+ start: startToken.location.offset,
186
+ end: ctx.currentToken.location.offset,
187
+ line: startToken.location.line,
188
+ column: startToken.location.column,
189
+ },
190
+ };
191
+ }
192
+ export function parseAgent(ctx, description) {
193
+ const startToken = ctx.consume(TokenType.AGENT);
194
+ const name = ctx.consume(TokenType.IDENTIFIER, "Expected agent name").value;
195
+ let role = "";
196
+ if (ctx.match(TokenType.COLON)) {
197
+ role = ctx.consume(TokenType.IDENTIFIER, "Expected role name").value;
198
+ }
199
+ ctx.skipNewlines();
200
+ ctx.consume(TokenType.LBRACE, "Expected '{' after agent name");
201
+ ctx.skipNewlines();
202
+ const capabilities = [];
203
+ const responsibilities = [];
204
+ let skills;
205
+ let model;
206
+ let maxConcurrent;
207
+ while (!ctx.check(TokenType.RBRACE) && !ctx.isAtEnd()) {
208
+ if (ctx.check(TokenType.CAPABILITIES)) {
209
+ ctx.advance();
210
+ ctx.consume(TokenType.COLON, "Expected ':' after capabilities");
211
+ const capList = ctx.parseStringArray();
212
+ // Convert to capability nodes
213
+ for (const cap of capList) {
214
+ capabilities.push({
215
+ type: "Capability",
216
+ verb: "can",
217
+ action: cap,
218
+ location: {
219
+ start: startToken.location.offset,
220
+ end: ctx.currentToken.location.offset,
221
+ line: startToken.location.line,
222
+ column: startToken.location.column,
223
+ },
224
+ });
225
+ }
226
+ }
227
+ else if (ctx.check(TokenType.SKILLS)) {
228
+ ctx.advance();
229
+ ctx.consume(TokenType.COLON, "Expected ':' after skills");
230
+ skills = ctx.parseStringArray();
231
+ }
232
+ else if (ctx.check(TokenType.MODEL)) {
233
+ ctx.advance();
234
+ ctx.consume(TokenType.COLON, "Expected ':' after model");
235
+ model = ctx.consume(TokenType.STRING, "Expected string value").value;
236
+ }
237
+ else if (ctx.check(TokenType.MAX_CONCURRENT)) {
238
+ ctx.advance();
239
+ ctx.consume(TokenType.COLON, "Expected ':' after max_concurrent");
240
+ maxConcurrent = parseInt(ctx.consume(TokenType.NUMBER, "Expected number value").value);
241
+ }
242
+ else if (ctx.check(TokenType.STRING) || ctx.check(TokenType.IDENTIFIER) ||
243
+ ctx.check(TokenType.PROMPT)) {
244
+ // Parse the full capability with nested capabilities support (including descriptions)
245
+ capabilities.push(ctx.parseCapability());
246
+ }
247
+ else {
248
+ ctx.advance();
249
+ }
250
+ ctx.skipNewlines();
251
+ }
252
+ ctx.consume(TokenType.RBRACE, "Expected '}' after agent body");
253
+ // Determine agent kind based on properties
254
+ // Builder agents have skills, model, or maxConcurrent properties
255
+ // Domain agents have business logic capabilities and may have roles
256
+ const agentKind = (skills !== undefined || model !== undefined ||
257
+ maxConcurrent !== undefined)
258
+ ? "builder"
259
+ : "domain";
260
+ return {
261
+ type: "AgentDefinition",
262
+ name,
263
+ description,
264
+ agentKind,
265
+ role,
266
+ responsibilities,
267
+ capabilities,
268
+ skills,
269
+ model,
270
+ maxConcurrent,
271
+ location: {
272
+ start: startToken.location.offset,
273
+ end: ctx.currentToken.location.offset,
274
+ line: startToken.location.line,
275
+ column: startToken.location.column,
276
+ },
277
+ };
278
+ }
279
+ export function parseTypeDefinition(ctx, description) {
280
+ const startToken = ctx.currentToken;
281
+ let kind = "type";
282
+ if (ctx.check(TokenType.TYPE)) {
283
+ kind = "type";
284
+ ctx.advance();
285
+ }
286
+ else if (ctx.check(TokenType.ENUM)) {
287
+ kind = "enum";
288
+ ctx.advance();
289
+ }
290
+ else if (ctx.check(TokenType.INTERFACE)) {
291
+ kind = "interface";
292
+ ctx.advance();
293
+ }
294
+ ctx.skipNewlines();
295
+ const name = ctx.consumeIdentifierOrKeyword(`Expected type name after '${kind}' keyword at line ${ctx.currentToken.location.line}:${ctx.currentToken.location.column}. Got '${ctx.currentToken.value || ctx.currentToken.type}' instead.`).value;
296
+ ctx.skipNewlines();
297
+ ctx.consume(TokenType.LBRACE, "Expected '{' after type name");
298
+ ctx.skipNewlines();
299
+ const fields = [];
300
+ const values = [];
301
+ while (!ctx.check(TokenType.RBRACE) && !ctx.isAtEnd()) {
302
+ if (kind === "enum") {
303
+ // Enum values remain plain strings (no descriptions)
304
+ values.push(ctx.consumeIdentifierOrKeyword("Expected enum value").value);
305
+ }
306
+ else {
307
+ // Check for description before field
308
+ const fieldDescription = ctx.parseDescriptionIfPresent();
309
+ const fieldName = ctx.consumeIdentifierOrKeyword("Expected field name").value;
310
+ ctx.consume(TokenType.COLON, "Expected ':' after field name");
311
+ // Parse field type with optional array syntax
312
+ let fieldType = ctx.consumeIdentifierOrKeyword("Expected field type").value;
313
+ // Handle array syntax: string[], TypeName[], TypeName[][]
314
+ while (ctx.check(TokenType.LBRACKET)) {
315
+ ctx.advance(); // consume '['
316
+ ctx.consume(TokenType.RBRACKET, "Expected ']' after '['");
317
+ fieldType += "[]";
318
+ }
319
+ fields.push({
320
+ type: "TypeField",
321
+ name: fieldName,
322
+ description: fieldDescription,
323
+ fieldType,
324
+ required: true,
325
+ location: {
326
+ start: startToken.location.offset,
327
+ end: ctx.currentToken.location.offset,
328
+ line: startToken.location.line,
329
+ column: startToken.location.column,
330
+ },
331
+ });
332
+ }
333
+ if (ctx.check(TokenType.COMMA)) {
334
+ ctx.advance();
335
+ }
336
+ ctx.skipNewlines();
337
+ }
338
+ ctx.consume(TokenType.RBRACE, "Expected '}' after type body");
339
+ return {
340
+ type: "TypeDefinition",
341
+ name,
342
+ description,
343
+ kind,
344
+ fields: fields.length > 0 ? fields : undefined,
345
+ values: values.length > 0 ? values : undefined,
346
+ location: {
347
+ start: startToken.location.offset,
348
+ end: ctx.currentToken.location.offset,
349
+ line: startToken.location.line,
350
+ column: startToken.location.column,
351
+ },
352
+ };
353
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Aexol Language Parser — Expression Parsing
3
+ *
4
+ * Condition and expression parsers (or/and/comparison/primary precedence
5
+ * chain) extracted from the Parser class. Each function receives the
6
+ * ParserCursor as its parsing context; mutual recursion between the
7
+ * expression levels goes through direct local calls.
8
+ */
9
+ import type { ConditionNode, ExpressionNode } from "../ast/nodes.ts";
10
+ import type { ParserCursor } from "./cursor.js";
11
+ export declare function parseCondition(ctx: ParserCursor): ConditionNode;
12
+ export declare function parseExpression(ctx: ParserCursor): ExpressionNode;
13
+ export declare function parseOrExpression(ctx: ParserCursor): ExpressionNode;
14
+ export declare function parseAndExpression(ctx: ParserCursor): ExpressionNode;
15
+ export declare function parseComparisonExpression(ctx: ParserCursor): ExpressionNode;
16
+ export declare function parsePrimaryExpression(ctx: ParserCursor): ExpressionNode;
17
+ //# sourceMappingURL=expressions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expressions.d.ts","sourceRoot":"","sources":["../../../../src/generated/parser/parser/expressions.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,cAAc,CAAC,GAAG,EAAE,YAAY,GAAG,aAAa,CAc/D;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,YAAY,GAAG,cAAc,CAEjE;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,cAAc,CAsBnE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,cAAc,CAsBpE;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,YAAY,GAAG,cAAc,CA+B3E;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,YAAY,GAAG,cAAc,CAmFxE"}
@@ -0,0 +1,165 @@
1
+ // GENERATED by cli-node/scripts/vendor-parser.mjs — do not edit; regenerate with `node scripts/vendor-parser.mjs`; source: packages/parser/
2
+ /**
3
+ * Aexol Language Parser — Expression Parsing
4
+ *
5
+ * Condition and expression parsers (or/and/comparison/primary precedence
6
+ * chain) extracted from the Parser class. Each function receives the
7
+ * ParserCursor as its parsing context; mutual recursion between the
8
+ * expression levels goes through direct local calls.
9
+ */
10
+ import { TokenType } from "../lexer/tokens.js";
11
+ export function parseCondition(ctx) {
12
+ const startToken = ctx.currentToken;
13
+ const expression = parseExpression(ctx);
14
+ return {
15
+ type: "Condition",
16
+ expression,
17
+ location: {
18
+ start: startToken.location.offset,
19
+ end: ctx.currentToken.location.offset,
20
+ line: startToken.location.line,
21
+ column: startToken.location.column,
22
+ },
23
+ };
24
+ }
25
+ export function parseExpression(ctx) {
26
+ return parseOrExpression(ctx);
27
+ }
28
+ export function parseOrExpression(ctx) {
29
+ const startToken = ctx.currentToken;
30
+ let left = parseAndExpression(ctx);
31
+ while (ctx.check(TokenType.OR)) {
32
+ ctx.advance();
33
+ const right = parseAndExpression(ctx);
34
+ left = {
35
+ type: "Expression",
36
+ operator: "or",
37
+ left,
38
+ right,
39
+ location: {
40
+ start: startToken.location.offset,
41
+ end: ctx.currentToken.location.offset,
42
+ line: startToken.location.line,
43
+ column: startToken.location.column,
44
+ },
45
+ };
46
+ }
47
+ return left;
48
+ }
49
+ export function parseAndExpression(ctx) {
50
+ const startToken = ctx.currentToken;
51
+ let left = parseComparisonExpression(ctx);
52
+ while (ctx.check(TokenType.AND)) {
53
+ ctx.advance();
54
+ const right = parseComparisonExpression(ctx);
55
+ left = {
56
+ type: "Expression",
57
+ operator: "and",
58
+ left,
59
+ right,
60
+ location: {
61
+ start: startToken.location.offset,
62
+ end: ctx.currentToken.location.offset,
63
+ line: startToken.location.line,
64
+ column: startToken.location.column,
65
+ },
66
+ };
67
+ }
68
+ return left;
69
+ }
70
+ export function parseComparisonExpression(ctx) {
71
+ const startToken = ctx.currentToken;
72
+ let left = parsePrimaryExpression(ctx);
73
+ while (ctx.checkAny(TokenType.EQ, TokenType.NEQ, TokenType.LT, TokenType.LTE, TokenType.GT, TokenType.GTE)) {
74
+ const op = ctx.advance().value;
75
+ const right = parsePrimaryExpression(ctx);
76
+ left = {
77
+ type: "Expression",
78
+ operator: op,
79
+ left,
80
+ right,
81
+ location: {
82
+ start: startToken.location.offset,
83
+ end: ctx.currentToken.location.offset,
84
+ line: startToken.location.line,
85
+ column: startToken.location.column,
86
+ },
87
+ };
88
+ }
89
+ return left;
90
+ }
91
+ export function parsePrimaryExpression(ctx) {
92
+ const startToken = ctx.currentToken;
93
+ if (ctx.check(TokenType.TRUE)) {
94
+ ctx.advance();
95
+ return {
96
+ type: "Expression",
97
+ value: true,
98
+ location: {
99
+ start: startToken.location.offset,
100
+ end: ctx.currentToken.location.offset,
101
+ line: startToken.location.line,
102
+ column: startToken.location.column,
103
+ },
104
+ };
105
+ }
106
+ if (ctx.check(TokenType.FALSE)) {
107
+ ctx.advance();
108
+ return {
109
+ type: "Expression",
110
+ value: false,
111
+ location: {
112
+ start: startToken.location.offset,
113
+ end: ctx.currentToken.location.offset,
114
+ line: startToken.location.line,
115
+ column: startToken.location.column,
116
+ },
117
+ };
118
+ }
119
+ if (ctx.check(TokenType.NUMBER)) {
120
+ const value = Number(ctx.advance().value);
121
+ return {
122
+ type: "Expression",
123
+ value,
124
+ location: {
125
+ start: startToken.location.offset,
126
+ end: ctx.currentToken.location.offset,
127
+ line: startToken.location.line,
128
+ column: startToken.location.column,
129
+ },
130
+ };
131
+ }
132
+ if (ctx.check(TokenType.STRING)) {
133
+ const value = ctx.advance().value;
134
+ return {
135
+ type: "Expression",
136
+ value,
137
+ location: {
138
+ start: startToken.location.offset,
139
+ end: ctx.currentToken.location.offset,
140
+ line: startToken.location.line,
141
+ column: startToken.location.column,
142
+ },
143
+ };
144
+ }
145
+ if (ctx.check(TokenType.IDENTIFIER)) {
146
+ const value = ctx.advance().value;
147
+ return {
148
+ type: "Expression",
149
+ value,
150
+ location: {
151
+ start: startToken.location.offset,
152
+ end: ctx.currentToken.location.offset,
153
+ line: startToken.location.line,
154
+ column: startToken.location.column,
155
+ },
156
+ };
157
+ }
158
+ if (ctx.check(TokenType.LPAREN)) {
159
+ ctx.advance();
160
+ const expr = parseExpression(ctx);
161
+ ctx.consume(TokenType.RPAREN, "Expected ')' after expression");
162
+ return expr;
163
+ }
164
+ throw new SyntaxError(`Unexpected token in expression: ${ctx.currentToken.type}`);
165
+ }