Giter VIP home page Giter VIP logo

lambdajs's Introduction

LambdaJS

LambdaJS is small, tested, reduction semantics for JavaScript. It was proposal by Brown PLT group in 2010. Read their paper.

This repo reproduces the translation ("desguar") between JavaScript and LambdaJS using Ocaml.

Pipeline

pipeline

  1. JavaScript is processed by Flow Parser first to generate JS AST.
  2. The translation is working on the JS AST, and the output is LambdaJS AST. That is the core part of this repo.
  3. A small utility is written to serialize the LambdaJS AST to S-expression.
  4. LambdaJS S-expression interpreter is from original LambdaJS codebase. The desugar result can be executed and tested directly by it.

Build

Please install opam, OCaml (>= 4.07) and Racket(>= 7.2) first. You can find guide for installing opam here.

Then a few third-party libraries are necessary:

opam install merlin user-setup menhir utop ppx_deriving ounit2 qcheck
opam pin add flow_parser https://github.com/facebook/flow.git

Finally,

dune build      # build the repo
dune runtest    # and run all unit tests!

Run

You can translate JS in example/qsort.js and run generated lambdaJS directly by:

cat ./examples/qsort.js | dune exec ./src/translate.exe | ./interp/interp-shell.ss  

dune exec completes pipeline step 1-3 and interp-shell finishes pipeline step 4. The output is written to stdout.

Below lists supported feature. All of them are in example directory. You can replace the js file in above command and run it directly.

TODO

  • Support prototype chain, and other interesting syntax.
  • Added black-box tests to check output of interpreter, rather than S-expression.
  • Brown University proposed S5, an extension for LambdaJS with ES5 support. Maybe we can learn something from it.

lambdajs's People

Contributors

lw-cui avatar

Stargazers

 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.