Experimental Ambient Calculus reducer module. Give the reducer an ambient and it will reduce it to its final form.
Input: a[open_] | open a
Output: a[]
See example input format (JSON) which is produced by ambc, an ambients compiler.
git clone https://github.com/haadcode/ambients-reducer.git
npm install
npm run build
npm run start
Use as a module in a JavaScript program:
const fs = require("fs")
const deserializer = require("./src/Deserializer.bs.js")
const vm = require("./src/AmbientReducer.bs.js")
const jsonFile = "./__tests__/fixtures/001.json"
const json = fs.readFileSync(jsonFile, "utf8")
const program = deserializer.fromJSON(json)
const result = vm.reduceFully(program)
console.log(JSON.stringify(result, null, 2))
Run Program1.re:
node src/examples/Program1.bs.js
Output:
--------
initial state:
[]
└─ a[open b]
├─ b[in_ c.open c.open_]
└─ c[in b.open_]
└─ d[]
--------
final state:
[]
└─ a[]
└─ d[]
Run Program2.re:
node src/examples/Program2.bs.js
See step-by-step state of the reductions by running Program3.re:
node src/examples/Program3.bs.js
See the output of Program3 here