Skip to content

Lw-Cui/LambdaJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

9962373 · Dec 21, 2020

History

36 Commits
Dec 18, 2020
Dec 18, 2020
Dec 10, 2020
Dec 10, 2020
Dec 10, 2020
Nov 10, 2020
Dec 21, 2020
Dec 21, 2020
Nov 10, 2020
Dec 10, 2020

Repository files navigation

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.

About

Translation between JavaScript and LambdaJS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published