/ToyLang

A toy programming language built with TypeScript for learning purposes.

Primary LanguageTypeScriptMIT LicenseMIT

ToyLang logo

A toy programming language built with TypeScript for learning purposes.

Learning resources

Here are few excellent resources I followed while building ToyLang.

Examples

The syntax & semantics of the language is very similar to JavaScript with few differences.

To run examples from /examples folder, you simply need to run:

# yarn example <name_of_example>
yarn example factorial

API Usage

  1. Install toylang package
npm install toylang
  1. Use the package
const { Parser, Interpreter } = require("toylang");

const parser = new Parser();
const interpreter = new Interpreter();

const ast = parser.parse(`print(1+1);`);
interpreter.execute(ast);

Scope of the project

The scope of the project is only limited to educational purposes, the code itself is written for better understanding, rather than efficient or production use cases.

Todos

  • Write more tests.
  • Refactor ASTFactories.ts.
  • Refactor typings.
  • Add data structures (Arrays, Objects).
  • Add more examples.
  • Add support for imported modules.
  • Add support for Class declarations in interpreter.
  • More standard library functions.
  • Better error handling.
  • Overall refactor of the codebase.