@virune/compiler 1.1.0-rc.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 (300) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +2 -0
  3. package/dist/src/analysis/control-flow.d.ts +9 -0
  4. package/dist/src/analysis/control-flow.d.ts.map +1 -0
  5. package/dist/src/analysis/control-flow.js +47 -0
  6. package/dist/src/analysis/control-flow.js.map +1 -0
  7. package/dist/src/ast/nodes.d.ts +495 -0
  8. package/dist/src/ast/nodes.d.ts.map +1 -0
  9. package/dist/src/ast/nodes.js +2 -0
  10. package/dist/src/ast/nodes.js.map +1 -0
  11. package/dist/src/binder/symbols.d.ts +36 -0
  12. package/dist/src/binder/symbols.d.ts.map +1 -0
  13. package/dist/src/binder/symbols.js +30 -0
  14. package/dist/src/binder/symbols.js.map +1 -0
  15. package/dist/src/checker/builtin-members.d.ts +4 -0
  16. package/dist/src/checker/builtin-members.d.ts.map +1 -0
  17. package/dist/src/checker/builtin-members.js +175 -0
  18. package/dist/src/checker/builtin-members.js.map +1 -0
  19. package/dist/src/checker/checker.d.ts +148 -0
  20. package/dist/src/checker/checker.d.ts.map +1 -0
  21. package/dist/src/checker/checker.js +2985 -0
  22. package/dist/src/checker/checker.js.map +1 -0
  23. package/dist/src/checker/effect-registry.d.ts +14 -0
  24. package/dist/src/checker/effect-registry.d.ts.map +1 -0
  25. package/dist/src/checker/effect-registry.js +11 -0
  26. package/dist/src/checker/effect-registry.js.map +1 -0
  27. package/dist/src/checker/type-operations.d.ts +27 -0
  28. package/dist/src/checker/type-operations.d.ts.map +1 -0
  29. package/dist/src/checker/type-operations.js +268 -0
  30. package/dist/src/checker/type-operations.js.map +1 -0
  31. package/dist/src/codegen/emitter.d.ts +83 -0
  32. package/dist/src/codegen/emitter.d.ts.map +1 -0
  33. package/dist/src/codegen/emitter.js +1029 -0
  34. package/dist/src/codegen/emitter.js.map +1 -0
  35. package/dist/src/codegen/helpers.d.ts +7 -0
  36. package/dist/src/codegen/helpers.d.ts.map +1 -0
  37. package/dist/src/codegen/helpers.js +48 -0
  38. package/dist/src/codegen/helpers.js.map +1 -0
  39. package/dist/src/codegen/runtime-imports.d.ts +6 -0
  40. package/dist/src/codegen/runtime-imports.d.ts.map +1 -0
  41. package/dist/src/codegen/runtime-imports.js +45 -0
  42. package/dist/src/codegen/runtime-imports.js.map +1 -0
  43. package/dist/src/codegen/writer.d.ts +14 -0
  44. package/dist/src/codegen/writer.d.ts.map +1 -0
  45. package/dist/src/codegen/writer.js +56 -0
  46. package/dist/src/codegen/writer.js.map +1 -0
  47. package/dist/src/compiler.d.ts +24 -0
  48. package/dist/src/compiler.d.ts.map +1 -0
  49. package/dist/src/compiler.js +97 -0
  50. package/dist/src/compiler.js.map +1 -0
  51. package/dist/src/diagnostics/codes.d.ts +18 -0
  52. package/dist/src/diagnostics/codes.d.ts.map +1 -0
  53. package/dist/src/diagnostics/codes.js +43 -0
  54. package/dist/src/diagnostics/codes.js.map +1 -0
  55. package/dist/src/diagnostics/diagnostic.d.ts +41 -0
  56. package/dist/src/diagnostics/diagnostic.d.ts.map +1 -0
  57. package/dist/src/diagnostics/diagnostic.js +50 -0
  58. package/dist/src/diagnostics/diagnostic.js.map +1 -0
  59. package/dist/src/diagnostics/render.d.ts +44 -0
  60. package/dist/src/diagnostics/render.d.ts.map +1 -0
  61. package/dist/src/diagnostics/render.js +44 -0
  62. package/dist/src/diagnostics/render.js.map +1 -0
  63. package/dist/src/experimental-api.d.ts +19 -0
  64. package/dist/src/experimental-api.d.ts.map +1 -0
  65. package/dist/src/experimental-api.js +17 -0
  66. package/dist/src/experimental-api.js.map +1 -0
  67. package/dist/src/hir/lower.d.ts +6 -0
  68. package/dist/src/hir/lower.d.ts.map +1 -0
  69. package/dist/src/hir/lower.js +124 -0
  70. package/dist/src/hir/lower.js.map +1 -0
  71. package/dist/src/hir/nodes.d.ts +12 -0
  72. package/dist/src/hir/nodes.d.ts.map +1 -0
  73. package/dist/src/hir/nodes.js +2 -0
  74. package/dist/src/hir/nodes.js.map +1 -0
  75. package/dist/src/index.d.ts +2 -0
  76. package/dist/src/index.d.ts.map +1 -0
  77. package/dist/src/index.js +2 -0
  78. package/dist/src/index.js.map +1 -0
  79. package/dist/src/interop/checked-api.d.ts +21 -0
  80. package/dist/src/interop/checked-api.d.ts.map +1 -0
  81. package/dist/src/interop/checked-api.js +46 -0
  82. package/dist/src/interop/checked-api.js.map +1 -0
  83. package/dist/src/interop/decision.d.ts +24 -0
  84. package/dist/src/interop/decision.d.ts.map +1 -0
  85. package/dist/src/interop/decision.js +96 -0
  86. package/dist/src/interop/decision.js.map +1 -0
  87. package/dist/src/interop/frontend-component-emission.d.ts +17 -0
  88. package/dist/src/interop/frontend-component-emission.d.ts.map +1 -0
  89. package/dist/src/interop/frontend-component-emission.js +271 -0
  90. package/dist/src/interop/frontend-component-emission.js.map +1 -0
  91. package/dist/src/interop/jsx-view-validation.d.ts +20 -0
  92. package/dist/src/interop/jsx-view-validation.d.ts.map +1 -0
  93. package/dist/src/interop/jsx-view-validation.js +847 -0
  94. package/dist/src/interop/jsx-view-validation.js.map +1 -0
  95. package/dist/src/interop/operation-api.d.ts +32 -0
  96. package/dist/src/interop/operation-api.d.ts.map +1 -0
  97. package/dist/src/interop/operation-api.js +61 -0
  98. package/dist/src/interop/operation-api.js.map +1 -0
  99. package/dist/src/interop/operation.d.ts +136 -0
  100. package/dist/src/interop/operation.d.ts.map +1 -0
  101. package/dist/src/interop/operation.js +575 -0
  102. package/dist/src/interop/operation.js.map +1 -0
  103. package/dist/src/interop/repetition-host-locator.d.ts +25 -0
  104. package/dist/src/interop/repetition-host-locator.d.ts.map +1 -0
  105. package/dist/src/interop/repetition-host-locator.js +61 -0
  106. package/dist/src/interop/repetition-host-locator.js.map +1 -0
  107. package/dist/src/interop/repetition-host-usage-validation.d.ts +11 -0
  108. package/dist/src/interop/repetition-host-usage-validation.d.ts.map +1 -0
  109. package/dist/src/interop/repetition-host-usage-validation.js +89 -0
  110. package/dist/src/interop/repetition-host-usage-validation.js.map +1 -0
  111. package/dist/src/interop/types.d.ts +365 -0
  112. package/dist/src/interop/types.d.ts.map +1 -0
  113. package/dist/src/interop/types.js +2 -0
  114. package/dist/src/interop/types.js.map +1 -0
  115. package/dist/src/mir/lower.d.ts +4 -0
  116. package/dist/src/mir/lower.d.ts.map +1 -0
  117. package/dist/src/mir/lower.js +131 -0
  118. package/dist/src/mir/lower.js.map +1 -0
  119. package/dist/src/mir/nodes.d.ts +36 -0
  120. package/dist/src/mir/nodes.d.ts.map +1 -0
  121. package/dist/src/mir/nodes.js +2 -0
  122. package/dist/src/mir/nodes.js.map +1 -0
  123. package/dist/src/project/incremental.d.ts +9 -0
  124. package/dist/src/project/incremental.d.ts.map +1 -0
  125. package/dist/src/project/incremental.js +15 -0
  126. package/dist/src/project/incremental.js.map +1 -0
  127. package/dist/src/project/project.d.ts +98 -0
  128. package/dist/src/project/project.d.ts.map +1 -0
  129. package/dist/src/project/project.js +884 -0
  130. package/dist/src/project/project.js.map +1 -0
  131. package/dist/src/public-api.d.ts +45 -0
  132. package/dist/src/public-api.d.ts.map +1 -0
  133. package/dist/src/public-api.js +37 -0
  134. package/dist/src/public-api.js.map +1 -0
  135. package/dist/src/reference/evaluator.d.ts +13 -0
  136. package/dist/src/reference/evaluator.d.ts.map +1 -0
  137. package/dist/src/reference/evaluator.js +304 -0
  138. package/dist/src/reference/evaluator.js.map +1 -0
  139. package/dist/src/selfhost/bootstrap-artifact-normalizer.d.ts +65 -0
  140. package/dist/src/selfhost/bootstrap-artifact-normalizer.d.ts.map +1 -0
  141. package/dist/src/selfhost/bootstrap-artifact-normalizer.js +226 -0
  142. package/dist/src/selfhost/bootstrap-artifact-normalizer.js.map +1 -0
  143. package/dist/src/selfhost/bootstrap-artifact-snapshot.d.ts +23 -0
  144. package/dist/src/selfhost/bootstrap-artifact-snapshot.d.ts.map +1 -0
  145. package/dist/src/selfhost/bootstrap-artifact-snapshot.js +122 -0
  146. package/dist/src/selfhost/bootstrap-artifact-snapshot.js.map +1 -0
  147. package/dist/src/selfhost/bootstrap-compiler-selection.d.ts +36 -0
  148. package/dist/src/selfhost/bootstrap-compiler-selection.d.ts.map +1 -0
  149. package/dist/src/selfhost/bootstrap-compiler-selection.js +52 -0
  150. package/dist/src/selfhost/bootstrap-compiler-selection.js.map +1 -0
  151. package/dist/src/selfhost/bootstrap-execution-probe.d.ts +42 -0
  152. package/dist/src/selfhost/bootstrap-execution-probe.d.ts.map +1 -0
  153. package/dist/src/selfhost/bootstrap-execution-probe.js +115 -0
  154. package/dist/src/selfhost/bootstrap-execution-probe.js.map +1 -0
  155. package/dist/src/selfhost/bootstrap-rollback-decision.d.ts +40 -0
  156. package/dist/src/selfhost/bootstrap-rollback-decision.d.ts.map +1 -0
  157. package/dist/src/selfhost/bootstrap-rollback-decision.js +144 -0
  158. package/dist/src/selfhost/bootstrap-rollback-decision.js.map +1 -0
  159. package/dist/src/selfhost/bootstrap-shadow-history.d.ts +49 -0
  160. package/dist/src/selfhost/bootstrap-shadow-history.d.ts.map +1 -0
  161. package/dist/src/selfhost/bootstrap-shadow-history.js +348 -0
  162. package/dist/src/selfhost/bootstrap-shadow-history.js.map +1 -0
  163. package/dist/src/selfhost/bootstrap-shadow-report.d.ts +43 -0
  164. package/dist/src/selfhost/bootstrap-shadow-report.d.ts.map +1 -0
  165. package/dist/src/selfhost/bootstrap-shadow-report.js +94 -0
  166. package/dist/src/selfhost/bootstrap-shadow-report.js.map +1 -0
  167. package/dist/src/selfhost/bootstrap-stage-executor.d.ts +53 -0
  168. package/dist/src/selfhost/bootstrap-stage-executor.d.ts.map +1 -0
  169. package/dist/src/selfhost/bootstrap-stage-executor.js +159 -0
  170. package/dist/src/selfhost/bootstrap-stage-executor.js.map +1 -0
  171. package/dist/src/selfhost/bootstrap-stage-loader.d.ts +14 -0
  172. package/dist/src/selfhost/bootstrap-stage-loader.d.ts.map +1 -0
  173. package/dist/src/selfhost/bootstrap-stage-loader.js +112 -0
  174. package/dist/src/selfhost/bootstrap-stage-loader.js.map +1 -0
  175. package/dist/src/selfhost/bootstrap-stage-pipeline.d.ts +8 -0
  176. package/dist/src/selfhost/bootstrap-stage-pipeline.d.ts.map +1 -0
  177. package/dist/src/selfhost/bootstrap-stage-pipeline.js +85 -0
  178. package/dist/src/selfhost/bootstrap-stage-pipeline.js.map +1 -0
  179. package/dist/src/selfhost/bootstrap-stage-runner.d.ts +47 -0
  180. package/dist/src/selfhost/bootstrap-stage-runner.d.ts.map +1 -0
  181. package/dist/src/selfhost/bootstrap-stage-runner.js +106 -0
  182. package/dist/src/selfhost/bootstrap-stage-runner.js.map +1 -0
  183. package/dist/src/selfhost/clean-bootstrap-evidence.d.ts +83 -0
  184. package/dist/src/selfhost/clean-bootstrap-evidence.d.ts.map +1 -0
  185. package/dist/src/selfhost/clean-bootstrap-evidence.js +233 -0
  186. package/dist/src/selfhost/clean-bootstrap-evidence.js.map +1 -0
  187. package/dist/src/selfhost/compiler-facade.d.ts +33 -0
  188. package/dist/src/selfhost/compiler-facade.d.ts.map +1 -0
  189. package/dist/src/selfhost/compiler-facade.js +65 -0
  190. package/dist/src/selfhost/compiler-facade.js.map +1 -0
  191. package/dist/src/selfhost/contract.d.ts +151 -0
  192. package/dist/src/selfhost/contract.d.ts.map +1 -0
  193. package/dist/src/selfhost/contract.js +335 -0
  194. package/dist/src/selfhost/contract.js.map +1 -0
  195. package/dist/src/selfhost/differential-artifacts.d.ts +8 -0
  196. package/dist/src/selfhost/differential-artifacts.d.ts.map +1 -0
  197. package/dist/src/selfhost/differential-artifacts.js +50 -0
  198. package/dist/src/selfhost/differential-artifacts.js.map +1 -0
  199. package/dist/src/selfhost/differential-harness.d.ts +91 -0
  200. package/dist/src/selfhost/differential-harness.d.ts.map +1 -0
  201. package/dist/src/selfhost/differential-harness.js +246 -0
  202. package/dist/src/selfhost/differential-harness.js.map +1 -0
  203. package/dist/src/selfhost/full-language-inventory-runner.d.ts +49 -0
  204. package/dist/src/selfhost/full-language-inventory-runner.d.ts.map +1 -0
  205. package/dist/src/selfhost/full-language-inventory-runner.js +225 -0
  206. package/dist/src/selfhost/full-language-inventory-runner.js.map +1 -0
  207. package/dist/src/selfhost/full-language-inventory.d.ts +42 -0
  208. package/dist/src/selfhost/full-language-inventory.d.ts.map +1 -0
  209. package/dist/src/selfhost/full-language-inventory.js +163 -0
  210. package/dist/src/selfhost/full-language-inventory.js.map +1 -0
  211. package/dist/src/selfhost/interop-resolution-witness.d.ts +35 -0
  212. package/dist/src/selfhost/interop-resolution-witness.d.ts.map +1 -0
  213. package/dist/src/selfhost/interop-resolution-witness.js +186 -0
  214. package/dist/src/selfhost/interop-resolution-witness.js.map +1 -0
  215. package/dist/src/selfhost/kernel-model-host-adapter.d.ts +28 -0
  216. package/dist/src/selfhost/kernel-model-host-adapter.d.ts.map +1 -0
  217. package/dist/src/selfhost/kernel-model-host-adapter.js +36 -0
  218. package/dist/src/selfhost/kernel-model-host-adapter.js.map +1 -0
  219. package/dist/src/selfhost/legacy-adapter.d.ts +8 -0
  220. package/dist/src/selfhost/legacy-adapter.d.ts.map +1 -0
  221. package/dist/src/selfhost/legacy-adapter.js +186 -0
  222. package/dist/src/selfhost/legacy-adapter.js.map +1 -0
  223. package/dist/src/selfhost/module-graph.d.ts +57 -0
  224. package/dist/src/selfhost/module-graph.d.ts.map +1 -0
  225. package/dist/src/selfhost/module-graph.js +267 -0
  226. package/dist/src/selfhost/module-graph.js.map +1 -0
  227. package/dist/src/selfhost/mvp-adapter.d.ts +19 -0
  228. package/dist/src/selfhost/mvp-adapter.d.ts.map +1 -0
  229. package/dist/src/selfhost/mvp-adapter.js +186 -0
  230. package/dist/src/selfhost/mvp-adapter.js.map +1 -0
  231. package/dist/src/selfhost/node-executor.d.ts +6 -0
  232. package/dist/src/selfhost/node-executor.d.ts.map +1 -0
  233. package/dist/src/selfhost/node-executor.js +138 -0
  234. package/dist/src/selfhost/node-executor.js.map +1 -0
  235. package/dist/src/selfhost/project-compiler-adapter.d.ts +77 -0
  236. package/dist/src/selfhost/project-compiler-adapter.d.ts.map +1 -0
  237. package/dist/src/selfhost/project-compiler-adapter.js +358 -0
  238. package/dist/src/selfhost/project-compiler-adapter.js.map +1 -0
  239. package/dist/src/selfhost/project-differential-adapter.d.ts +15 -0
  240. package/dist/src/selfhost/project-differential-adapter.d.ts.map +1 -0
  241. package/dist/src/selfhost/project-differential-adapter.js +65 -0
  242. package/dist/src/selfhost/project-differential-adapter.js.map +1 -0
  243. package/dist/src/selfhost/promotion-evidence.d.ts +62 -0
  244. package/dist/src/selfhost/promotion-evidence.d.ts.map +1 -0
  245. package/dist/src/selfhost/promotion-evidence.js +332 -0
  246. package/dist/src/selfhost/promotion-evidence.js.map +1 -0
  247. package/dist/src/selfhost/promotion-policy-replay-v2.d.ts +54 -0
  248. package/dist/src/selfhost/promotion-policy-replay-v2.d.ts.map +1 -0
  249. package/dist/src/selfhost/promotion-policy-replay-v2.js +343 -0
  250. package/dist/src/selfhost/promotion-policy-replay-v2.js.map +1 -0
  251. package/dist/src/selfhost/promotion-shadow-history-v2.d.ts +55 -0
  252. package/dist/src/selfhost/promotion-shadow-history-v2.d.ts.map +1 -0
  253. package/dist/src/selfhost/promotion-shadow-history-v2.js +227 -0
  254. package/dist/src/selfhost/promotion-shadow-history-v2.js.map +1 -0
  255. package/dist/src/selfhost/promotion-subject.d.ts +34 -0
  256. package/dist/src/selfhost/promotion-subject.d.ts.map +1 -0
  257. package/dist/src/selfhost/promotion-subject.js +141 -0
  258. package/dist/src/selfhost/promotion-subject.js.map +1 -0
  259. package/dist/src/selfhost/source-manifest.d.ts +31 -0
  260. package/dist/src/selfhost/source-manifest.d.ts.map +1 -0
  261. package/dist/src/selfhost/source-manifest.js +194 -0
  262. package/dist/src/selfhost/source-manifest.js.map +1 -0
  263. package/dist/src/selfhost/stage-compiler-facade.d.ts +25 -0
  264. package/dist/src/selfhost/stage-compiler-facade.d.ts.map +1 -0
  265. package/dist/src/selfhost/stage-compiler-facade.js +100 -0
  266. package/dist/src/selfhost/stage-compiler-facade.js.map +1 -0
  267. package/dist/src/semantic-evidence/snapshot.d.ts +114 -0
  268. package/dist/src/semantic-evidence/snapshot.d.ts.map +1 -0
  269. package/dist/src/semantic-evidence/snapshot.js +336 -0
  270. package/dist/src/semantic-evidence/snapshot.js.map +1 -0
  271. package/dist/src/source.d.ts +25 -0
  272. package/dist/src/source.d.ts.map +1 -0
  273. package/dist/src/source.js +10 -0
  274. package/dist/src/source.js.map +1 -0
  275. package/dist/src/syntax/cst-to-ast.d.ts +108 -0
  276. package/dist/src/syntax/cst-to-ast.d.ts.map +1 -0
  277. package/dist/src/syntax/cst-to-ast.js +383 -0
  278. package/dist/src/syntax/cst-to-ast.js.map +1 -0
  279. package/dist/src/syntax/documentation.d.ts +11 -0
  280. package/dist/src/syntax/documentation.d.ts.map +1 -0
  281. package/dist/src/syntax/documentation.js +261 -0
  282. package/dist/src/syntax/documentation.js.map +1 -0
  283. package/dist/src/syntax/parser.d.ts +114 -0
  284. package/dist/src/syntax/parser.d.ts.map +1 -0
  285. package/dist/src/syntax/parser.js +970 -0
  286. package/dist/src/syntax/parser.js.map +1 -0
  287. package/dist/src/syntax/syntax-metadata.d.ts +8 -0
  288. package/dist/src/syntax/syntax-metadata.d.ts.map +1 -0
  289. package/dist/src/syntax/syntax-metadata.js +14 -0
  290. package/dist/src/syntax/syntax-metadata.js.map +1 -0
  291. package/dist/src/syntax/tokens.d.ts +96 -0
  292. package/dist/src/syntax/tokens.d.ts.map +1 -0
  293. package/dist/src/syntax/tokens.js +260 -0
  294. package/dist/src/syntax/tokens.js.map +1 -0
  295. package/dist/src/types/types.d.ts +97 -0
  296. package/dist/src/types/types.d.ts.map +1 -0
  297. package/dist/src/types/types.js +105 -0
  298. package/dist/src/types/types.js.map +1 -0
  299. package/package.json +47 -0
  300. package/schema/diagnostics-v1.schema.json +75 -0
@@ -0,0 +1,970 @@
1
+ import { CstParser } from 'chevrotain';
2
+ import { allTokens, AndAnd, At, Bang, BangEqual, Bar, BigIntLiteral, Colon, Comma, Dot, EqualEqual, Equals, FatArrow, FloatLiteral, Greater, GreaterEqual, Identifier, IdentifierName, IntLiteral, KwAs, KwAsync, KwAwait, KwBreak, KwBy, KwChildren, KwComponent, KwConst, KwContinue, KwDerives, KwDefer, KwDiscard, KwElse, KwEnum, KwExtern, KwFalse, KwFn, KwFor, KwFrom, KwIf, KwImport, KwIn, KwJs, KwLet, KwMatch, KwModule, KwMut, KwNewtype, KwParallel, KwPub, KwRecord, KwReturn, KwTest, KwThen, KwTrue, KwTry, KwType, KwUnsafe, KwUses, KwView, KwWhile, KwWith, LBrace, LBracket, Less, LessEqual, LParen, Minus, NewLine, OrOr, Percent, Pipe, Plus, Question, RangeInclusive, RBrace, RBracket, RParen, Slash, Spread, Star, StringLiteral, ThinArrow, Underscore, } from './tokens.js';
3
+ const errorProvider = {
4
+ buildMismatchTokenMessage({ expected, actual }) {
5
+ return `Expected ${expected.LABEL ?? expected.name}, received ${actual.image || 'end of file'}`;
6
+ },
7
+ buildNotAllInputParsedMessage({ firstRedundant }) {
8
+ return `Unexpected token ${firstRedundant.image}`;
9
+ },
10
+ buildNoViableAltMessage({ actual }) {
11
+ return `Unexpected token ${actual[0]?.image ?? 'end of file'}`;
12
+ },
13
+ buildEarlyExitMessage({ actual }) {
14
+ return `Expected another item before ${actual[0]?.image ?? 'end of file'}`;
15
+ },
16
+ };
17
+ export class ViruneParser extends CstParser {
18
+ constructor() {
19
+ super(allTokens, { recoveryEnabled: true, nodeLocationTracking: 'full', errorMessageProvider: errorProvider });
20
+ const $ = this;
21
+ $.RULE('module', () => {
22
+ $.MANY(() => $.CONSUME(NewLine));
23
+ $.OPTION(() => {
24
+ $.CONSUME(KwUnsafe);
25
+ $.CONSUME(KwModule);
26
+ $.SUBRULE($.lineEnd);
27
+ $.MANY6(() => $.CONSUME4(NewLine));
28
+ });
29
+ $.MANY2(() => {
30
+ $.SUBRULE($.importDeclaration);
31
+ $.MANY3(() => $.CONSUME2(NewLine));
32
+ });
33
+ $.MANY4(() => {
34
+ $.SUBRULE($.declaration);
35
+ $.MANY5(() => $.CONSUME3(NewLine));
36
+ });
37
+ });
38
+ $.RULE('importDeclaration', () => {
39
+ $.OPTION(() => $.CONSUME(KwPub));
40
+ $.CONSUME(KwImport);
41
+ $.OPTION2(() => $.CONSUME(KwJs));
42
+ $.OPTION3(() => $.CONSUME(KwType));
43
+ $.OR([
44
+ { GATE: () => this.LA(1).tokenType === StringLiteral, ALT: () => $.CONSUME(StringLiteral) },
45
+ { GATE: () => this.LA(1).tokenType === LBrace, ALT: () => {
46
+ $.CONSUME(LBrace);
47
+ $.MANY(() => $.CONSUME(NewLine));
48
+ $.OPTION4(() => {
49
+ $.SUBRULE($.importItem);
50
+ $.MANY2(() => {
51
+ $.CONSUME(Comma);
52
+ $.MANY3(() => $.CONSUME2(NewLine));
53
+ $.OPTION5(() => $.SUBRULE2($.importItem));
54
+ });
55
+ });
56
+ $.CONSUME(RBrace);
57
+ $.CONSUME(KwFrom);
58
+ $.CONSUME2(StringLiteral);
59
+ } },
60
+ { GATE: () => this.LA(1).tokenType === Star, ALT: () => {
61
+ $.CONSUME(Star);
62
+ $.CONSUME(KwAs);
63
+ $.CONSUME(Identifier);
64
+ $.CONSUME2(KwFrom);
65
+ $.CONSUME3(StringLiteral);
66
+ } },
67
+ { ALT: () => {
68
+ $.CONSUME2(Identifier);
69
+ $.CONSUME3(KwFrom);
70
+ $.CONSUME4(StringLiteral);
71
+ } },
72
+ ]);
73
+ $.SUBRULE($.lineEnd);
74
+ });
75
+ $.RULE('importItem', () => {
76
+ $.CONSUME(Identifier);
77
+ $.OPTION(() => {
78
+ $.CONSUME(KwAs);
79
+ $.CONSUME2(Identifier);
80
+ });
81
+ });
82
+ $.RULE('declaration', () => {
83
+ $.MANY(() => $.SUBRULE($.attribute));
84
+ $.OR([
85
+ { GATE: () => this.isFunctionStart(), ALT: () => $.SUBRULE($.functionDeclaration) },
86
+ { GATE: () => this.isComponentStart(), ALT: () => $.SUBRULE($.componentDeclaration) },
87
+ { GATE: () => this.isRecordStart(), ALT: () => $.SUBRULE($.recordDeclaration) },
88
+ { GATE: () => this.isEnumStart(), ALT: () => $.SUBRULE($.enumDeclaration) },
89
+ { GATE: () => this.isNewtypeStart(), ALT: () => $.SUBRULE($.newtypeDeclaration) },
90
+ { GATE: () => this.isTypeAliasStart(), ALT: () => $.SUBRULE($.typeAliasDeclaration) },
91
+ { GATE: () => this.isExternStart(), ALT: () => $.SUBRULE($.externDeclaration) },
92
+ { GATE: () => this.isTestStart(), ALT: () => $.SUBRULE($.testDeclaration) },
93
+ { ALT: () => $.SUBRULE($.topLevelLetDeclaration) },
94
+ ]);
95
+ });
96
+ $.RULE('attribute', () => {
97
+ $.CONSUME(At);
98
+ $.CONSUME(Identifier);
99
+ $.OPTION(() => {
100
+ $.CONSUME(LParen);
101
+ $.OPTION2(() => $.SUBRULE($.argumentList));
102
+ $.CONSUME(RParen);
103
+ });
104
+ $.MANY(() => $.CONSUME(NewLine));
105
+ });
106
+ $.RULE('functionDeclaration', () => {
107
+ $.OPTION(() => $.CONSUME(KwPub));
108
+ $.OPTION2(() => $.CONSUME(KwAsync));
109
+ $.CONSUME(KwFn);
110
+ $.CONSUME(Identifier);
111
+ $.OPTION3(() => $.SUBRULE($.typeParameters));
112
+ $.CONSUME(LParen);
113
+ $.MANY(() => $.CONSUME(NewLine));
114
+ $.OPTION4(() => $.SUBRULE($.parameterList));
115
+ $.MANY2(() => $.CONSUME2(NewLine));
116
+ $.CONSUME(RParen);
117
+ $.OPTION5(() => {
118
+ $.CONSUME(ThinArrow);
119
+ $.SUBRULE($.typeReference);
120
+ });
121
+ $.OPTION6(() => $.SUBRULE($.usesClause));
122
+ $.OR([
123
+ { ALT: () => $.SUBRULE($.block) },
124
+ { ALT: () => { $.CONSUME(FatArrow); $.SUBRULE($.expression); $.SUBRULE($.lineEnd); } },
125
+ ]);
126
+ });
127
+ $.RULE('componentDeclaration', () => {
128
+ $.OPTION(() => $.CONSUME(KwPub));
129
+ $.CONSUME(KwComponent);
130
+ $.CONSUME(Identifier);
131
+ $.CONSUME(LParen);
132
+ $.MANY(() => $.CONSUME(NewLine));
133
+ $.OPTION2(() => $.SUBRULE($.parameterList));
134
+ $.MANY2(() => $.CONSUME2(NewLine));
135
+ $.CONSUME(RParen);
136
+ $.SUBRULE($.usesClause);
137
+ $.SUBRULE($.block);
138
+ });
139
+ $.RULE('typeParameters', () => {
140
+ $.CONSUME(Less);
141
+ $.CONSUME(Identifier);
142
+ $.MANY(() => { $.CONSUME(Comma); $.CONSUME2(Identifier); });
143
+ $.CONSUME(Greater);
144
+ });
145
+ $.RULE('parameterList', () => {
146
+ $.SUBRULE($.parameter);
147
+ $.MANY(() => {
148
+ $.CONSUME(Comma);
149
+ $.MANY2(() => $.CONSUME(NewLine));
150
+ $.OPTION(() => $.SUBRULE2($.parameter));
151
+ });
152
+ });
153
+ $.RULE('parameter', () => {
154
+ $.CONSUME(Identifier);
155
+ $.OPTION(() => $.CONSUME(Question));
156
+ $.CONSUME(Colon);
157
+ $.SUBRULE($.typeReference);
158
+ });
159
+ $.RULE('usesClause', () => {
160
+ $.CONSUME(KwUses);
161
+ $.OR([
162
+ { ALT: () => $.CONSUME(Identifier) },
163
+ { ALT: () => $.CONSUME(Star) },
164
+ ]);
165
+ $.MANY(() => {
166
+ $.CONSUME(Comma);
167
+ $.OR2([
168
+ { ALT: () => $.CONSUME2(Identifier) },
169
+ { ALT: () => $.CONSUME2(Star) },
170
+ ]);
171
+ });
172
+ });
173
+ $.RULE('recordDeclaration', () => {
174
+ $.OPTION(() => $.CONSUME(KwPub));
175
+ $.CONSUME(KwRecord);
176
+ $.CONSUME(Identifier);
177
+ $.OPTION2(() => $.SUBRULE($.typeParameters));
178
+ $.OPTION3(() => $.SUBRULE($.derivesClause));
179
+ $.CONSUME(LBrace);
180
+ $.MANY(() => $.CONSUME(NewLine));
181
+ $.MANY2(() => {
182
+ $.SUBRULE($.recordField);
183
+ $.MANY3(() => $.CONSUME2(NewLine));
184
+ });
185
+ $.CONSUME(RBrace);
186
+ });
187
+ $.RULE('recordField', () => {
188
+ $.MANY(() => $.SUBRULE($.attribute));
189
+ $.CONSUME(Identifier);
190
+ $.CONSUME(Colon);
191
+ $.SUBRULE($.typeReference);
192
+ $.OPTION(() => $.CONSUME(Comma));
193
+ });
194
+ $.RULE('derivesClause', () => {
195
+ $.CONSUME(KwDerives);
196
+ $.CONSUME(Identifier);
197
+ $.MANY(() => { $.CONSUME(Comma); $.CONSUME2(Identifier); });
198
+ });
199
+ $.RULE('enumDeclaration', () => {
200
+ $.OPTION(() => $.CONSUME(KwPub));
201
+ $.CONSUME(KwEnum);
202
+ $.CONSUME(Identifier);
203
+ $.OPTION2(() => $.SUBRULE($.typeParameters));
204
+ $.OPTION3(() => $.SUBRULE($.derivesClause));
205
+ $.CONSUME(LBrace);
206
+ $.MANY(() => $.CONSUME(NewLine));
207
+ $.MANY2(() => {
208
+ $.SUBRULE($.enumVariant);
209
+ $.MANY3(() => $.CONSUME2(NewLine));
210
+ });
211
+ $.CONSUME(RBrace);
212
+ });
213
+ $.RULE('enumVariant', () => {
214
+ $.CONSUME(Identifier);
215
+ $.OPTION(() => {
216
+ $.CONSUME(LParen);
217
+ $.OPTION2(() => {
218
+ $.SUBRULE($.typeReference);
219
+ $.MANY(() => { $.CONSUME(Comma); $.SUBRULE2($.typeReference); });
220
+ });
221
+ $.CONSUME(RParen);
222
+ });
223
+ $.OPTION3(() => $.CONSUME2(Comma));
224
+ });
225
+ $.RULE('newtypeDeclaration', () => {
226
+ $.OPTION(() => $.CONSUME(KwPub));
227
+ $.CONSUME(KwNewtype);
228
+ $.CONSUME(Identifier);
229
+ $.CONSUME(Equals);
230
+ $.SUBRULE($.typeReference);
231
+ $.SUBRULE($.lineEnd);
232
+ });
233
+ $.RULE('typeAliasDeclaration', () => {
234
+ $.OPTION(() => $.CONSUME(KwPub));
235
+ $.CONSUME(KwType);
236
+ $.CONSUME(Identifier);
237
+ $.OPTION2(() => $.SUBRULE($.typeParameters));
238
+ $.CONSUME(Equals);
239
+ $.SUBRULE($.typeReference);
240
+ $.SUBRULE($.lineEnd);
241
+ });
242
+ $.RULE('externDeclaration', () => {
243
+ $.OPTION(() => $.CONSUME(KwUnsafe));
244
+ $.CONSUME(KwExtern);
245
+ $.CONSUME(KwJs);
246
+ $.CONSUME(StringLiteral);
247
+ $.CONSUME(LBrace);
248
+ $.MANY(() => $.CONSUME(NewLine));
249
+ $.MANY2(() => { $.SUBRULE($.externFunction); $.MANY3(() => $.CONSUME2(NewLine)); });
250
+ $.CONSUME(RBrace);
251
+ });
252
+ $.RULE('externFunction', () => {
253
+ $.OPTION(() => $.CONSUME(KwAsync));
254
+ $.CONSUME(KwFn);
255
+ $.CONSUME(Identifier);
256
+ $.CONSUME(LParen);
257
+ $.OPTION2(() => $.SUBRULE($.parameterList));
258
+ $.CONSUME(RParen);
259
+ $.CONSUME(ThinArrow);
260
+ $.SUBRULE($.typeReference);
261
+ $.OPTION3(() => $.SUBRULE($.usesClause));
262
+ $.CONSUME(Equals);
263
+ $.CONSUME(StringLiteral);
264
+ $.SUBRULE($.lineEnd);
265
+ });
266
+ $.RULE('testDeclaration', () => {
267
+ $.OPTION(() => $.CONSUME(KwAsync));
268
+ $.CONSUME(KwTest);
269
+ $.CONSUME(StringLiteral);
270
+ $.SUBRULE($.block);
271
+ });
272
+ $.RULE('topLevelLetDeclaration', () => {
273
+ $.OPTION(() => $.CONSUME(KwPub));
274
+ $.OR([
275
+ { ALT: () => $.CONSUME(KwLet) },
276
+ { ALT: () => $.CONSUME(KwConst) },
277
+ ]);
278
+ $.CONSUME(Identifier);
279
+ $.OPTION2(() => { $.CONSUME(Colon); $.SUBRULE($.typeReference); });
280
+ $.CONSUME(Equals);
281
+ $.SUBRULE($.expression);
282
+ $.SUBRULE($.lineEnd);
283
+ });
284
+ $.RULE('typeReference', () => {
285
+ $.OR([
286
+ { GATE: () => this.LA(1).tokenType === KwFn || (this.LA(1).tokenType === KwAsync && this.LA(2).tokenType === KwFn), ALT: () => $.SUBRULE($.functionTypeReference) },
287
+ { GATE: () => this.LA(1).tokenType === LParen, ALT: () => $.SUBRULE($.tupleTypeReference) },
288
+ { ALT: () => {
289
+ $.CONSUME(Identifier);
290
+ $.OPTION(() => {
291
+ $.CONSUME(Less);
292
+ $.SUBRULE($.typeReference);
293
+ $.MANY(() => { $.CONSUME(Comma); $.SUBRULE2($.typeReference); });
294
+ $.CONSUME(Greater);
295
+ });
296
+ } },
297
+ ]);
298
+ $.OPTION2(() => $.CONSUME(Question));
299
+ });
300
+ $.RULE('tupleTypeReference', () => {
301
+ $.CONSUME(LParen);
302
+ $.SUBRULE($.typeReference);
303
+ $.CONSUME(Comma);
304
+ $.SUBRULE2($.typeReference);
305
+ $.MANY(() => { $.CONSUME2(Comma); $.SUBRULE3($.typeReference); });
306
+ $.CONSUME(RParen);
307
+ });
308
+ $.RULE('functionTypeReference', () => {
309
+ $.OPTION(() => $.CONSUME(KwAsync));
310
+ $.CONSUME(KwFn);
311
+ $.CONSUME(LParen);
312
+ $.OPTION2(() => {
313
+ $.SUBRULE($.typeReference);
314
+ $.MANY(() => { $.CONSUME(Comma); $.SUBRULE2($.typeReference); });
315
+ });
316
+ $.CONSUME(RParen);
317
+ $.CONSUME(ThinArrow);
318
+ $.SUBRULE3($.typeReference);
319
+ $.OPTION3(() => $.SUBRULE($.usesClause));
320
+ });
321
+ $.RULE('block', () => {
322
+ $.CONSUME(LBrace);
323
+ $.MANY(() => $.CONSUME(NewLine));
324
+ $.MANY2(() => {
325
+ $.SUBRULE($.statement);
326
+ $.MANY3(() => $.CONSUME2(NewLine));
327
+ });
328
+ $.CONSUME(RBrace);
329
+ });
330
+ $.RULE('statement', () => {
331
+ $.OR([
332
+ { ALT: () => $.SUBRULE($.letStatement) },
333
+ { ALT: () => $.SUBRULE($.returnStatement) },
334
+ { GATE: () => this.LA(1).tokenType === KwIf && this.LA(2).tokenType !== KwAwait, ALT: () => $.SUBRULE($.ifStatement) },
335
+ { ALT: () => $.SUBRULE($.forStatement) },
336
+ { ALT: () => $.SUBRULE($.whileStatement) },
337
+ { ALT: () => $.SUBRULE($.breakStatement) },
338
+ { ALT: () => $.SUBRULE($.continueStatement) },
339
+ { ALT: () => $.SUBRULE($.discardStatement) },
340
+ { ALT: () => $.SUBRULE($.deferStatement) },
341
+ { GATE: () => this.isAssignmentStart(), ALT: () => $.SUBRULE($.assignmentStatement) },
342
+ { ALT: () => $.SUBRULE($.expressionStatement) },
343
+ ]);
344
+ });
345
+ $.RULE('letStatement', () => {
346
+ $.CONSUME(KwLet);
347
+ $.OPTION(() => $.CONSUME(KwMut));
348
+ $.CONSUME(Identifier);
349
+ $.OPTION2(() => { $.CONSUME(Colon); $.SUBRULE($.typeReference); });
350
+ $.CONSUME(Equals);
351
+ $.SUBRULE($.expression);
352
+ $.SUBRULE($.lineEnd);
353
+ });
354
+ $.RULE('returnStatement', () => {
355
+ $.CONSUME(KwReturn);
356
+ $.OPTION(() => $.SUBRULE($.expression));
357
+ $.SUBRULE($.lineEnd);
358
+ });
359
+ $.RULE('ifStatement', () => {
360
+ $.CONSUME(KwIf);
361
+ $.SUBRULE($.expression);
362
+ $.SUBRULE($.block);
363
+ $.OPTION(() => { $.CONSUME(KwElse); $.OR([{ ALT: () => $.SUBRULE2($.block) }, { ALT: () => $.SUBRULE2($.ifStatement) }]); });
364
+ });
365
+ $.RULE('forStatement', () => {
366
+ $.CONSUME(KwFor);
367
+ $.CONSUME(Identifier);
368
+ $.CONSUME(KwIn);
369
+ $.SUBRULE($.expression);
370
+ $.SUBRULE($.block);
371
+ });
372
+ $.RULE('whileStatement', () => {
373
+ $.CONSUME(KwWhile);
374
+ $.SUBRULE($.expression);
375
+ $.SUBRULE($.block);
376
+ });
377
+ $.RULE('breakStatement', () => {
378
+ $.CONSUME(KwBreak);
379
+ $.SUBRULE($.lineEnd);
380
+ });
381
+ $.RULE('continueStatement', () => {
382
+ $.CONSUME(KwContinue);
383
+ $.SUBRULE($.lineEnd);
384
+ });
385
+ $.RULE('discardStatement', () => {
386
+ $.CONSUME(KwDiscard);
387
+ $.SUBRULE($.expression);
388
+ $.SUBRULE($.lineEnd);
389
+ });
390
+ $.RULE('deferStatement', () => {
391
+ $.CONSUME(KwDefer);
392
+ $.SUBRULE($.expression);
393
+ $.SUBRULE($.lineEnd);
394
+ });
395
+ $.RULE('assignmentStatement', () => {
396
+ $.SUBRULE($.postfixExpression);
397
+ $.CONSUME(Equals);
398
+ $.SUBRULE($.expression);
399
+ $.SUBRULE($.lineEnd);
400
+ });
401
+ $.RULE('expressionStatement', () => {
402
+ $.SUBRULE($.expression);
403
+ $.SUBRULE($.lineEnd);
404
+ });
405
+ $.RULE('lineEnd', () => {
406
+ $.AT_LEAST_ONE(() => $.CONSUME(NewLine));
407
+ });
408
+ $.RULE('expression', () => $.SUBRULE($.pipelineExpression));
409
+ $.RULE('pipelineExpression', () => {
410
+ $.SUBRULE($.orExpression);
411
+ $.MANY(() => { $.CONSUME(Pipe); $.SUBRULE2($.orExpression); });
412
+ });
413
+ $.RULE('orExpression', () => {
414
+ $.SUBRULE($.andExpression);
415
+ $.MANY(() => { $.CONSUME(OrOr); $.SUBRULE2($.andExpression); });
416
+ });
417
+ $.RULE('andExpression', () => {
418
+ $.SUBRULE($.equalityExpression);
419
+ $.MANY(() => { $.CONSUME(AndAnd); $.SUBRULE2($.equalityExpression); });
420
+ });
421
+ $.RULE('equalityExpression', () => {
422
+ $.SUBRULE($.comparisonExpression);
423
+ $.MANY(() => { $.OR([{ ALT: () => $.CONSUME(EqualEqual) }, { ALT: () => $.CONSUME(BangEqual) }]); $.SUBRULE2($.comparisonExpression); });
424
+ });
425
+ $.RULE('comparisonExpression', () => {
426
+ $.SUBRULE($.additiveExpression);
427
+ $.MANY(() => { $.OR([{ ALT: () => $.CONSUME(Less) }, { ALT: () => $.CONSUME(LessEqual) }, { ALT: () => $.CONSUME(Greater) }, { ALT: () => $.CONSUME(GreaterEqual) }]); $.SUBRULE2($.additiveExpression); });
428
+ });
429
+ $.RULE('additiveExpression', () => {
430
+ $.SUBRULE($.multiplicativeExpression);
431
+ $.MANY(() => { $.OR([{ ALT: () => $.CONSUME(Plus) }, { ALT: () => $.CONSUME(Minus) }]); $.SUBRULE2($.multiplicativeExpression); });
432
+ });
433
+ $.RULE('multiplicativeExpression', () => {
434
+ $.SUBRULE($.unaryExpression);
435
+ $.MANY(() => { $.OR([{ ALT: () => $.CONSUME(Star) }, { ALT: () => $.CONSUME(Slash) }, { ALT: () => $.CONSUME(Percent) }]); $.SUBRULE2($.unaryExpression); });
436
+ });
437
+ $.RULE('unaryExpression', () => {
438
+ $.OR([
439
+ { ALT: () => { $.OR2([{ ALT: () => $.CONSUME(Bang) }, { ALT: () => $.CONSUME(Minus) }, { ALT: () => $.CONSUME(KwAwait) }]); $.SUBRULE($.unaryExpression); } },
440
+ { ALT: () => $.SUBRULE($.postfixExpression) },
441
+ ]);
442
+ });
443
+ $.RULE('postfixExpression', () => {
444
+ $.SUBRULE($.primaryExpression);
445
+ $.MANY({
446
+ GATE: () => this.isCallSuffixStart() || [Dot, LBracket, Question, KwWith].includes(this.LA(1).tokenType),
447
+ DEF: () => {
448
+ $.OR([
449
+ { GATE: () => this.isCallSuffixStart(), ALT: () => $.SUBRULE($.callSuffix) },
450
+ { ALT: () => { $.CONSUME(Dot); $.CONSUME(IdentifierName); } },
451
+ { ALT: () => $.SUBRULE($.indexSuffix) },
452
+ { ALT: () => $.CONSUME(Question) },
453
+ { ALT: () => { $.CONSUME(KwWith); $.SUBRULE($.recordFieldBlock); } },
454
+ ]);
455
+ },
456
+ });
457
+ });
458
+ $.RULE('indexSuffix', () => {
459
+ $.CONSUME(LBracket);
460
+ $.SUBRULE($.expression);
461
+ $.CONSUME(RBracket);
462
+ });
463
+ $.RULE('callSuffix', () => {
464
+ $.OPTION(() => $.SUBRULE($.typeArguments));
465
+ $.CONSUME(LParen);
466
+ $.OPTION2(() => $.SUBRULE($.argumentList));
467
+ $.CONSUME(RParen);
468
+ });
469
+ $.RULE('typeArguments', () => {
470
+ $.CONSUME(Less);
471
+ $.SUBRULE($.typeReference);
472
+ $.MANY(() => { $.CONSUME(Comma); $.SUBRULE2($.typeReference); });
473
+ $.CONSUME(Greater);
474
+ });
475
+ $.RULE('argumentList', () => {
476
+ $.SUBRULE($.expression);
477
+ $.MANY(() => { $.CONSUME(Comma); $.MANY2(() => $.CONSUME(NewLine)); $.OPTION(() => $.SUBRULE2($.expression)); });
478
+ });
479
+ $.RULE('primaryExpression', () => {
480
+ $.OR([
481
+ { ALT: () => $.CONSUME(StringLiteral) },
482
+ { ALT: () => $.CONSUME(BigIntLiteral) },
483
+ { ALT: () => $.CONSUME(FloatLiteral) },
484
+ { ALT: () => $.CONSUME(IntLiteral) },
485
+ { ALT: () => $.CONSUME(KwTrue) },
486
+ { ALT: () => $.CONSUME(KwFalse) },
487
+ { ALT: () => $.CONSUME(Underscore) },
488
+ { GATE: () => this.LA(1).tokenType === KwView, ALT: () => $.SUBRULE($.viewExpression) },
489
+ { GATE: () => this.isRecordExpressionStart(), ALT: () => $.SUBRULE($.recordExpression) },
490
+ { ALT: () => $.CONSUME(Identifier) },
491
+ { ALT: () => $.SUBRULE($.listExpression) },
492
+ { ALT: () => $.SUBRULE($.parenthesizedOrTupleExpression) },
493
+ { ALT: () => $.SUBRULE($.conditionalExpression) },
494
+ { ALT: () => $.SUBRULE($.matchExpression) },
495
+ { ALT: () => $.SUBRULE($.lambdaExpression) },
496
+ { ALT: () => $.SUBRULE($.parallelExpression) },
497
+ { ALT: () => $.SUBRULE($.contextualAggregateExpression) },
498
+ ]);
499
+ });
500
+ $.RULE('viewExpression', () => {
501
+ $.CONSUME(KwView);
502
+ $.SUBRULE($.viewBlock);
503
+ });
504
+ $.RULE('viewBlock', () => {
505
+ $.CONSUME(LBrace);
506
+ $.MANY(() => $.CONSUME(NewLine));
507
+ $.MANY2(() => {
508
+ $.SUBRULE($.viewChild);
509
+ $.MANY3(() => $.CONSUME2(NewLine));
510
+ });
511
+ $.CONSUME(RBrace);
512
+ });
513
+ $.RULE('viewChild', () => {
514
+ $.OR([
515
+ { GATE: () => this.LA(1).tokenType === KwIf, ALT: () => $.SUBRULE($.viewConditional) },
516
+ { GATE: () => this.LA(1).tokenType === KwFor, ALT: () => $.SUBRULE($.viewRepetition) },
517
+ { GATE: () => this.LA(1).tokenType === KwChildren && this.LA(2).tokenType === NewLine, ALT: () => $.SUBRULE($.viewChildrenSlot) },
518
+ { GATE: () => this.LA(1).tokenType === StringLiteral, ALT: () => $.SUBRULE($.viewTextChild) },
519
+ { GATE: () => this.LA(1).tokenType === LBrace, ALT: () => $.SUBRULE($.viewExpressionChild) },
520
+ { ALT: () => $.SUBRULE($.viewElement) },
521
+ ]);
522
+ });
523
+ $.RULE('viewElement', () => {
524
+ $.SUBRULE($.viewTag);
525
+ $.CONSUME(LParen);
526
+ $.MANY(() => $.CONSUME(NewLine));
527
+ $.OPTION(() => $.SUBRULE($.viewPropertyList));
528
+ $.MANY2(() => $.CONSUME2(NewLine));
529
+ $.CONSUME(RParen);
530
+ $.OR([
531
+ { GATE: () => this.LA(1).tokenType === LBrace, ALT: () => $.SUBRULE($.viewBlock) },
532
+ { ALT: () => $.SUBRULE($.lineEnd) },
533
+ ]);
534
+ });
535
+ $.RULE('viewTag', () => {
536
+ $.CONSUME(Identifier);
537
+ $.MANY(() => { $.CONSUME(Dot); $.CONSUME(IdentifierName); });
538
+ });
539
+ $.RULE('viewPropertyList', () => {
540
+ $.SUBRULE($.viewProperty);
541
+ $.MANY(() => {
542
+ $.CONSUME(Comma);
543
+ $.MANY2(() => $.CONSUME(NewLine));
544
+ $.OPTION(() => $.SUBRULE2($.viewProperty));
545
+ });
546
+ });
547
+ $.RULE('viewProperty', () => {
548
+ $.OR([
549
+ { ALT: () => $.CONSUME(IdentifierName) },
550
+ { ALT: () => $.CONSUME(StringLiteral) },
551
+ ]);
552
+ $.CONSUME(Colon);
553
+ $.SUBRULE($.expression);
554
+ });
555
+ $.RULE('viewConditional', () => {
556
+ $.CONSUME(KwIf);
557
+ $.SUBRULE($.expression);
558
+ $.SUBRULE($.viewBlock);
559
+ $.OPTION(() => {
560
+ $.CONSUME(KwElse);
561
+ $.OR([
562
+ { GATE: () => this.LA(1).tokenType === LBrace, ALT: () => $.SUBRULE2($.viewBlock) },
563
+ { ALT: () => $.SUBRULE2($.viewConditional) },
564
+ ]);
565
+ });
566
+ });
567
+ $.RULE('viewRepetition', () => {
568
+ $.CONSUME(KwFor);
569
+ $.CONSUME(Identifier);
570
+ $.OPTION(() => { $.CONSUME(Comma); $.CONSUME2(Identifier); });
571
+ $.CONSUME(KwIn);
572
+ $.SUBRULE($.expression);
573
+ $.CONSUME(KwBy);
574
+ $.SUBRULE2($.expression);
575
+ $.SUBRULE($.viewBlock);
576
+ });
577
+ $.RULE('viewTextChild', () => {
578
+ $.CONSUME(StringLiteral);
579
+ $.SUBRULE($.lineEnd);
580
+ });
581
+ $.RULE('viewExpressionChild', () => {
582
+ $.CONSUME(LBrace);
583
+ $.SUBRULE($.expression);
584
+ $.CONSUME(RBrace);
585
+ $.SUBRULE($.lineEnd);
586
+ });
587
+ $.RULE('viewChildrenSlot', () => {
588
+ $.CONSUME(KwChildren);
589
+ $.SUBRULE($.lineEnd);
590
+ });
591
+ $.RULE('recordExpression', () => {
592
+ $.CONSUME(Identifier);
593
+ $.OPTION(() => $.SUBRULE($.typeArguments));
594
+ $.SUBRULE($.recordFieldBlock);
595
+ });
596
+ $.RULE('recordFieldBlock', () => {
597
+ $.CONSUME(LBrace);
598
+ $.MANY(() => $.CONSUME(NewLine));
599
+ $.OPTION(() => {
600
+ $.SUBRULE($.recordEntry);
601
+ $.MANY2(() => { $.CONSUME(Comma); $.MANY3(() => $.CONSUME2(NewLine)); $.OPTION2(() => $.SUBRULE2($.recordEntry)); });
602
+ });
603
+ $.CONSUME(RBrace);
604
+ });
605
+ $.RULE('recordEntry', () => {
606
+ $.CONSUME(Identifier);
607
+ $.OPTION(() => { $.CONSUME(Colon); $.SUBRULE($.expression); });
608
+ });
609
+ $.RULE('contextualAggregateExpression', () => {
610
+ $.CONSUME(LBrace);
611
+ $.MANY(() => $.CONSUME(NewLine));
612
+ $.OPTION(() => {
613
+ $.SUBRULE($.contextualAggregateEntry);
614
+ $.MANY2(() => { $.CONSUME(Comma); $.MANY3(() => $.CONSUME2(NewLine)); $.OPTION2(() => $.SUBRULE2($.contextualAggregateEntry)); });
615
+ });
616
+ $.CONSUME(RBrace);
617
+ });
618
+ $.RULE('contextualAggregateEntry', () => {
619
+ $.CONSUME(IdentifierName);
620
+ $.CONSUME(Colon);
621
+ $.SUBRULE($.expression);
622
+ });
623
+ $.RULE('listExpression', () => {
624
+ $.CONSUME(LBracket);
625
+ $.MANY(() => $.CONSUME(NewLine));
626
+ $.OPTION(() => {
627
+ $.SUBRULE($.expression);
628
+ $.MANY2(() => { $.CONSUME(Comma); $.MANY3(() => $.CONSUME2(NewLine)); $.OPTION2(() => $.SUBRULE2($.expression)); });
629
+ });
630
+ $.CONSUME(RBracket);
631
+ });
632
+ $.RULE('parenthesizedOrTupleExpression', () => {
633
+ $.CONSUME(LParen);
634
+ $.SUBRULE($.expression);
635
+ $.OPTION(() => {
636
+ $.CONSUME(Comma);
637
+ $.SUBRULE2($.expression);
638
+ $.MANY(() => { $.CONSUME2(Comma); $.SUBRULE3($.expression); });
639
+ });
640
+ $.CONSUME(RParen);
641
+ });
642
+ $.RULE('conditionalExpression', () => {
643
+ $.CONSUME(KwIf);
644
+ $.SUBRULE($.expression);
645
+ $.CONSUME(KwThen);
646
+ $.SUBRULE2($.expression);
647
+ $.CONSUME(KwElse);
648
+ $.SUBRULE3($.expression);
649
+ });
650
+ $.RULE('matchExpression', () => {
651
+ $.CONSUME(KwMatch);
652
+ $.SUBRULE($.expression);
653
+ $.CONSUME(LBrace);
654
+ $.MANY(() => $.CONSUME(NewLine));
655
+ $.AT_LEAST_ONE(() => { $.SUBRULE($.matchArm); $.MANY2(() => $.CONSUME2(NewLine)); });
656
+ $.CONSUME(RBrace);
657
+ });
658
+ $.RULE('matchArm', () => {
659
+ $.SUBRULE($.pattern);
660
+ $.OPTION(() => { $.CONSUME(KwIf); $.SUBRULE($.expression); });
661
+ $.CONSUME(FatArrow);
662
+ $.SUBRULE2($.expression);
663
+ $.OPTION2(() => $.CONSUME(Comma));
664
+ });
665
+ $.RULE('pattern', () => {
666
+ $.SUBRULE($.orPattern);
667
+ });
668
+ $.RULE('orPattern', () => {
669
+ $.SUBRULE($.primaryPattern);
670
+ $.MANY(() => { $.CONSUME(Bar); $.SUBRULE2($.primaryPattern); });
671
+ });
672
+ $.RULE('primaryPattern', () => {
673
+ $.OR([
674
+ { ALT: () => $.CONSUME(Underscore) },
675
+ { GATE: () => this.LA(1).tokenType === IntLiteral && this.LA(2).tokenType === RangeInclusive, ALT: () => $.SUBRULE($.rangePattern) },
676
+ { ALT: () => $.CONSUME(StringLiteral) },
677
+ { ALT: () => $.CONSUME(IntLiteral) },
678
+ { ALT: () => $.CONSUME(KwTrue) },
679
+ { ALT: () => $.CONSUME(KwFalse) },
680
+ { ALT: () => $.SUBRULE($.listPattern) },
681
+ { GATE: () => this.LA(1).tokenType === LParen, ALT: () => $.SUBRULE($.tuplePattern) },
682
+ { GATE: () => this.LA(1).tokenType === Identifier && this.LA(2).tokenType === LParen, ALT: () => $.SUBRULE($.variantPattern) },
683
+ { GATE: () => this.LA(1).tokenType === Identifier && this.LA(2).tokenType === LBrace, ALT: () => $.SUBRULE($.recordPattern) },
684
+ { ALT: () => $.CONSUME(Identifier) },
685
+ ]);
686
+ });
687
+ $.RULE('rangePattern', () => {
688
+ $.CONSUME(IntLiteral);
689
+ $.CONSUME(RangeInclusive);
690
+ $.CONSUME2(IntLiteral);
691
+ });
692
+ $.RULE('listPattern', () => {
693
+ $.CONSUME(LBracket);
694
+ $.OPTION(() => {
695
+ $.OR([
696
+ { GATE: () => this.LA(1).tokenType === Spread, ALT: () => {
697
+ $.CONSUME(Spread);
698
+ $.OR2([{ ALT: () => $.CONSUME(Underscore) }, { ALT: () => $.CONSUME(Identifier) }]);
699
+ } },
700
+ { ALT: () => {
701
+ $.SUBRULE($.pattern);
702
+ $.MANY({ GATE: () => this.LA(1).tokenType === Comma && this.LA(2).tokenType !== Spread && this.LA(2).tokenType !== RBracket, DEF: () => {
703
+ $.CONSUME(Comma);
704
+ $.SUBRULE2($.pattern);
705
+ } });
706
+ $.OPTION2({ GATE: () => this.LA(1).tokenType === Comma && this.LA(2).tokenType === Spread, DEF: () => {
707
+ $.CONSUME2(Comma);
708
+ $.CONSUME2(Spread);
709
+ $.OR3([{ ALT: () => $.CONSUME2(Underscore) }, { ALT: () => $.CONSUME2(Identifier) }]);
710
+ } });
711
+ $.OPTION3(() => $.CONSUME3(Comma));
712
+ } },
713
+ ]);
714
+ });
715
+ $.CONSUME(RBracket);
716
+ });
717
+ $.RULE('tuplePattern', () => {
718
+ $.CONSUME(LParen);
719
+ $.SUBRULE($.pattern);
720
+ $.CONSUME(Comma);
721
+ $.SUBRULE2($.pattern);
722
+ $.MANY(() => { $.CONSUME2(Comma); $.SUBRULE3($.pattern); });
723
+ $.CONSUME(RParen);
724
+ });
725
+ $.RULE('variantPattern', () => {
726
+ $.CONSUME(Identifier);
727
+ $.CONSUME(LParen);
728
+ $.OPTION(() => { $.SUBRULE($.pattern); $.MANY(() => { $.CONSUME(Comma); $.SUBRULE2($.pattern); }); });
729
+ $.CONSUME(RParen);
730
+ });
731
+ $.RULE('recordPattern', () => {
732
+ $.CONSUME(Identifier);
733
+ $.CONSUME(LBrace);
734
+ $.OPTION(() => {
735
+ $.OPTION2(() => {
736
+ $.SUBRULE($.recordPatternField);
737
+ $.MANY(() => { $.CONSUME(Comma); $.OPTION3(() => $.SUBRULE2($.recordPatternField)); });
738
+ });
739
+ $.OPTION4(() => { $.CONSUME(Spread); });
740
+ });
741
+ $.CONSUME(RBrace);
742
+ });
743
+ $.RULE('recordPatternField', () => {
744
+ $.CONSUME(Identifier);
745
+ $.OPTION(() => { $.CONSUME(Colon); $.SUBRULE($.pattern); });
746
+ });
747
+ $.RULE('lambdaExpression', () => {
748
+ $.OPTION(() => $.CONSUME(KwAsync));
749
+ $.CONSUME(KwFn);
750
+ $.CONSUME(LParen);
751
+ $.OPTION2(() => $.SUBRULE($.lambdaParameterList));
752
+ $.CONSUME(RParen);
753
+ $.OPTION3(() => { $.CONSUME(ThinArrow); $.SUBRULE($.typeReference); });
754
+ $.OPTION4(() => $.SUBRULE($.usesClause));
755
+ $.OR([
756
+ { ALT: () => { $.CONSUME(FatArrow); $.SUBRULE($.expression); } },
757
+ { ALT: () => $.SUBRULE($.block) },
758
+ ]);
759
+ });
760
+ $.RULE('lambdaParameterList', () => {
761
+ $.SUBRULE($.lambdaParameter);
762
+ $.MANY(() => { $.CONSUME(Comma); $.SUBRULE2($.lambdaParameter); });
763
+ });
764
+ $.RULE('lambdaParameter', () => {
765
+ $.CONSUME(Identifier);
766
+ $.OPTION(() => { $.CONSUME(Colon); $.SUBRULE($.typeReference); });
767
+ });
768
+ $.RULE('parallelExpression', () => {
769
+ $.CONSUME(KwParallel);
770
+ $.OPTION(() => $.CONSUME(KwTry));
771
+ $.CONSUME(LBrace);
772
+ $.MANY(() => $.CONSUME(NewLine));
773
+ $.SUBRULE($.parallelEntry);
774
+ $.MANY2(() => { $.CONSUME(Comma); $.MANY3(() => $.CONSUME2(NewLine)); $.OPTION2(() => $.SUBRULE2($.parallelEntry)); });
775
+ $.CONSUME(RBrace);
776
+ });
777
+ $.RULE('parallelEntry', () => {
778
+ $.CONSUME(Identifier);
779
+ $.CONSUME(Colon);
780
+ $.SUBRULE($.expression);
781
+ });
782
+ this.performSelfAnalysis();
783
+ }
784
+ tokenAt(offset) { return this.LA(offset); }
785
+ publicFollowIs(type) { return this.tokenAt(1)?.tokenType === KwPub && this.tokenAt(2)?.tokenType === type; }
786
+ isCallSuffixStart() {
787
+ if (this.tokenAt(1)?.tokenType === LParen)
788
+ return true;
789
+ if (this.tokenAt(1)?.tokenType !== Less)
790
+ return false;
791
+ const previous = this.LA(0);
792
+ const less = this.tokenAt(1);
793
+ if (previous?.endOffset === undefined || less?.startOffset === undefined || previous.endOffset + 1 !== less.startOffset)
794
+ return false;
795
+ let depth = 0;
796
+ for (let offset = 1; offset < 128; offset++) {
797
+ const token = this.tokenAt(offset);
798
+ if (token === undefined)
799
+ return false;
800
+ if (token.tokenType === Less)
801
+ depth++;
802
+ else if (token.tokenType === Greater) {
803
+ depth--;
804
+ if (depth === 0)
805
+ return this.tokenAt(offset + 1)?.tokenType === LParen;
806
+ }
807
+ }
808
+ return false;
809
+ }
810
+ isRecordExpressionStart() {
811
+ const identifier = this.tokenAt(1);
812
+ if (identifier?.tokenType !== Identifier || !/^[A-Z]/u.test(identifier.image))
813
+ return false;
814
+ if (this.tokenAt(2)?.tokenType === LBrace)
815
+ return true;
816
+ const less = this.tokenAt(2);
817
+ if (less?.tokenType !== Less || identifier.endOffset === undefined || less.startOffset === undefined || identifier.endOffset + 1 !== less.startOffset)
818
+ return false;
819
+ let depth = 0;
820
+ for (let offset = 2; offset < 128; offset++) {
821
+ const token = this.tokenAt(offset);
822
+ if (token === undefined)
823
+ return false;
824
+ if (token.tokenType === Less)
825
+ depth++;
826
+ else if (token.tokenType === Greater) {
827
+ depth--;
828
+ if (depth === 0)
829
+ return this.tokenAt(offset + 1)?.tokenType === LBrace;
830
+ }
831
+ }
832
+ return false;
833
+ }
834
+ isAssignmentStart() {
835
+ let parenDepth = 0;
836
+ let bracketDepth = 0;
837
+ let braceDepth = 0;
838
+ for (let offset = 1;; offset++) {
839
+ const token = this.tokenAt(offset);
840
+ if (token === undefined || token.tokenType.name === 'EOF')
841
+ return false;
842
+ if (token.tokenType === NewLine && parenDepth === 0 && bracketDepth === 0 && braceDepth === 0)
843
+ return false;
844
+ if (token.tokenType === Equals && parenDepth === 0 && bracketDepth === 0 && braceDepth === 0)
845
+ return true;
846
+ if (token.tokenType === LParen)
847
+ parenDepth++;
848
+ else if (token.tokenType === RParen)
849
+ parenDepth--;
850
+ else if (token.tokenType === LBracket)
851
+ bracketDepth++;
852
+ else if (token.tokenType === RBracket)
853
+ bracketDepth--;
854
+ else if (token.tokenType === LBrace)
855
+ braceDepth++;
856
+ else if (token.tokenType === RBrace)
857
+ braceDepth--;
858
+ if (parenDepth < 0 || bracketDepth < 0 || braceDepth < 0)
859
+ return false;
860
+ }
861
+ }
862
+ isFunctionStart() {
863
+ return this.tokenAt(1)?.tokenType === KwFn || this.tokenAt(1)?.tokenType === KwAsync || this.publicFollowIs(KwFn) || (this.publicFollowIs(KwAsync) && this.tokenAt(3)?.tokenType === KwFn);
864
+ }
865
+ isComponentStart() { return this.tokenAt(1)?.tokenType === KwComponent || this.publicFollowIs(KwComponent); }
866
+ isRecordStart() { return this.tokenAt(1)?.tokenType === KwRecord || this.publicFollowIs(KwRecord); }
867
+ isEnumStart() { return this.tokenAt(1)?.tokenType === KwEnum || this.publicFollowIs(KwEnum); }
868
+ isNewtypeStart() { return this.tokenAt(1)?.tokenType === KwNewtype || this.publicFollowIs(KwNewtype); }
869
+ isTypeAliasStart() { return this.tokenAt(1)?.tokenType === KwType || this.publicFollowIs(KwType); }
870
+ isExternStart() { return this.tokenAt(1)?.tokenType === KwExtern || (this.tokenAt(1)?.tokenType === KwUnsafe && this.tokenAt(2)?.tokenType === KwExtern); }
871
+ isTestStart() { return this.tokenAt(1)?.tokenType === KwTest || (this.tokenAt(1)?.tokenType === KwAsync && this.tokenAt(2)?.tokenType === KwTest); }
872
+ module;
873
+ importDeclaration;
874
+ importItem;
875
+ declaration;
876
+ attribute;
877
+ functionDeclaration;
878
+ componentDeclaration;
879
+ typeParameters;
880
+ parameterList;
881
+ parameter;
882
+ usesClause;
883
+ recordDeclaration;
884
+ recordField;
885
+ derivesClause;
886
+ enumDeclaration;
887
+ enumVariant;
888
+ newtypeDeclaration;
889
+ typeAliasDeclaration;
890
+ externDeclaration;
891
+ externFunction;
892
+ testDeclaration;
893
+ topLevelLetDeclaration;
894
+ typeReference;
895
+ tupleTypeReference;
896
+ functionTypeReference;
897
+ block;
898
+ statement;
899
+ letStatement;
900
+ returnStatement;
901
+ ifStatement;
902
+ forStatement;
903
+ whileStatement;
904
+ breakStatement;
905
+ continueStatement;
906
+ discardStatement;
907
+ deferStatement;
908
+ assignmentStatement;
909
+ expressionStatement;
910
+ lineEnd;
911
+ expression;
912
+ pipelineExpression;
913
+ orExpression;
914
+ andExpression;
915
+ equalityExpression;
916
+ comparisonExpression;
917
+ additiveExpression;
918
+ multiplicativeExpression;
919
+ unaryExpression;
920
+ postfixExpression;
921
+ indexSuffix;
922
+ callSuffix;
923
+ typeArguments;
924
+ argumentList;
925
+ primaryExpression;
926
+ viewExpression;
927
+ viewBlock;
928
+ viewChild;
929
+ viewElement;
930
+ viewTag;
931
+ viewPropertyList;
932
+ viewProperty;
933
+ viewConditional;
934
+ viewRepetition;
935
+ viewTextChild;
936
+ viewExpressionChild;
937
+ viewChildrenSlot;
938
+ recordExpression;
939
+ recordFieldBlock;
940
+ recordEntry;
941
+ contextualAggregateExpression;
942
+ contextualAggregateEntry;
943
+ listExpression;
944
+ parenthesizedOrTupleExpression;
945
+ conditionalExpression;
946
+ matchExpression;
947
+ matchArm;
948
+ pattern;
949
+ orPattern;
950
+ primaryPattern;
951
+ rangePattern;
952
+ listPattern;
953
+ tuplePattern;
954
+ variantPattern;
955
+ recordPattern;
956
+ recordPatternField;
957
+ lambdaExpression;
958
+ lambdaParameterList;
959
+ lambdaParameter;
960
+ parallelExpression;
961
+ parallelEntry;
962
+ }
963
+ const parser = new ViruneParser();
964
+ export function parse(tokens) {
965
+ parser.input = [...tokens];
966
+ const cst = parser.module();
967
+ return { cst, errors: parser.errors };
968
+ }
969
+ export const baseCstVisitorConstructor = parser.getBaseCstVisitorConstructorWithDefaults();
970
+ //# sourceMappingURL=parser.js.map