MoozonWei / tiny-compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tiny Compiler

Learn the-super-tiny-compiler.

  • tokenizer
  • parser
  • traverser
  • transformer
  • codegen
  • compiler

Test it out

Installation

npm install @moozon/tiny-compiler

Compiler

import { compiler } from '@moozon/tiny-compiler'

console.log(
  /** 
   * should output:
   * "add(2, subtract(4, 2));"
   */
  compiler('(add 2 (subtract 4 2))')
)

console.log(
  /** 
   * should output:
   * "add(2, subtract(4, 2));
   * add(2, subtract(4, 2));"
   */
  compiler('(add 2 (subtract 4 2))(add 2 (subtract 4 2))')
)

Other APIs

import {
  codegen,
  parser,
  tokenizer,
  transformer,
  traverser,
} from '@moozon/tiny-compiler'

// checkout test files
// ...

About

License:MIT License


Languages

Language:TypeScript 98.7%Language:JavaScript 1.3%