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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

827eea8 · Oct 16, 2022

History

79 Commits
Sep 16, 2022
Oct 16, 2022
Sep 21, 2022
Oct 16, 2022
Oct 10, 2022
Oct 15, 2022
Oct 12, 2022
Oct 16, 2022
Oct 12, 2022
Oct 16, 2022
Oct 10, 2022
Oct 15, 2022
Oct 16, 2022

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