Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
/ toy-js Public archive

A compile-to-js language written in itself with a formatter & type checker

Notifications You must be signed in to change notification settings

marcellerusu/toy-js

Repository files navigation

toy-js

A compile-to-js language written in itself

So far it has a semi-functional formatter and type checker is in progress

Some of the work has been done on youtube

The results are as of bootstrapping there were ~1500 lines of toy-js vs the ~2000 lines of javascript, meaning there's been a roughly 25% reduction in code size. This is mostly due to the dataclass syntax.

Progress

Bootstrapping [DONE]

  • can compile the lexer
  • can compile the parser
  • can compile the codegen

Formatting

  • can format the formatter
  • can format lexer
  • can format parser
  • can format codegen

Type Checker

  • basic functions
  • primitives (number, string)
  • builtins for console
  • basic let type inference
  • infer array type
  • lexer.lang
    • #scan
    • getters & instance var defs
  • ... more

Syntax

this snippet shows off some of the usable features so far

let ten = comptime! 5 + 5
def add(a, b)
  return undefined if !a || !b
  return a + b
end

print(ten)

dataclass Person(name, age)

let p = new Person("marcelle", 25)

# more, see the .lang source files for more

https://justforfunnoreally.dev/

About

A compile-to-js language written in itself with a formatter & type checker

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages