Coder Social home page Coder Social logo

alcen / lazy-source Goto Github PK

View Code? Open in Web Editor NEW

This project forked from source-academy/js-slang

0.0 1.0 0.0 3.42 MB

Implementation of a lazy version of Source languages

Home Page: https://sourceacademy.nus.edu.sg

License: Apache License 2.0

TypeScript 72.19% Shell 0.44% JavaScript 27.37%

lazy-source's Introduction

js-slang

https://travis-ci.org/source-academy/js-slang.svg?branch=master https://coveralls.io/repos/github/source-academy/js-slang/badge.svg?branch=master

Open-source implementations of the programming language Source. Source is a series of small subsets of JavaScript, designed for teaching university-level programming courses for computer science majors, following Structure and Interpretation of Computer Programs, JavaScript Adaptation (https://sicp.comp.nus.edu.sg).

Usage

To run in native, set isNativeRunnable to true here: https://github.com/source-academy/js-slang/blob/master/src/index.ts#L29

To build,

$ git clone https://github.com/source-academy/js-slang.git
$ cd js-slang
$ yarn
$ yarn build

To try out Source in a REPL, run

$ node dist/repl/repl.js [chapter] # default: 1

If you wish, you can pass in a file path instead, to evaluate some Source before initialising the REPL It will be run in Source chapter 4.

$ node dist/repl/repl.js [path/to/file]

or alternatively, install js-slang and run

$ npm -g install js-slang   # Install js-slang
$ js-slang [chapter] # default: 1

Documentation

Source is documented here: https://sicp.comp.nus.edu.sg/source/

To build the documentation, run

$ git clone https://github.com/source-academy/js-slang.git
$ cd js-slang
$ npm install # If additional permissions are required, run sudo npm install
$ yarn jsdoc  # to make the web pages in js-slang/doc/source
$ cd doc
$ make        # to make the PDF documents using LaTeX

Documentation on the Source libraries are generated from inline documentation in the library sources. The libraries are in repository cadet-frontend, which is assumed to be located in ../cadet-frontend, from the root of this repo. The command yarn jsdoc makes the documentation available in folder doc/jsdoc/libraries/. The script jsdoc provides an installation command to deploy the documentation via scp on a server: yarn jsdoc install

Testing

js-slang comes with an extensive test suite. To run the tests after you made your modifications, run yarn test. Regression tests are run automatically when you want to push changes to this repository. The regression tests are generated using jest and stored as snapshots in src/__tests__.

After modifying js-slang, carefully inspect any failing regression tests reported in red in the command line. If you are convinced that the regression tests and not your changes are at fault, you can update the regression tests as follows:

$ yarn test -- --updateSnapshot

Error messages

To enable verbose messages, have the statement "enable verbose"; as the first line of your code.

There are two main kinds of error messages: those that occur at runtime and those that occur at parse time. The first can be found in interpreter-errors.ts, while the second can be found in rules/.

Each error subclass will have explain() and elaborate(). Displaying the error will always cause the first to be called; the second is only called when verbose mode is enabled. As such, explain() should be made to return a string containing the most basic information about what the error entails. Any additional details about the error message, including specifics and correction guides, should be left to elaborate().

Please remember to write test cases to reflect your added functionalities. The god of this repository is self-professed to be very particular about test cases.

Using your js-slang in local Source Academy

A common issue when developing modifications to js-slang is how to test it using your own local frontend. Assume that you have built your own cadet-frontend locally, here is how you can make it use your own js-slang, instead of the one that the Source Academy team has deployed to npm:

$ cd js-slang
$ yarn build
$ cp -r dist ../cadet-frontend/node_modules/js-slang

Then start frontend and the new js-slang will be used.

lazy-source's People

Contributors

alcen avatar martin-henz avatar ning-y avatar openorclose avatar remo5000 avatar thomastanck avatar jomcruz93 avatar dependabot[bot] avatar dependabot-preview[bot] avatar yyc avatar bobbyzhouzijian avatar leowwb avatar swampertx avatar podocarp avatar jiachen247 avatar hcwong avatar kush1509 avatar j0 avatar geshuming avatar meowzz95 avatar urieltan avatar zhaojj2209 avatar

Watchers

James Cloos 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.