@sccharts-lab/engine 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/LICENSE +277 -0
  2. package/README.md +125 -2
  3. package/dist/codegen/expr.d.ts +36 -0
  4. package/dist/codegen/expr.js +252 -0
  5. package/dist/codegen/expr.js.map +1 -0
  6. package/dist/codegen/index.d.ts +4 -0
  7. package/dist/codegen/index.js +238 -0
  8. package/dist/codegen/index.js.map +1 -0
  9. package/dist/codegen/layout.d.ts +57 -0
  10. package/dist/codegen/layout.js +306 -0
  11. package/dist/codegen/layout.js.map +1 -0
  12. package/dist/codegen/logic.d.ts +31 -0
  13. package/dist/codegen/logic.js +258 -0
  14. package/dist/codegen/logic.js.map +1 -0
  15. package/dist/codegen/methods.d.ts +17 -0
  16. package/dist/codegen/methods.js +242 -0
  17. package/dist/codegen/methods.js.map +1 -0
  18. package/dist/codegen/reset.d.ts +6 -0
  19. package/dist/codegen/reset.js +110 -0
  20. package/dist/codegen/reset.js.map +1 -0
  21. package/dist/codegen/types.d.ts +81 -0
  22. package/dist/codegen/types.js +3 -0
  23. package/dist/codegen/types.js.map +1 -0
  24. package/dist/format.d.ts +136 -0
  25. package/dist/format.js +872 -0
  26. package/dist/format.js.map +1 -0
  27. package/dist/index.d.ts +120 -0
  28. package/dist/index.js +507 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/internal.d.ts +1 -0
  31. package/dist/internal.js +4 -0
  32. package/dist/internal.js.map +1 -0
  33. package/dist/parser/ids.d.ts +4 -0
  34. package/dist/parser/ids.js +172 -0
  35. package/dist/parser/ids.js.map +1 -0
  36. package/dist/parser/imports.d.ts +2 -0
  37. package/dist/parser/imports.js +28 -0
  38. package/dist/parser/imports.js.map +1 -0
  39. package/dist/parser/interface.d.ts +10 -0
  40. package/dist/parser/interface.js +93 -0
  41. package/dist/parser/interface.js.map +1 -0
  42. package/dist/parser/kielerWording.d.ts +2 -0
  43. package/dist/parser/kielerWording.js +196 -0
  44. package/dist/parser/kielerWording.js.map +1 -0
  45. package/dist/parser/lexer.d.ts +25 -0
  46. package/dist/parser/lexer.js +334 -0
  47. package/dist/parser/lexer.js.map +1 -0
  48. package/dist/parser/parser.d.ts +29 -0
  49. package/dist/parser/parser.js +3249 -0
  50. package/dist/parser/parser.js.map +1 -0
  51. package/dist/parser/resolve.d.ts +46 -0
  52. package/dist/parser/resolve.js +919 -0
  53. package/dist/parser/resolve.js.map +1 -0
  54. package/dist/parser/source.d.ts +15 -0
  55. package/dist/parser/source.js +42 -0
  56. package/dist/parser/source.js.map +1 -0
  57. package/dist/parser/validate.d.ts +5 -0
  58. package/dist/parser/validate.js +1430 -0
  59. package/dist/parser/validate.js.map +1 -0
  60. package/dist/sim/abortRegions.d.ts +9 -0
  61. package/dist/sim/abortRegions.js +192 -0
  62. package/dist/sim/abortRegions.js.map +1 -0
  63. package/dist/sim/analysis.d.ts +113 -0
  64. package/dist/sim/analysis.js +1104 -0
  65. package/dist/sim/analysis.js.map +1 -0
  66. package/dist/sim/codegen.d.ts +30 -0
  67. package/dist/sim/codegen.js +730 -0
  68. package/dist/sim/codegen.js.map +1 -0
  69. package/dist/sim/compile.d.ts +43 -0
  70. package/dist/sim/compile.js +1062 -0
  71. package/dist/sim/compile.js.map +1 -0
  72. package/dist/sim/deps.d.ts +73 -0
  73. package/dist/sim/deps.js +481 -0
  74. package/dist/sim/deps.js.map +1 -0
  75. package/dist/sim/describe.d.ts +22 -0
  76. package/dist/sim/describe.js +272 -0
  77. package/dist/sim/describe.js.map +1 -0
  78. package/dist/sim/describePreemption.d.ts +22 -0
  79. package/dist/sim/describePreemption.js +90 -0
  80. package/dist/sim/describePreemption.js.map +1 -0
  81. package/dist/sim/describeStructure.d.ts +75 -0
  82. package/dist/sim/describeStructure.js +293 -0
  83. package/dist/sim/describeStructure.js.map +1 -0
  84. package/dist/sim/eval.d.ts +99 -0
  85. package/dist/sim/eval.js +644 -0
  86. package/dist/sim/eval.js.map +1 -0
  87. package/dist/sim/exec.d.ts +212 -0
  88. package/dist/sim/exec.js +874 -0
  89. package/dist/sim/exec.js.map +1 -0
  90. package/dist/sim/fold.d.ts +2 -0
  91. package/dist/sim/fold.js +40 -0
  92. package/dist/sim/fold.js.map +1 -0
  93. package/dist/sim/goblock.d.ts +16 -0
  94. package/dist/sim/goblock.js +171 -0
  95. package/dist/sim/goblock.js.map +1 -0
  96. package/dist/sim/guardIndices.d.ts +13 -0
  97. package/dist/sim/guardIndices.js +137 -0
  98. package/dist/sim/guardIndices.js.map +1 -0
  99. package/dist/sim/index.d.ts +43 -0
  100. package/dist/sim/index.js +138 -0
  101. package/dist/sim/index.js.map +1 -0
  102. package/dist/sim/lower.d.ts +33 -0
  103. package/dist/sim/lower.js +716 -0
  104. package/dist/sim/lower.js.map +1 -0
  105. package/dist/sim/memory.d.ts +47 -0
  106. package/dist/sim/memory.js +328 -0
  107. package/dist/sim/memory.js.map +1 -0
  108. package/dist/sim/model.d.ts +487 -0
  109. package/dist/sim/model.js +772 -0
  110. package/dist/sim/model.js.map +1 -0
  111. package/dist/sim/passes/abort.d.ts +2 -0
  112. package/dist/sim/passes/abort.js +269 -0
  113. package/dist/sim/passes/abort.js.map +1 -0
  114. package/dist/sim/passes/abortRegion.d.ts +10 -0
  115. package/dist/sim/passes/abortRegion.js +62 -0
  116. package/dist/sim/passes/abortRegion.js.map +1 -0
  117. package/dist/sim/passes/arrayAssignment.d.ts +2 -0
  118. package/dist/sim/passes/arrayAssignment.js +147 -0
  119. package/dist/sim/passes/arrayAssignment.js.map +1 -0
  120. package/dist/sim/passes/codeEffects.d.ts +2 -0
  121. package/dist/sim/passes/codeEffects.js +14 -0
  122. package/dist/sim/passes/codeEffects.js.map +1 -0
  123. package/dist/sim/passes/complexFinalState.d.ts +4 -0
  124. package/dist/sim/passes/complexFinalState.js +77 -0
  125. package/dist/sim/passes/complexFinalState.js.map +1 -0
  126. package/dist/sim/passes/connector.d.ts +2 -0
  127. package/dist/sim/passes/connector.js +18 -0
  128. package/dist/sim/passes/connector.js.map +1 -0
  129. package/dist/sim/passes/contained.d.ts +37 -0
  130. package/dist/sim/passes/contained.js +198 -0
  131. package/dist/sim/passes/contained.js.map +1 -0
  132. package/dist/sim/passes/context.d.ts +39 -0
  133. package/dist/sim/passes/context.js +3 -0
  134. package/dist/sim/passes/context.js.map +1 -0
  135. package/dist/sim/passes/countDelay.d.ts +2 -0
  136. package/dist/sim/passes/countDelay.js +51 -0
  137. package/dist/sim/passes/countDelay.js.map +1 -0
  138. package/dist/sim/passes/dataflow.d.ts +11 -0
  139. package/dist/sim/passes/dataflow.js +319 -0
  140. package/dist/sim/passes/dataflow.js.map +1 -0
  141. package/dist/sim/passes/deferred.d.ts +2 -0
  142. package/dist/sim/passes/deferred.js +345 -0
  143. package/dist/sim/passes/deferred.js.map +1 -0
  144. package/dist/sim/passes/detect.d.ts +10 -0
  145. package/dist/sim/passes/detect.js +33 -0
  146. package/dist/sim/passes/detect.js.map +1 -0
  147. package/dist/sim/passes/during.d.ts +2 -0
  148. package/dist/sim/passes/during.js +67 -0
  149. package/dist/sim/passes/during.js.map +1 -0
  150. package/dist/sim/passes/entry.d.ts +5 -0
  151. package/dist/sim/passes/entry.js +93 -0
  152. package/dist/sim/passes/entry.js.map +1 -0
  153. package/dist/sim/passes/enum.d.ts +2 -0
  154. package/dist/sim/passes/enum.js +22 -0
  155. package/dist/sim/passes/enum.js.map +1 -0
  156. package/dist/sim/passes/exit.d.ts +4 -0
  157. package/dist/sim/passes/exit.js +120 -0
  158. package/dist/sim/passes/exit.js.map +1 -0
  159. package/dist/sim/passes/finalRegion.d.ts +2 -0
  160. package/dist/sim/passes/finalRegion.js +21 -0
  161. package/dist/sim/passes/finalRegion.js.map +1 -0
  162. package/dist/sim/passes/followedBy.d.ts +2 -0
  163. package/dist/sim/passes/followedBy.js +78 -0
  164. package/dist/sim/passes/followedBy.js.map +1 -0
  165. package/dist/sim/passes/forRegion.d.ts +9 -0
  166. package/dist/sim/passes/forRegion.js +230 -0
  167. package/dist/sim/passes/forRegion.js.map +1 -0
  168. package/dist/sim/passes/history.d.ts +12 -0
  169. package/dist/sim/passes/history.js +115 -0
  170. package/dist/sim/passes/history.js.map +1 -0
  171. package/dist/sim/passes/hostCode.d.ts +2 -0
  172. package/dist/sim/passes/hostCode.js +152 -0
  173. package/dist/sim/passes/hostCode.js.map +1 -0
  174. package/dist/sim/passes/index.d.ts +4 -0
  175. package/dist/sim/passes/index.js +84 -0
  176. package/dist/sim/passes/index.js.map +1 -0
  177. package/dist/sim/passes/inheritance.d.ts +8 -0
  178. package/dist/sim/passes/inheritance.js +233 -0
  179. package/dist/sim/passes/inheritance.js.map +1 -0
  180. package/dist/sim/passes/initOperator.d.ts +2 -0
  181. package/dist/sim/passes/initOperator.js +68 -0
  182. package/dist/sim/passes/initOperator.js.map +1 -0
  183. package/dist/sim/passes/initialization.d.ts +2 -0
  184. package/dist/sim/passes/initialization.js +69 -0
  185. package/dist/sim/passes/initialization.js.map +1 -0
  186. package/dist/sim/passes/ode.d.ts +2 -0
  187. package/dist/sim/passes/ode.js +14 -0
  188. package/dist/sim/passes/ode.js.map +1 -0
  189. package/dist/sim/passes/period.d.ts +2 -0
  190. package/dist/sim/passes/period.js +106 -0
  191. package/dist/sim/passes/period.js.map +1 -0
  192. package/dist/sim/passes/prTransitions.d.ts +2 -0
  193. package/dist/sim/passes/prTransitions.js +12 -0
  194. package/dist/sim/passes/prTransitions.js.map +1 -0
  195. package/dist/sim/passes/pre.d.ts +4 -0
  196. package/dist/sim/passes/pre.js +326 -0
  197. package/dist/sim/passes/pre.js.map +1 -0
  198. package/dist/sim/passes/quirks.d.ts +2 -0
  199. package/dist/sim/passes/quirks.js +169 -0
  200. package/dist/sim/passes/quirks.js.map +1 -0
  201. package/dist/sim/passes/reference.d.ts +60 -0
  202. package/dist/sim/passes/reference.js +386 -0
  203. package/dist/sim/passes/reference.js.map +1 -0
  204. package/dist/sim/passes/regionActions.d.ts +2 -0
  205. package/dist/sim/passes/regionActions.js +56 -0
  206. package/dist/sim/passes/regionActions.js.map +1 -0
  207. package/dist/sim/passes/sequentialFollowedBy.d.ts +2 -0
  208. package/dist/sim/passes/sequentialFollowedBy.js +72 -0
  209. package/dist/sim/passes/sequentialFollowedBy.js.map +1 -0
  210. package/dist/sim/passes/signal.d.ts +2 -0
  211. package/dist/sim/passes/signal.js +230 -0
  212. package/dist/sim/passes/signal.js.map +1 -0
  213. package/dist/sim/passes/static.d.ts +5 -0
  214. package/dist/sim/passes/static.js +67 -0
  215. package/dist/sim/passes/static.js.map +1 -0
  216. package/dist/sim/passes/suspend.d.ts +10 -0
  217. package/dist/sim/passes/suspend.js +71 -0
  218. package/dist/sim/passes/suspend.js.map +1 -0
  219. package/dist/sim/passes/termination.d.ts +9 -0
  220. package/dist/sim/passes/termination.js +69 -0
  221. package/dist/sim/passes/termination.js.map +1 -0
  222. package/dist/sim/passes/timedAutomata.d.ts +10 -0
  223. package/dist/sim/passes/timedAutomata.js +437 -0
  224. package/dist/sim/passes/timedAutomata.js.map +1 -0
  225. package/dist/sim/passes/unpackClasses.d.ts +2 -0
  226. package/dist/sim/passes/unpackClasses.js +54 -0
  227. package/dist/sim/passes/unpackClasses.js.map +1 -0
  228. package/dist/sim/passes/userSchedule.d.ts +2 -0
  229. package/dist/sim/passes/userSchedule.js +43 -0
  230. package/dist/sim/passes/userSchedule.js.map +1 -0
  231. package/dist/sim/passes/weakSuspend.d.ts +2 -0
  232. package/dist/sim/passes/weakSuspend.js +145 -0
  233. package/dist/sim/passes/weakSuspend.js.map +1 -0
  234. package/dist/sim/preemptionLog.d.ts +41 -0
  235. package/dist/sim/preemptionLog.js +133 -0
  236. package/dist/sim/preemptionLog.js.map +1 -0
  237. package/dist/sim/random.d.ts +12 -0
  238. package/dist/sim/random.js +40 -0
  239. package/dist/sim/random.js.map +1 -0
  240. package/dist/sim/reasons.d.ts +29 -0
  241. package/dist/sim/reasons.js +168 -0
  242. package/dist/sim/reasons.js.map +1 -0
  243. package/dist/sim/scg.d.ts +124 -0
  244. package/dist/sim/scg.js +723 -0
  245. package/dist/sim/scg.js.map +1 -0
  246. package/dist/sim/sfr.d.ts +4 -0
  247. package/dist/sim/sfr.js +264 -0
  248. package/dist/sim/sfr.js.map +1 -0
  249. package/dist/sim/stringConditions.d.ts +3 -0
  250. package/dist/sim/stringConditions.js +42 -0
  251. package/dist/sim/stringConditions.js.map +1 -0
  252. package/dist/sim/structure/copy.d.ts +4 -0
  253. package/dist/sim/structure/copy.js +140 -0
  254. package/dist/sim/structure/copy.js.map +1 -0
  255. package/dist/sim/structure/delays.d.ts +30 -0
  256. package/dist/sim/structure/delays.js +127 -0
  257. package/dist/sim/structure/delays.js.map +1 -0
  258. package/dist/sim/structure/instance.d.ts +15 -0
  259. package/dist/sim/structure/instance.js +69 -0
  260. package/dist/sim/structure/instance.js.map +1 -0
  261. package/dist/sim/structure/methods.d.ts +19 -0
  262. package/dist/sim/structure/methods.js +550 -0
  263. package/dist/sim/structure/methods.js.map +1 -0
  264. package/dist/sim/structure/rewrite.d.ts +20 -0
  265. package/dist/sim/structure/rewrite.js +113 -0
  266. package/dist/sim/structure/rewrite.js.map +1 -0
  267. package/dist/sim/structure/track.d.ts +22 -0
  268. package/dist/sim/structure/track.js +123 -0
  269. package/dist/sim/structure/track.js.map +1 -0
  270. package/dist/sim/tracker.d.ts +77 -0
  271. package/dist/sim/tracker.js +265 -0
  272. package/dist/sim/tracker.js.map +1 -0
  273. package/dist/sim/values.d.ts +31 -0
  274. package/dist/sim/values.js +103 -0
  275. package/dist/sim/values.js.map +1 -0
  276. package/dist/types.d.ts +670 -0
  277. package/dist/types.js +9 -0
  278. package/dist/types.js.map +1 -0
  279. package/package.json +58 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,wGAAwG;AACxG,qEAAqE;AACrE,EAAE;AACF,oEAAoE;AACpE,wGAAwG;AACxG,qGAAqG","sourcesContent":["// The shared contract of the guide's SCCharts engine: the AST the parser produces, and the shapes the\n// compiler, simulator and diagram renderer exchange. Everything here is plain data (JSON-serialisable),\n// so it can cross a Web Worker boundary and be cached at build time.\n//\n// The textual syntax is KIELER's SCTX. The authoritative grammar is\n// ../kieler-server-fork/modules/sccharts/src/de/cau/cs/kieler/sccharts/text/SCTX.xtext (with SCL, KExt,\n// KEffects, KExpressions and Annotations). Names below follow the KIELER metamodel where one exists.\n\n// ---------------------------------------------------------------------------------------------------\n// Source locations and diagnostics\n// ---------------------------------------------------------------------------------------------------\n\n/** Offsets are UTF-16 indices into the source; lines and columns are 1-based. `end` is exclusive. */\nexport interface Span {\n start: number\n end: number\n line: number\n col: number\n endLine: number\n endCol: number\n}\n\nexport type Severity = 'error' | 'warning' | 'info'\n\nexport interface Diagnostic {\n severity: Severity\n message: string\n span?: Span\n /** Stable machine-readable code, e.g. 'parse', 'unknown-variable', 'causality-cycle', 'instantaneous-loop'. */\n code?: string\n /** One or two sentences a beginner can act on (\"Make one of the transitions delayed ...\"). */\n hint?: string\n /** Ids of the model elements involved (states, transitions, regions), for highlighting in the diagram. */\n related?: string[]\n /** KIELER's own message for the same problem (validation and linking diagnostics), when it has one. */\n kieler?: string\n /** The name the message suggests instead (its \"did you mean\"): a quick fix may put it in place of `span`. */\n suggestion?: string\n /** A runtime error (`TickResult.error`): the tick in which the simulation stopped. Later ticks repeat the error\n * with this tick, since KIELER's simulation stays stopped. */\n tick?: number\n}\n\n// ---------------------------------------------------------------------------------------------------\n// Element ids\n// ---------------------------------------------------------------------------------------------------\n//\n// Every state, region, transition and action has an `id` that is unique within a Program and stable\n// for unchanged source (so a diagram can keep its highlight while the text is edited elsewhere):\n//\n// root state <ChartName> e.g. ABRO\n// region <parentStateId>:<regionName | index> e.g. ABRO:main, ABRO.WaitAB:0\n// state <parentStateId>.<stateName> e.g. ABRO.WaitAB.WaitA\n// (regions are not part of a state's id unless two regions of the same parent\n// contain a state of the same name; then it is <regionId>.<stateName>)\n// transition <sourceStateId>-><priority> e.g. ABRO.WaitAB->1\n// action <stateId>!<kind><index among that kind> e.g. ABRO.WaitAB!entry0\n// declaration <scopeId>$<valuedObjectName> e.g. ABRO$O\n//\n// The diagram renderer puts these ids on SVG elements as data-id attributes; the simulator reports\n// them in TickResult.\n\n// ---------------------------------------------------------------------------------------------------\n// AST\n// ---------------------------------------------------------------------------------------------------\n\nexport interface NodeBase {\n span: Span\n}\n\nexport interface Program extends NodeBase {\n kind: 'program'\n /** `import \"file\"` strings in order. */\n imports: string[]\n /** Spans of the import names (parallel to imports). */\n importSpans?: Span[]\n pragmas: Pragma[]\n /** Every `scchart` in the file, in order. The simulator runs one of them (default: the first, as KIELER: Reference.xtend keeps rootStates.head). */\n charts: State[]\n /** Ordinary `// ...` and `/* ... *\\/` comments (hidden from the grammar), in source order. */\n comments?: { kind: 'line' | 'block'; text: string; span: Span }[]\n}\n\nexport interface Annotation extends NodeBase {\n kind: 'annotation'\n /** Name without the '@' (or 'comment' for a doc comment). */\n name: string\n values: string[]\n /** Typed annotation `@layout[elk.direction] UP`: the part in brackets. */\n type?: string\n /** JSON annotation `@name {\"key\": 1}`: the object's source text. */\n json?: string\n}\n\nexport interface Pragma extends NodeBase {\n kind: 'pragma'\n name: string\n values: string[]\n /** JSON pragma `#name {\"key\": 1}`: the object's source text. */\n json?: string\n}\n\nexport interface State extends NodeBase {\n kind: 'state'\n id: string\n name: string\n /** Optional display label: `state A \"Waiting for A\"`. */\n label?: string\n isRoot: boolean\n initial: boolean\n final: boolean\n connector: boolean\n violation: boolean\n annotations: Annotation[]\n /** Text of the `/** ... *\\/` doc comment directly before the element, without the comment markers. */\n doc?: string\n declarations: Declaration[]\n /**\n * Declarations written after the actions, states or regions (a syntax error). KIELER's parser drops them, so they\n * are not in the scope and the names they declare do not resolve (as in KIELER); kept for the linker's hint.\n */\n lateDeclarations?: Declaration[]\n actions: LocalAction[]\n /** Concurrent regions. Empty for a simple state. States written directly inside a superstate\n * (without `region`) form one implicit region (`implicit: true`). */\n regions: Region[]\n /** Outgoing transitions in priority order: transitions[0] has priority 1. */\n transitions: Transition[]\n /** `state S is Other(a, b to c)`: the state is an instance of another SCChart. */\n reference?: ScopeCall\n /** `calls` (module call) instead of `is`. */\n callsReference?: boolean\n /** `extends` base states (inheritance, rare). */\n baseStates?: ScopeCall[]\n /** Generic parameter declarations `scchart X<T is int>`, kept as written. */\n genericParameters?: string[]\n /** Span of just the state's name (for go-to-definition and renaming). */\n nameSpan: Span\n /** `policy` regions of a root state (kept apart from `regions`; they describe method call protocols). */\n policies?: Region[]\n}\n\nexport interface Region extends NodeBase {\n kind: 'region'\n id: string\n regionType: 'controlflow' | 'dataflow'\n name?: string\n label?: string\n /** States written straight into a superstate or scchart without a `region` keyword. */\n implicit: boolean\n annotations: Annotation[]\n doc?: string\n /** `final region` / `abort region` / `override region` modifiers. */\n final?: boolean\n abort?: boolean\n override?: boolean\n declarations: Declaration[]\n actions: LocalAction[]\n /** Control-flow regions. */\n states: State[]\n /** Dataflow regions (`dataflow { O = A && B }`). */\n equations: Equation[]\n /** `region R for i : 0 to 3` (end omitted: `for i : ARRAY` iterates an array's indices). */\n forLoop?: { variable: string; from: Expression; to?: Expression; span: Span }\n /** `region R is super.X`: resolves only to regions inherited through `extends`; it does not instantiate a chart. */\n reference?: ScopeCall\n /** Dataflow `once`. */\n once?: boolean\n /** Span of the region's name (when it has one). */\n nameSpan?: Span\n /** A `policy` region of a chart or host class (method call protocol); not part of the behaviour. */\n policy?: boolean\n}\n\nexport type DelayType = 'delayed' | 'immediate' | 'auto' | 'undefined'\nexport type PreemptionType = 'weak' | 'strong' | 'termination'\n\nexport interface Transition extends NodeBase {\n kind: 'transition'\n id: string\n /** Id of the source state. */\n source: string\n /** Target state name as written. */\n targetName: string\n /** Resolved id of the target state (set by the resolver; undefined if it does not resolve). */\n target?: string\n targetSpan: Span\n /** Priority, 1-based, in the order the transitions are written under their source state. */\n priority: number\n /** As written; undefined means the keyword was omitted (delayed, except for connector sources). */\n delay?: DelayType\n /** `go to` = weak abort, `abort to` = strong abort, `join to` = termination. */\n preemption: PreemptionType\n /** Count delay: `if 3 A go to B` fires on the third tick in which A holds. */\n triggerDelay?: number\n trigger?: Expression\n /** `Pr=0.5` probability and `nondeterministic` (kept, not simulated). */\n probability?: number\n nondeterministic?: boolean\n effects: Effect[]\n deferred?: 'shallow' | 'deep'\n history?: 'reset' | 'shallow' | 'deep'\n label?: string\n annotations: Annotation[]\n doc?: string\n}\n\nexport type LocalActionKind = 'entry' | 'during' | 'exit' | 'suspend' | 'period' | 'ode'\n\nexport interface LocalAction extends NodeBase {\n kind: LocalActionKind\n id: string\n /** `immediate during`, `immediate suspend`, ... */\n delay?: DelayType\n /** `weak entry` / `strong exit` (PreemptionActionType) */\n preemption?: 'weak' | 'strong'\n /** `weak suspend` */\n weak?: boolean\n triggerDelay?: number\n trigger?: Expression\n /** `entry if A Pr 0.5`, `during if A Pr=0.5` (kept, not simulated). */\n probability?: number\n effects: Effect[]\n label?: string\n annotations: Annotation[]\n doc?: string\n}\n\nexport interface Equation extends NodeBase {\n kind: 'equation'\n target: Reference\n operator: AssignOperator\n expression: Expression\n sequential?: boolean\n /** Dataflow reference call `A(x, y)` / `A(x) = e`: the call's arguments (expression is then the call or `e`). */\n callArgs?: Expression[]\n annotations?: Annotation[]\n}\n\nexport interface ScopeCall extends NodeBase {\n kind: 'scopeCall'\n target: string\n /** Bindings in order. `binding` is set for explicit `x to y` bindings (the referenced chart's name). */\n parameters: ScopeParameter[]\n genericParameters?: string[]\n super?: boolean\n /** Span of the target name. */\n targetSpan?: Span\n}\n\nexport interface ScopeParameter {\n expression: Expression\n /** Explicit binding `x to y`: the name of the referenced chart's interface variable. */\n binding?: string\n /** Resolved ValuedObject id of the explicit binding (set by the resolver). */\n bindingDecl?: string\n /** `x to y[1]` */\n bindingIndices?: Expression[]\n /** Span of the binding name after `to`. */\n bindingSpan?: Span\n /** `&x`: call by reference. */\n byReference?: boolean\n /** `!&x`: pure output. */\n pureOutput?: boolean\n span: Span\n}\n\n// ----- Declarations -----\n\nexport type ValueType = 'pure' | 'bool' | 'int' | 'float' | 'string' | 'clock' | 'clock-time' | 'host'\n\nexport type CombineOperator = 'none' | '+' | '*' | 'max' | 'min' | '|' | '&' | 'host'\n\nexport interface Declaration extends NodeBase {\n kind: 'declaration'\n /** `variable` for ordinary (and signal) declarations; others are parsed so charts that use them\n * still load, and the simulator reports them as unsupported if they matter. */\n declKind: 'variable' | 'reference' | 'method' | 'enum' | 'class' | 'struct' | 'schedule' | 'primitive'\n /** Undefined only for `signal S` (a pure signal). */\n type?: ValueType\n /** `host \"unsigned char\" x` */\n hostType?: string\n /** For `ref`/reference declarations: `ref Other o`. */\n referenceTarget?: string\n signal: boolean\n input: boolean\n output: boolean\n const: boolean\n global: boolean\n static: boolean\n extern?: boolean\n access?: 'public' | 'protected' | 'private'\n annotations: Annotation[]\n doc?: string\n valuedObjects: ValuedObject[]\n /** Raw source text of declarations the engine does not model in detail (methods, classes, enums). */\n text?: string\n /** `extern \"rand\", @Java \"Math.random\" rand`: the host code strings with their tag annotations. */\n externs?: { code: string; annotations: Annotation[] }[]\n /** `ref Container.Chart x`: the container part. */\n referenceContainer?: string\n /** Span of the referenced type's name (`ref Chart x`, `primitive T x`). */\n referenceSpan?: Span\n /** `ref Chart<T> x`: generic arguments as written. */\n genericParameters?: string[]\n /** Class, struct and enum: the type name (`class Counter {...} c` -> 'Counter'); also kept on host classes. */\n className?: string\n /** `host class ...`, `host enum ...` */\n host?: boolean\n /** Members of a class or struct (declarations and methods), or the members of an enum (one declaration). */\n members?: Declaration[]\n /** Methods: return type as written (`int`, `void`, `host \"char*\"` -> 'host'), the parameters and the body. */\n returnType?: string\n returnHostType?: string\n parameters?: Declaration[]\n body?: { declarations: Declaration[]; statements: SclStatement[]; span: Span }\n /** `override method ...` */\n override?: boolean\n /** Schedule declarations: `schedule {conflicting, commuting} s` priorities, and `global` protocol. */\n priorities?: string[]\n /** `policy` regions of a host class. */\n policies?: Region[]\n}\n\nexport interface ValuedObject extends NodeBase {\n kind: 'valuedObject'\n id: string\n name: string\n /** Array dimensions: `int a[3][2]` → two expressions. */\n cardinalities: Expression[]\n initialValue?: Expression\n combine?: CombineOperator\n label?: string\n /** `ref Chart c(x to y)`: bindings of a reference valued object. */\n parameters?: ScopeParameter[]\n genericParameters?: string[]\n annotations?: Annotation[]\n /** Span of just the name. */\n nameSpan?: Span\n}\n\n// ----- Expressions -----\n\nexport type OperatorType =\n | '||' | '&&' | '|' | '^' | '&'\n | '==' | '!=' | '<' | '<=' | '>' | '>='\n | '<<' | '>>' | '>>>'\n | '+' | '-' | '*' | '/' | '%'\n | '!' | '~' | 'neg' // 'neg' is unary minus\n | '?:' // ternary: args [cond, then, else?]\n | 'pre' | 'val'\n | '->' | 'fby' | 'sfby' // dataflow initialisation and followed-by\n\nexport type Expression =\n | { kind: 'bool'; value: boolean; span: Span }\n | { kind: 'int'; value: number; span: Span }\n | { kind: 'float'; value: number; span: Span }\n | { kind: 'string'; value: string; span: Span }\n | Reference\n | { kind: 'op'; op: OperatorType; args: Expression[]; span: Span }\n /** Call of a method or referenced chart: `f(x)`, `obj.f(x)` (name 'obj.f'); `extern f(x)` sets extern.\n * `target` is the called reference (with indices, sub-reference and resolved decl) for non-extern calls. */\n | { kind: 'call'; name: string; args: Expression[]; extern?: boolean; target?: Reference; super?: boolean; paramAccess?: ParamAccess[]; span: Span }\n | { kind: 'random'; span: Span }\n | { kind: 'randomize'; span: Span }\n | { kind: 'hostcode'; text: string; span: Span } // `...` backtick host code\n | { kind: 'vector'; values: Expression[]; range?: boolean; span: Span } // {1, 2, 3}; range: {1 to 5} (values [from, to])\n | { kind: 'ignore'; span: Span } // `_` in a vector\n | { kind: 'null'; span: Span }\n /**\n * `scchart(Chart).x` (target 'Chart', sub x) or `state(R.S)` (container 'R', target 'S'). `state`: the id of the\n * state a `state(...)` names, set by name resolution.\n */\n | { kind: 'special'; access: 'static' | 'scchart' | 'state'; text: string; target?: string; container?: string; sub?: Reference; state?: string; span: Span }\n /** `this` (only as a parameter of a reference). */\n | { kind: 'this'; span: Span }\n\n/** Parameter passing mode of a call argument: `&x` call by reference, `!&x` pure output, null for a plain value. */\nexport type ParamAccess = '&' | '!&' | null\n\nexport interface Reference {\n kind: 'ref'\n name: string\n indices: Expression[]\n /** `a.b` member access. */\n sub?: Reference\n span: Span\n /** Resolved declaration (ValuedObject id), set by the resolver. */\n decl?: string\n}\n\n// ----- Effects -----\n\nexport type AssignOperator = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '>>>=' | 'min=' | 'max='\n\nexport type Effect =\n | { kind: 'assign'; target: Reference; operator: AssignOperator; expression: Expression; span: Span; annotations?: Annotation[] }\n | { kind: 'postfix'; target: Reference; operator: '++' | '--'; span: Span; annotations?: Annotation[] }\n /** `S` or `S(value)`. A bare name in an effect list parses as an emission; emitting a non-signal is a\n * warning in KIELER's validator and an error from its compiler in reachable code (the validator reports\n * both). `S(v)` where S is a method or a reference becomes a 'call' effect in the resolver (KIELER's\n * KEffectsEmissionReferenceCallConverter). */\n | { kind: 'emit'; target: Reference; value?: Expression; span: Span; annotations?: Annotation[] }\n | { kind: 'call'; name: string; args: Expression[]; extern?: boolean; target?: Reference; super?: boolean; paramAccess?: ParamAccess[]; span: Span; annotations?: Annotation[] }\n | { kind: 'print'; args: Expression[]; span: Span; annotations?: Annotation[] }\n | { kind: 'randomize'; args: Expression[]; span: Span; annotations?: Annotation[] }\n | { kind: 'hostcode'; text: string; span: Span; annotations?: Annotation[] }\n /** `{ ... }` SCL code block. `text` is its source including the braces; the parsed body is kept too. */\n | { kind: 'code'; text: string; span: Span; declarations?: Declaration[]; statements?: SclStatement[]; annotations?: Annotation[] }\n\n/** Statements of SCL code blocks (`do { ... }`) and method bodies, as SCTX allows them. */\nexport type SclStatement =\n | Extract<Effect, { kind: 'assign' | 'postfix' | 'call' | 'print' | 'randomize' | 'hostcode' }>\n | { kind: 'label'; name: string; span: Span }\n | { kind: 'goto'; target: string; span: Span }\n | { kind: 'return'; expression: Expression; span: Span }\n | { kind: 'block'; declarations: Declaration[]; statements: SclStatement[]; span: Span }\n | { kind: 'if'; condition: Expression; declarations: Declaration[]; statements: SclStatement[]; else?: { declarations: Declaration[]; statements: SclStatement[]; span: Span }; span: Span }\n | { kind: 'while'; condition: Expression; declarations: Declaration[]; statements: SclStatement[]; span: Span }\n /** `for (int i = 0; i < n; i++) { ... }`: init is a declaration or a statement. */\n | { kind: 'for'; init?: Declaration | SclStatement; condition: Expression; update?: SclStatement; declarations: Declaration[]; statements: SclStatement[]; span: Span }\n /** An expression used as a statement (`for (; c; x)` update or initialisation without assignment). */\n | { kind: 'expression'; expression: Expression; span: Span }\n\n// ---------------------------------------------------------------------------------------------------\n// Engine API shapes\n// ---------------------------------------------------------------------------------------------------\n\nexport type Value = boolean | number | string | Value[] | null\n\nexport interface ParseResult {\n program?: Program\n diagnostics: Diagnostic[]\n}\n\nexport interface VariableInfo {\n name: string\n /** Declaration id. */\n id: string\n /** In compile()'s interface, KIELER's simulation type: a clock (and `clock-time`) of a timed chart is `float`, or\n * `int` with @IntegerClockType, as in KIELER's interface and data pool. */\n type: ValueType\n signal: boolean\n /** Valued signal (a signal with a type other than pure). */\n valued: boolean\n combine?: CombineOperator\n input: boolean\n output: boolean\n const: boolean\n /** Array dimensions (empty for scalars). */\n dims: number[]\n initialValue?: Value\n}\n\n/**\n * A value a trigger read at the moment it was checked (not after the tick). `name` is the reference as written in\n * the trigger (`n`, `a[i]`, `pre(x)`, `val(S)`; inside a referenced chart the referenced chart's names, with the\n * instance's values); `signal` marks a signal's presence (`value` true: present).\n */\nexport interface TraceSeen {\n name: string\n value: Value\n signal?: boolean\n}\n\nexport type TraceEvent =\n | { kind: 'enter'; state: string }\n | { kind: 'exit'; state: string }\n /** A source transition's trigger was evaluated (once per tick, result and values read). `reason`: the values in\n * words (\"n was 0 and S was present\"), `seen` the same as data. Constants and for-region counters are left out. */\n | { kind: 'check'; transition: string; result: boolean; reason?: string; seen?: TraceSeen[] }\n /** A source transition fired. `reason`/`seen`: what its trigger read when it was last checked true in this tick.\n * `unchecked`: it has a trigger but fired without that trigger being checked: KIELER takes a superstate's last\n * transition without checking it when, after the exit actions, no other transition holds (preemption.md P-23). */\n | { kind: 'take'; transition: string; reason?: string; seen?: TraceSeen[]; unchecked?: boolean }\n | { kind: 'action'; action: string; fired: boolean }\n | { kind: 'write'; variable: string; value: Value; by: string; how: 'init' | 'update' }\n | { kind: 'emit'; signal: string; value?: Value; by: string }\n | { kind: 'pause'; state: string; region: string }\n | { kind: 'terminate'; region: string }\n /** The state (or an ancestor's suspend) froze it in this tick; `reason`/`seen`: what the suspend trigger read. */\n | { kind: 'suspend'; state: string; reason?: string; seen?: TraceSeen[] }\n | { kind: 'print'; text: string; by: string }\n /** A plain-English explanation; `markdown` is the same with names and code in code spans (inline Markdown). */\n | { kind: 'note'; text: string; markdown?: string; related?: string[] }\n\nexport interface TickResult {\n /** 1 for the first reaction. */\n tick: number\n /**\n * The inputs by interface name (a signal: its presence) at the end of the tick: what the environment gave or kept\n * (missing inputs keep their value), unless the chart itself wrote the input in the tick (basics.md B-10), when it\n * is the value the chart wrote. `ranWith` has the values the tick started with.\n */\n inputs: Record<string, Value>\n /**\n * Every input's value as this tick ran with it: after the environment's values were applied (missing inputs keep\n * theirs, B-9; tick 1's assignments KIELER makes before reading inputs, B-7) and before the chart wrote any, by\n * KIELER's names: a valued input signal V as `V` (its presence) and `V_val` (its value); an unset string is null.\n * Sending these to `step()` again, tick by tick, gives the same run. (Optional only for hand-made results.)\n */\n ranWith?: Record<string, Value>\n /** Every interface and local variable after the tick. For a valued signal: its value. */\n values: Record<string, Value>\n /** Signal presence in this tick (pure and valued signals). */\n present: Record<string, boolean>\n /** Ids of all states active at the end of the tick (including ancestors and the root). */\n active: string[]\n entered: string[]\n exited: string[]\n /** Transition ids in the order they fired. A transition can fire more than once (immediate chains). */\n taken: string[]\n /** Ids of local actions whose effects ran. */\n actions: string[]\n /** The root has terminated (in this tick or an earlier one): nothing will happen in later ticks.\n * Sticky. KIELER's _TERM flag (the oracle's `terminated`) is true only in the tick of termination,\n * so compare against the first tick whose `terminated` is true. */\n terminated: boolean\n /** True only in the tick in which the root terminated (KIELER's _TERM). */\n terminatedNow?: boolean\n /** Micro-steps of the reaction in execution order, for \"explain this tick\". */\n log: TraceEvent[]\n /** Text from print() effects. */\n printed: string[]\n /** A runtime failure (division by zero, array index out of range, runaway immediate loop, ...). */\n error?: Diagnostic\n /**\n * For-region copies (structure.md S-21 .. S-23), when the chart has for-regions: every copy, in KIELER's order (the\n * for-regions in order, each copy in counter order), with the states active in that copy at the end of the tick and\n * the states entered in it during the tick. `active`, `entered` and `exited` above report a copy's states by the\n * ids of the one region the diagram draws, once for all copies; this says which copy is where.\n */\n copies?: ForCopyState[]\n}\n\n/** One copy of a for-region in a tick (TickResult.copies). */\nexport interface ForCopyState {\n /** The for-region's id (as written: the diagram draws it once). */\n region: string\n /** The counter's value in this copy (the engine gives a number; a string is allowed in hand-made results). */\n value: number | string\n /** Source ids of the states active in this copy at the end of the tick, outermost first. */\n active: string[]\n /** Source ids of the states entered in this copy during the tick, in order. */\n entered: string[]\n}\n\n/** A for-region and its copies (CompileResult.forCopies). */\nexport interface ForCopies {\n /** The for-region's id. */\n region: string\n /** The counter's name. */\n counter: string\n /** The counter's values, one per copy, in KIELER's order of the copies. */\n values: number[]\n /** The region's name, when it has one. */\n name?: string\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@sccharts-lab/engine",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "SCCharts compiler, simulator and C code generator in TypeScript, verified against KIELER: parse SCTX, check it as KIELER does, run it tick by tick, generate C",
5
+ "keywords": [
6
+ "sccharts",
7
+ "sctx",
8
+ "kieler",
9
+ "synchronous-languages",
10
+ "statecharts",
11
+ "compiler",
12
+ "simulator",
13
+ "code-generation",
14
+ "embedded",
15
+ "reactive-systems"
16
+ ],
17
+ "homepage": "https://sccharts.jmw.nz",
18
+ "bugs": "https://github.com/Fallstop/sccharts-lab/issues",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/Fallstop/sccharts-lab.git",
22
+ "directory": "site/packages/engine"
23
+ },
24
+ "license": "EPL-2.0",
25
+ "type": "module",
26
+ "sideEffects": false,
27
+ "engines": {
28
+ "node": ">=20"
29
+ },
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./types": {
36
+ "types": "./dist/types.d.ts",
37
+ "default": "./dist/types.js"
38
+ },
39
+ "./format": {
40
+ "types": "./dist/format.d.ts",
41
+ "default": "./dist/format.js"
42
+ },
43
+ "./lexer": {
44
+ "types": "./dist/parser/lexer.d.ts",
45
+ "default": "./dist/parser/lexer.js"
46
+ },
47
+ "./internal": {
48
+ "types": "./dist/internal.d.ts",
49
+ "default": "./dist/internal.js"
50
+ },
51
+ "./package.json": "./package.json"
52
+ },
53
+ "files": [
54
+ "dist"
55
+ ],
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "main": "./dist/index.js",
60
+ "types": "./dist/index.d.ts"
6
61
  }