Source is a subset of JavaScript (EcmaScript 5) used to teach freshman introduction to programming course CS1101S.
This repository contains a toolchain (parser, analyzer, interpreter) for Source language and a playground website for the toolchain.
The toolchain has three main components.
-
Parser
The language grammar evolves as the course progress. New language constructs are added to reflect the material taught in the course.
To implement this, we first parse the source using existing ES5 parser (acorn) and traverse the AST to filter out any features that students aren't supposed to be using yet.
-
Static Analysis
Provide syntax analysis to catch common mistakes: invalid types, missing return statement, etc. The static analyis comprises of generating Control Flow Graph and applying type analysis and data flow analysis.
-
Interpreter
An small-step interpreter for the language that evaluates the program step-by-step. There is also an expression visualizer that tracks evaluation progress of an expression according to substitution model. Interop with native javascript is also supported via FFI (foreign function interface).
You will need Node >=6 and NPM >=3. Yarn is recommended.
npm install source-toolchain --save
# Or if you have Yarn
yarn add source-toolchain --save
Install dependencies (do for current directory and playground)
npm install
# Or if you have Yarn
yarn
Run the task that you need
# Toolchain: Run Jest in watch mode
# Playground: Run Next.js development
npm run dev
# Toolchain: Compile to ES6 then ES5
npm run compile
To deploy the playground using now.sh
# Make sure you compile the toolchain
npm run compile
# Deploy it
cd playground && npm run deploy
MIT