@bramas/simulant-lang 0.1.0 → 0.1.2

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.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @bramas/simulant-lang
2
+
3
+ Compiler and typed intermediate representation for Simulant, a language for
4
+ experiments on mobile entities and distributed algorithms. The compiler parses
5
+ `.sim` files, resolves imports, elaborates models and algorithms, lowers
6
+ structured procedures, and checks types and model capabilities.
7
+
8
+ For a complete project with a simulator and CLI:
9
+
10
+ ```sh
11
+ npm create @bramas/simulant@latest my-project
12
+ ```
13
+
14
+ ## Compiler API
15
+
16
+ ```sh
17
+ npm install @bramas/simulant-lang
18
+ ```
19
+
20
+ ```ts
21
+ import { loadProgram } from '@bramas/simulant-lang/elab/node';
22
+ import { compile } from '@bramas/simulant-lang/elab/elaborate';
23
+
24
+ const result = compile(loadProgram('src/main.sim'));
25
+ console.log(result.diagnostics);
26
+ console.log(Object.keys(result.experiments));
27
+ ```
28
+
29
+ Each entry in `result.experiments` contains diagnostics and, when compilation
30
+ succeeds, an `experiment`. `loadProgram` reads sources from disk and resolves
31
+ `std/*.sim` imports from the installed standard library. For custom source
32
+ storage, construct a `Program` with a source host instead.
33
+
34
+ Types are exported from `@bramas/simulant-lang/ir`; the independent TypeScript
35
+ IR builder is available at `@bramas/simulant-lang/builder`. This package uses
36
+ subpath exports; it has no root import. Execution and exploration belong to
37
+ `@bramas/simulant-engine`.
38
+
39
+ [Language reference](https://github.com/Bramas/simulant/blob/main/docs/sim-language.md)
40
+ · [IR contract](https://github.com/Bramas/simulant/blob/main/docs/ir.md)
41
+ · [Source](https://github.com/Bramas/simulant/tree/main/packages/lang)
42
+
43
+ Licensed under CeCILL-B; see `LICENCE.txt`.
@@ -29,7 +29,7 @@ export class ElabError extends Error {
29
29
  }
30
30
  }
31
31
  const fail = (msg, span) => { throw new ElabError(msg, span); };
32
- const ROUND = T.enum('Round', ['fsync', 'ssync']);
32
+ const ROUND = T.enum('Round', ['fsync', 'ssync', 'sequential']);
33
33
  const MEMORY = T.enum('Memory', ['persistent', 'oblivious']);
34
34
  const SYMMETRIES = T.enum('Symmetries', ['derived', 'none']);
35
35
  const META_TYPES = new Set(['Component', 'Model', 'Sensor', 'Topology', 'FrameModel', 'Round', 'Memory', 'Symmetries']);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bramas/simulant-lang",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "license": "CECILL-B",
6
6
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  "LICENCE.txt"
21
21
  ],
22
22
  "dependencies": {
23
- "@bramas/simulant-stdlib": "0.1.0"
23
+ "@bramas/simulant-stdlib": "0.1.2"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
@@ -52,7 +52,7 @@ type MV =
52
52
  | { m: 'topology'; ir: Topology }
53
53
  | { m: 'frame'; ir: FrameModel };
54
54
 
55
- const ROUND = T.enum('Round', ['fsync', 'ssync']) as Type & { k: 'enum' };
55
+ const ROUND = T.enum('Round', ['fsync', 'ssync', 'sequential']) as Type & { k: 'enum' };
56
56
  const MEMORY = T.enum('Memory', ['persistent', 'oblivious']) as Type & { k: 'enum' };
57
57
  const SYMMETRIES = T.enum('Symmetries', ['derived', 'none']) as Type & { k: 'enum' };
58
58
  const META_TYPES = new Set(['Component', 'Model', 'Sensor', 'Topology', 'FrameModel', 'Round', 'Memory', 'Symmetries']);
package/src/ir.ts CHANGED
@@ -145,8 +145,8 @@ export type Model = {
145
145
  sensors: Sensor[];
146
146
  memory: 'persistent' | 'oblivious';
147
147
  frame: FrameModel;
148
- /** `ssync`: the adversary activates a nonempty set of eligible agents; executions must be scheduler-fair. */
149
- round: 'fsync' | 'ssync';
148
+ /** `ssync`: a nonempty eligible subset; `sequential`: one eligible agent. Both require scheduler fairness. */
149
+ round: 'fsync' | 'ssync' | 'sequential';
150
150
  movement: 'rigid';
151
151
  components: Component[];
152
152
  symmetries: 'derived' | 'none';