Giter VIP home page Giter VIP logo

ambients-reducer's Introduction

Ambients Reducer

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.

Install

git clone https://github.com/haadcode/ambients-reducer.git
npm install

Build

npm run build

Build + Watch

npm run start

Usage

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))

Examples

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

ambients-reducer's People

Contributors

aphelionz avatar haadcode avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.