Git Product home page Git Product logo

source-programs's Introduction

Source Programs

This repo contains programs written in Source, developed for SICP JS and other educational projects.

All programs in this repository are runnable in the Source Academy playground: copy the program into the editor, choose "Source §4", and press "Run".

Evaluators

The evaluators in this section all follow the general style of SICP JS Chapter 4.

Steppers

The steppers in this section implement a small-step semantics, following the substitution model of SICP JS Chapter 1 and 2.

Type checkers

The type checkers in this section follow a rule-based static semantics available in doc/type-checking.pdf.

Virtual machines

The virtual machines in this section are SECD-style and follow a description in doc/virtual-machines.pdf. Each virtual machine comes with a compiler, implemented in the same file.

Tool Demos

(click to run; for actual sources, go to src/tool-demos/)

Module Demos

(click to run; for actual sources, go to src/module-demos/)

Test framework

Testing

[requires bash (any version) and awk (BSD awk 20070501); does not work with gawk]

For testing your Source programs, you need node and yarn.

Write your test cases in a folder __tests__ in each src subfolder. The name of the file specifies the targeted Source of your test case. For example, if src/steppers/source-0.js is the Source, a test case might be src/steppers/__tests__/source-0.test1.js.

Only the tests written will be run.

Each test case is appended to your Source, and then run with js-slang (using Source §4). The last line of the test case is a // comment that must contain the expected result. For example, a stepper test case may be:

parse_and_evaluate("! (1 === 1 && 2 > 3);");
// true

Before you can run the tests, you need to install js-slang by typing:

% yarn
% yarn install

Run all test cases by typing:

% yarn test

For failure cases (where you program is to throw error, e.g. memory exhausted error for virtual machines), you can include the error message as per normal. The lastest JS-Slang already throws the error message explicitly, without letting the underlying TypeScript handling it. Hence, an error message

Line 2073: Error: memory exhausted despite garbage collection undefined

can be written in the test file:

// Line 2073: Error: memory exhausted despite garbage collection undefined

or

// Error: memory exhausted despite garbage collection undefined

where only the part that starts from Error: will be compared. Line number is be ignored as it varies. If line number is needed for a particular reason, it can be appended to the back.

Integration of the test script with src/test/framework/ is pending a fix to the --variant parameter; any help appreciated.

License

GPL 3 All JavaScript programs in this repository are licensed under the GNU General Public License Version 3.

source-programs's People

Contributors

martin-henz avatar moziliar avatar dingyuchen avatar arsalan0c avatar xllx1 avatar mananthecoder avatar anubh-v avatar tysg avatar angelsl avatar meowzz95 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.