@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,670 @@
1
+ /** Offsets are UTF-16 indices into the source; lines and columns are 1-based. `end` is exclusive. */
2
+ export interface Span {
3
+ start: number;
4
+ end: number;
5
+ line: number;
6
+ col: number;
7
+ endLine: number;
8
+ endCol: number;
9
+ }
10
+ export type Severity = 'error' | 'warning' | 'info';
11
+ export interface Diagnostic {
12
+ severity: Severity;
13
+ message: string;
14
+ span?: Span;
15
+ /** Stable machine-readable code, e.g. 'parse', 'unknown-variable', 'causality-cycle', 'instantaneous-loop'. */
16
+ code?: string;
17
+ /** One or two sentences a beginner can act on ("Make one of the transitions delayed ..."). */
18
+ hint?: string;
19
+ /** Ids of the model elements involved (states, transitions, regions), for highlighting in the diagram. */
20
+ related?: string[];
21
+ /** KIELER's own message for the same problem (validation and linking diagnostics), when it has one. */
22
+ kieler?: string;
23
+ /** The name the message suggests instead (its "did you mean"): a quick fix may put it in place of `span`. */
24
+ suggestion?: string;
25
+ /** A runtime error (`TickResult.error`): the tick in which the simulation stopped. Later ticks repeat the error
26
+ * with this tick, since KIELER's simulation stays stopped. */
27
+ tick?: number;
28
+ }
29
+ export interface NodeBase {
30
+ span: Span;
31
+ }
32
+ export interface Program extends NodeBase {
33
+ kind: 'program';
34
+ /** `import "file"` strings in order. */
35
+ imports: string[];
36
+ /** Spans of the import names (parallel to imports). */
37
+ importSpans?: Span[];
38
+ pragmas: Pragma[];
39
+ /** Every `scchart` in the file, in order. The simulator runs one of them (default: the first, as KIELER: Reference.xtend keeps rootStates.head). */
40
+ charts: State[];
41
+ /** Ordinary `// ...` and `/* ... *\/` comments (hidden from the grammar), in source order. */
42
+ comments?: {
43
+ kind: 'line' | 'block';
44
+ text: string;
45
+ span: Span;
46
+ }[];
47
+ }
48
+ export interface Annotation extends NodeBase {
49
+ kind: 'annotation';
50
+ /** Name without the '@' (or 'comment' for a doc comment). */
51
+ name: string;
52
+ values: string[];
53
+ /** Typed annotation `@layout[elk.direction] UP`: the part in brackets. */
54
+ type?: string;
55
+ /** JSON annotation `@name {"key": 1}`: the object's source text. */
56
+ json?: string;
57
+ }
58
+ export interface Pragma extends NodeBase {
59
+ kind: 'pragma';
60
+ name: string;
61
+ values: string[];
62
+ /** JSON pragma `#name {"key": 1}`: the object's source text. */
63
+ json?: string;
64
+ }
65
+ export interface State extends NodeBase {
66
+ kind: 'state';
67
+ id: string;
68
+ name: string;
69
+ /** Optional display label: `state A "Waiting for A"`. */
70
+ label?: string;
71
+ isRoot: boolean;
72
+ initial: boolean;
73
+ final: boolean;
74
+ connector: boolean;
75
+ violation: boolean;
76
+ annotations: Annotation[];
77
+ /** Text of the `/** ... *\/` doc comment directly before the element, without the comment markers. */
78
+ doc?: string;
79
+ declarations: Declaration[];
80
+ /**
81
+ * Declarations written after the actions, states or regions (a syntax error). KIELER's parser drops them, so they
82
+ * are not in the scope and the names they declare do not resolve (as in KIELER); kept for the linker's hint.
83
+ */
84
+ lateDeclarations?: Declaration[];
85
+ actions: LocalAction[];
86
+ /** Concurrent regions. Empty for a simple state. States written directly inside a superstate
87
+ * (without `region`) form one implicit region (`implicit: true`). */
88
+ regions: Region[];
89
+ /** Outgoing transitions in priority order: transitions[0] has priority 1. */
90
+ transitions: Transition[];
91
+ /** `state S is Other(a, b to c)`: the state is an instance of another SCChart. */
92
+ reference?: ScopeCall;
93
+ /** `calls` (module call) instead of `is`. */
94
+ callsReference?: boolean;
95
+ /** `extends` base states (inheritance, rare). */
96
+ baseStates?: ScopeCall[];
97
+ /** Generic parameter declarations `scchart X<T is int>`, kept as written. */
98
+ genericParameters?: string[];
99
+ /** Span of just the state's name (for go-to-definition and renaming). */
100
+ nameSpan: Span;
101
+ /** `policy` regions of a root state (kept apart from `regions`; they describe method call protocols). */
102
+ policies?: Region[];
103
+ }
104
+ export interface Region extends NodeBase {
105
+ kind: 'region';
106
+ id: string;
107
+ regionType: 'controlflow' | 'dataflow';
108
+ name?: string;
109
+ label?: string;
110
+ /** States written straight into a superstate or scchart without a `region` keyword. */
111
+ implicit: boolean;
112
+ annotations: Annotation[];
113
+ doc?: string;
114
+ /** `final region` / `abort region` / `override region` modifiers. */
115
+ final?: boolean;
116
+ abort?: boolean;
117
+ override?: boolean;
118
+ declarations: Declaration[];
119
+ actions: LocalAction[];
120
+ /** Control-flow regions. */
121
+ states: State[];
122
+ /** Dataflow regions (`dataflow { O = A && B }`). */
123
+ equations: Equation[];
124
+ /** `region R for i : 0 to 3` (end omitted: `for i : ARRAY` iterates an array's indices). */
125
+ forLoop?: {
126
+ variable: string;
127
+ from: Expression;
128
+ to?: Expression;
129
+ span: Span;
130
+ };
131
+ /** `region R is super.X`: resolves only to regions inherited through `extends`; it does not instantiate a chart. */
132
+ reference?: ScopeCall;
133
+ /** Dataflow `once`. */
134
+ once?: boolean;
135
+ /** Span of the region's name (when it has one). */
136
+ nameSpan?: Span;
137
+ /** A `policy` region of a chart or host class (method call protocol); not part of the behaviour. */
138
+ policy?: boolean;
139
+ }
140
+ export type DelayType = 'delayed' | 'immediate' | 'auto' | 'undefined';
141
+ export type PreemptionType = 'weak' | 'strong' | 'termination';
142
+ export interface Transition extends NodeBase {
143
+ kind: 'transition';
144
+ id: string;
145
+ /** Id of the source state. */
146
+ source: string;
147
+ /** Target state name as written. */
148
+ targetName: string;
149
+ /** Resolved id of the target state (set by the resolver; undefined if it does not resolve). */
150
+ target?: string;
151
+ targetSpan: Span;
152
+ /** Priority, 1-based, in the order the transitions are written under their source state. */
153
+ priority: number;
154
+ /** As written; undefined means the keyword was omitted (delayed, except for connector sources). */
155
+ delay?: DelayType;
156
+ /** `go to` = weak abort, `abort to` = strong abort, `join to` = termination. */
157
+ preemption: PreemptionType;
158
+ /** Count delay: `if 3 A go to B` fires on the third tick in which A holds. */
159
+ triggerDelay?: number;
160
+ trigger?: Expression;
161
+ /** `Pr=0.5` probability and `nondeterministic` (kept, not simulated). */
162
+ probability?: number;
163
+ nondeterministic?: boolean;
164
+ effects: Effect[];
165
+ deferred?: 'shallow' | 'deep';
166
+ history?: 'reset' | 'shallow' | 'deep';
167
+ label?: string;
168
+ annotations: Annotation[];
169
+ doc?: string;
170
+ }
171
+ export type LocalActionKind = 'entry' | 'during' | 'exit' | 'suspend' | 'period' | 'ode';
172
+ export interface LocalAction extends NodeBase {
173
+ kind: LocalActionKind;
174
+ id: string;
175
+ /** `immediate during`, `immediate suspend`, ... */
176
+ delay?: DelayType;
177
+ /** `weak entry` / `strong exit` (PreemptionActionType) */
178
+ preemption?: 'weak' | 'strong';
179
+ /** `weak suspend` */
180
+ weak?: boolean;
181
+ triggerDelay?: number;
182
+ trigger?: Expression;
183
+ /** `entry if A Pr 0.5`, `during if A Pr=0.5` (kept, not simulated). */
184
+ probability?: number;
185
+ effects: Effect[];
186
+ label?: string;
187
+ annotations: Annotation[];
188
+ doc?: string;
189
+ }
190
+ export interface Equation extends NodeBase {
191
+ kind: 'equation';
192
+ target: Reference;
193
+ operator: AssignOperator;
194
+ expression: Expression;
195
+ sequential?: boolean;
196
+ /** Dataflow reference call `A(x, y)` / `A(x) = e`: the call's arguments (expression is then the call or `e`). */
197
+ callArgs?: Expression[];
198
+ annotations?: Annotation[];
199
+ }
200
+ export interface ScopeCall extends NodeBase {
201
+ kind: 'scopeCall';
202
+ target: string;
203
+ /** Bindings in order. `binding` is set for explicit `x to y` bindings (the referenced chart's name). */
204
+ parameters: ScopeParameter[];
205
+ genericParameters?: string[];
206
+ super?: boolean;
207
+ /** Span of the target name. */
208
+ targetSpan?: Span;
209
+ }
210
+ export interface ScopeParameter {
211
+ expression: Expression;
212
+ /** Explicit binding `x to y`: the name of the referenced chart's interface variable. */
213
+ binding?: string;
214
+ /** Resolved ValuedObject id of the explicit binding (set by the resolver). */
215
+ bindingDecl?: string;
216
+ /** `x to y[1]` */
217
+ bindingIndices?: Expression[];
218
+ /** Span of the binding name after `to`. */
219
+ bindingSpan?: Span;
220
+ /** `&x`: call by reference. */
221
+ byReference?: boolean;
222
+ /** `!&x`: pure output. */
223
+ pureOutput?: boolean;
224
+ span: Span;
225
+ }
226
+ export type ValueType = 'pure' | 'bool' | 'int' | 'float' | 'string' | 'clock' | 'clock-time' | 'host';
227
+ export type CombineOperator = 'none' | '+' | '*' | 'max' | 'min' | '|' | '&' | 'host';
228
+ export interface Declaration extends NodeBase {
229
+ kind: 'declaration';
230
+ /** `variable` for ordinary (and signal) declarations; others are parsed so charts that use them
231
+ * still load, and the simulator reports them as unsupported if they matter. */
232
+ declKind: 'variable' | 'reference' | 'method' | 'enum' | 'class' | 'struct' | 'schedule' | 'primitive';
233
+ /** Undefined only for `signal S` (a pure signal). */
234
+ type?: ValueType;
235
+ /** `host "unsigned char" x` */
236
+ hostType?: string;
237
+ /** For `ref`/reference declarations: `ref Other o`. */
238
+ referenceTarget?: string;
239
+ signal: boolean;
240
+ input: boolean;
241
+ output: boolean;
242
+ const: boolean;
243
+ global: boolean;
244
+ static: boolean;
245
+ extern?: boolean;
246
+ access?: 'public' | 'protected' | 'private';
247
+ annotations: Annotation[];
248
+ doc?: string;
249
+ valuedObjects: ValuedObject[];
250
+ /** Raw source text of declarations the engine does not model in detail (methods, classes, enums). */
251
+ text?: string;
252
+ /** `extern "rand", @Java "Math.random" rand`: the host code strings with their tag annotations. */
253
+ externs?: {
254
+ code: string;
255
+ annotations: Annotation[];
256
+ }[];
257
+ /** `ref Container.Chart x`: the container part. */
258
+ referenceContainer?: string;
259
+ /** Span of the referenced type's name (`ref Chart x`, `primitive T x`). */
260
+ referenceSpan?: Span;
261
+ /** `ref Chart<T> x`: generic arguments as written. */
262
+ genericParameters?: string[];
263
+ /** Class, struct and enum: the type name (`class Counter {...} c` -> 'Counter'); also kept on host classes. */
264
+ className?: string;
265
+ /** `host class ...`, `host enum ...` */
266
+ host?: boolean;
267
+ /** Members of a class or struct (declarations and methods), or the members of an enum (one declaration). */
268
+ members?: Declaration[];
269
+ /** Methods: return type as written (`int`, `void`, `host "char*"` -> 'host'), the parameters and the body. */
270
+ returnType?: string;
271
+ returnHostType?: string;
272
+ parameters?: Declaration[];
273
+ body?: {
274
+ declarations: Declaration[];
275
+ statements: SclStatement[];
276
+ span: Span;
277
+ };
278
+ /** `override method ...` */
279
+ override?: boolean;
280
+ /** Schedule declarations: `schedule {conflicting, commuting} s` priorities, and `global` protocol. */
281
+ priorities?: string[];
282
+ /** `policy` regions of a host class. */
283
+ policies?: Region[];
284
+ }
285
+ export interface ValuedObject extends NodeBase {
286
+ kind: 'valuedObject';
287
+ id: string;
288
+ name: string;
289
+ /** Array dimensions: `int a[3][2]` → two expressions. */
290
+ cardinalities: Expression[];
291
+ initialValue?: Expression;
292
+ combine?: CombineOperator;
293
+ label?: string;
294
+ /** `ref Chart c(x to y)`: bindings of a reference valued object. */
295
+ parameters?: ScopeParameter[];
296
+ genericParameters?: string[];
297
+ annotations?: Annotation[];
298
+ /** Span of just the name. */
299
+ nameSpan?: Span;
300
+ }
301
+ export type OperatorType = '||' | '&&' | '|' | '^' | '&' | '==' | '!=' | '<' | '<=' | '>' | '>=' | '<<' | '>>' | '>>>' | '+' | '-' | '*' | '/' | '%' | '!' | '~' | 'neg' | '?:' | 'pre' | 'val' | '->' | 'fby' | 'sfby';
302
+ export type Expression = {
303
+ kind: 'bool';
304
+ value: boolean;
305
+ span: Span;
306
+ } | {
307
+ kind: 'int';
308
+ value: number;
309
+ span: Span;
310
+ } | {
311
+ kind: 'float';
312
+ value: number;
313
+ span: Span;
314
+ } | {
315
+ kind: 'string';
316
+ value: string;
317
+ span: Span;
318
+ } | Reference | {
319
+ kind: 'op';
320
+ op: OperatorType;
321
+ args: Expression[];
322
+ span: Span;
323
+ }
324
+ /** Call of a method or referenced chart: `f(x)`, `obj.f(x)` (name 'obj.f'); `extern f(x)` sets extern.
325
+ * `target` is the called reference (with indices, sub-reference and resolved decl) for non-extern calls. */
326
+ | {
327
+ kind: 'call';
328
+ name: string;
329
+ args: Expression[];
330
+ extern?: boolean;
331
+ target?: Reference;
332
+ super?: boolean;
333
+ paramAccess?: ParamAccess[];
334
+ span: Span;
335
+ } | {
336
+ kind: 'random';
337
+ span: Span;
338
+ } | {
339
+ kind: 'randomize';
340
+ span: Span;
341
+ } | {
342
+ kind: 'hostcode';
343
+ text: string;
344
+ span: Span;
345
+ } | {
346
+ kind: 'vector';
347
+ values: Expression[];
348
+ range?: boolean;
349
+ span: Span;
350
+ } | {
351
+ kind: 'ignore';
352
+ span: Span;
353
+ } | {
354
+ kind: 'null';
355
+ span: Span;
356
+ }
357
+ /**
358
+ * `scchart(Chart).x` (target 'Chart', sub x) or `state(R.S)` (container 'R', target 'S'). `state`: the id of the
359
+ * state a `state(...)` names, set by name resolution.
360
+ */
361
+ | {
362
+ kind: 'special';
363
+ access: 'static' | 'scchart' | 'state';
364
+ text: string;
365
+ target?: string;
366
+ container?: string;
367
+ sub?: Reference;
368
+ state?: string;
369
+ span: Span;
370
+ }
371
+ /** `this` (only as a parameter of a reference). */
372
+ | {
373
+ kind: 'this';
374
+ span: Span;
375
+ };
376
+ /** Parameter passing mode of a call argument: `&x` call by reference, `!&x` pure output, null for a plain value. */
377
+ export type ParamAccess = '&' | '!&' | null;
378
+ export interface Reference {
379
+ kind: 'ref';
380
+ name: string;
381
+ indices: Expression[];
382
+ /** `a.b` member access. */
383
+ sub?: Reference;
384
+ span: Span;
385
+ /** Resolved declaration (ValuedObject id), set by the resolver. */
386
+ decl?: string;
387
+ }
388
+ export type AssignOperator = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '>>>=' | 'min=' | 'max=';
389
+ export type Effect = {
390
+ kind: 'assign';
391
+ target: Reference;
392
+ operator: AssignOperator;
393
+ expression: Expression;
394
+ span: Span;
395
+ annotations?: Annotation[];
396
+ } | {
397
+ kind: 'postfix';
398
+ target: Reference;
399
+ operator: '++' | '--';
400
+ span: Span;
401
+ annotations?: Annotation[];
402
+ }
403
+ /** `S` or `S(value)`. A bare name in an effect list parses as an emission; emitting a non-signal is a
404
+ * warning in KIELER's validator and an error from its compiler in reachable code (the validator reports
405
+ * both). `S(v)` where S is a method or a reference becomes a 'call' effect in the resolver (KIELER's
406
+ * KEffectsEmissionReferenceCallConverter). */
407
+ | {
408
+ kind: 'emit';
409
+ target: Reference;
410
+ value?: Expression;
411
+ span: Span;
412
+ annotations?: Annotation[];
413
+ } | {
414
+ kind: 'call';
415
+ name: string;
416
+ args: Expression[];
417
+ extern?: boolean;
418
+ target?: Reference;
419
+ super?: boolean;
420
+ paramAccess?: ParamAccess[];
421
+ span: Span;
422
+ annotations?: Annotation[];
423
+ } | {
424
+ kind: 'print';
425
+ args: Expression[];
426
+ span: Span;
427
+ annotations?: Annotation[];
428
+ } | {
429
+ kind: 'randomize';
430
+ args: Expression[];
431
+ span: Span;
432
+ annotations?: Annotation[];
433
+ } | {
434
+ kind: 'hostcode';
435
+ text: string;
436
+ span: Span;
437
+ annotations?: Annotation[];
438
+ }
439
+ /** `{ ... }` SCL code block. `text` is its source including the braces; the parsed body is kept too. */
440
+ | {
441
+ kind: 'code';
442
+ text: string;
443
+ span: Span;
444
+ declarations?: Declaration[];
445
+ statements?: SclStatement[];
446
+ annotations?: Annotation[];
447
+ };
448
+ /** Statements of SCL code blocks (`do { ... }`) and method bodies, as SCTX allows them. */
449
+ export type SclStatement = Extract<Effect, {
450
+ kind: 'assign' | 'postfix' | 'call' | 'print' | 'randomize' | 'hostcode';
451
+ }> | {
452
+ kind: 'label';
453
+ name: string;
454
+ span: Span;
455
+ } | {
456
+ kind: 'goto';
457
+ target: string;
458
+ span: Span;
459
+ } | {
460
+ kind: 'return';
461
+ expression: Expression;
462
+ span: Span;
463
+ } | {
464
+ kind: 'block';
465
+ declarations: Declaration[];
466
+ statements: SclStatement[];
467
+ span: Span;
468
+ } | {
469
+ kind: 'if';
470
+ condition: Expression;
471
+ declarations: Declaration[];
472
+ statements: SclStatement[];
473
+ else?: {
474
+ declarations: Declaration[];
475
+ statements: SclStatement[];
476
+ span: Span;
477
+ };
478
+ span: Span;
479
+ } | {
480
+ kind: 'while';
481
+ condition: Expression;
482
+ declarations: Declaration[];
483
+ statements: SclStatement[];
484
+ span: Span;
485
+ }
486
+ /** `for (int i = 0; i < n; i++) { ... }`: init is a declaration or a statement. */
487
+ | {
488
+ kind: 'for';
489
+ init?: Declaration | SclStatement;
490
+ condition: Expression;
491
+ update?: SclStatement;
492
+ declarations: Declaration[];
493
+ statements: SclStatement[];
494
+ span: Span;
495
+ }
496
+ /** An expression used as a statement (`for (; c; x)` update or initialisation without assignment). */
497
+ | {
498
+ kind: 'expression';
499
+ expression: Expression;
500
+ span: Span;
501
+ };
502
+ export type Value = boolean | number | string | Value[] | null;
503
+ export interface ParseResult {
504
+ program?: Program;
505
+ diagnostics: Diagnostic[];
506
+ }
507
+ export interface VariableInfo {
508
+ name: string;
509
+ /** Declaration id. */
510
+ id: string;
511
+ /** In compile()'s interface, KIELER's simulation type: a clock (and `clock-time`) of a timed chart is `float`, or
512
+ * `int` with @IntegerClockType, as in KIELER's interface and data pool. */
513
+ type: ValueType;
514
+ signal: boolean;
515
+ /** Valued signal (a signal with a type other than pure). */
516
+ valued: boolean;
517
+ combine?: CombineOperator;
518
+ input: boolean;
519
+ output: boolean;
520
+ const: boolean;
521
+ /** Array dimensions (empty for scalars). */
522
+ dims: number[];
523
+ initialValue?: Value;
524
+ }
525
+ /**
526
+ * A value a trigger read at the moment it was checked (not after the tick). `name` is the reference as written in
527
+ * the trigger (`n`, `a[i]`, `pre(x)`, `val(S)`; inside a referenced chart the referenced chart's names, with the
528
+ * instance's values); `signal` marks a signal's presence (`value` true: present).
529
+ */
530
+ export interface TraceSeen {
531
+ name: string;
532
+ value: Value;
533
+ signal?: boolean;
534
+ }
535
+ export type TraceEvent = {
536
+ kind: 'enter';
537
+ state: string;
538
+ } | {
539
+ kind: 'exit';
540
+ state: string;
541
+ }
542
+ /** A source transition's trigger was evaluated (once per tick, result and values read). `reason`: the values in
543
+ * words ("n was 0 and S was present"), `seen` the same as data. Constants and for-region counters are left out. */
544
+ | {
545
+ kind: 'check';
546
+ transition: string;
547
+ result: boolean;
548
+ reason?: string;
549
+ seen?: TraceSeen[];
550
+ }
551
+ /** A source transition fired. `reason`/`seen`: what its trigger read when it was last checked true in this tick.
552
+ * `unchecked`: it has a trigger but fired without that trigger being checked: KIELER takes a superstate's last
553
+ * transition without checking it when, after the exit actions, no other transition holds (preemption.md P-23). */
554
+ | {
555
+ kind: 'take';
556
+ transition: string;
557
+ reason?: string;
558
+ seen?: TraceSeen[];
559
+ unchecked?: boolean;
560
+ } | {
561
+ kind: 'action';
562
+ action: string;
563
+ fired: boolean;
564
+ } | {
565
+ kind: 'write';
566
+ variable: string;
567
+ value: Value;
568
+ by: string;
569
+ how: 'init' | 'update';
570
+ } | {
571
+ kind: 'emit';
572
+ signal: string;
573
+ value?: Value;
574
+ by: string;
575
+ } | {
576
+ kind: 'pause';
577
+ state: string;
578
+ region: string;
579
+ } | {
580
+ kind: 'terminate';
581
+ region: string;
582
+ }
583
+ /** The state (or an ancestor's suspend) froze it in this tick; `reason`/`seen`: what the suspend trigger read. */
584
+ | {
585
+ kind: 'suspend';
586
+ state: string;
587
+ reason?: string;
588
+ seen?: TraceSeen[];
589
+ } | {
590
+ kind: 'print';
591
+ text: string;
592
+ by: string;
593
+ }
594
+ /** A plain-English explanation; `markdown` is the same with names and code in code spans (inline Markdown). */
595
+ | {
596
+ kind: 'note';
597
+ text: string;
598
+ markdown?: string;
599
+ related?: string[];
600
+ };
601
+ export interface TickResult {
602
+ /** 1 for the first reaction. */
603
+ tick: number;
604
+ /**
605
+ * The inputs by interface name (a signal: its presence) at the end of the tick: what the environment gave or kept
606
+ * (missing inputs keep their value), unless the chart itself wrote the input in the tick (basics.md B-10), when it
607
+ * is the value the chart wrote. `ranWith` has the values the tick started with.
608
+ */
609
+ inputs: Record<string, Value>;
610
+ /**
611
+ * Every input's value as this tick ran with it: after the environment's values were applied (missing inputs keep
612
+ * theirs, B-9; tick 1's assignments KIELER makes before reading inputs, B-7) and before the chart wrote any, by
613
+ * KIELER's names: a valued input signal V as `V` (its presence) and `V_val` (its value); an unset string is null.
614
+ * Sending these to `step()` again, tick by tick, gives the same run. (Optional only for hand-made results.)
615
+ */
616
+ ranWith?: Record<string, Value>;
617
+ /** Every interface and local variable after the tick. For a valued signal: its value. */
618
+ values: Record<string, Value>;
619
+ /** Signal presence in this tick (pure and valued signals). */
620
+ present: Record<string, boolean>;
621
+ /** Ids of all states active at the end of the tick (including ancestors and the root). */
622
+ active: string[];
623
+ entered: string[];
624
+ exited: string[];
625
+ /** Transition ids in the order they fired. A transition can fire more than once (immediate chains). */
626
+ taken: string[];
627
+ /** Ids of local actions whose effects ran. */
628
+ actions: string[];
629
+ /** The root has terminated (in this tick or an earlier one): nothing will happen in later ticks.
630
+ * Sticky. KIELER's _TERM flag (the oracle's `terminated`) is true only in the tick of termination,
631
+ * so compare against the first tick whose `terminated` is true. */
632
+ terminated: boolean;
633
+ /** True only in the tick in which the root terminated (KIELER's _TERM). */
634
+ terminatedNow?: boolean;
635
+ /** Micro-steps of the reaction in execution order, for "explain this tick". */
636
+ log: TraceEvent[];
637
+ /** Text from print() effects. */
638
+ printed: string[];
639
+ /** A runtime failure (division by zero, array index out of range, runaway immediate loop, ...). */
640
+ error?: Diagnostic;
641
+ /**
642
+ * For-region copies (structure.md S-21 .. S-23), when the chart has for-regions: every copy, in KIELER's order (the
643
+ * for-regions in order, each copy in counter order), with the states active in that copy at the end of the tick and
644
+ * the states entered in it during the tick. `active`, `entered` and `exited` above report a copy's states by the
645
+ * ids of the one region the diagram draws, once for all copies; this says which copy is where.
646
+ */
647
+ copies?: ForCopyState[];
648
+ }
649
+ /** One copy of a for-region in a tick (TickResult.copies). */
650
+ export interface ForCopyState {
651
+ /** The for-region's id (as written: the diagram draws it once). */
652
+ region: string;
653
+ /** The counter's value in this copy (the engine gives a number; a string is allowed in hand-made results). */
654
+ value: number | string;
655
+ /** Source ids of the states active in this copy at the end of the tick, outermost first. */
656
+ active: string[];
657
+ /** Source ids of the states entered in this copy during the tick, in order. */
658
+ entered: string[];
659
+ }
660
+ /** A for-region and its copies (CompileResult.forCopies). */
661
+ export interface ForCopies {
662
+ /** The for-region's id. */
663
+ region: string;
664
+ /** The counter's name. */
665
+ counter: string;
666
+ /** The counter's values, one per copy, in KIELER's order of the copies. */
667
+ values: number[];
668
+ /** The region's name, when it has one. */
669
+ name?: string;
670
+ }
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+ // The shared contract of the guide's SCCharts engine: the AST the parser produces, and the shapes the
2
+ // compiler, simulator and diagram renderer exchange. Everything here is plain data (JSON-serialisable),
3
+ // so it can cross a Web Worker boundary and be cached at build time.
4
+ //
5
+ // The textual syntax is KIELER's SCTX. The authoritative grammar is
6
+ // ../kieler-server-fork/modules/sccharts/src/de/cau/cs/kieler/sccharts/text/SCTX.xtext (with SCL, KExt,
7
+ // KEffects, KExpressions and Annotations). Names below follow the KIELER metamodel where one exists.
8
+ export {};
9
+ //# sourceMappingURL=types.js.map