/lo-lang

LO - small programming language targeting WASM that aims to be as simple as possible

Primary LanguageRustMIT LicenseMIT

LO - small programming language targeting WASM that aims to be as simple as possible

๐Ÿ† Goals

  • Make both the language and the compiler small and easy to understand
  • Have little to no dependencies
  • Be easy to use and modify
  • Emit WASM to have the biggest target coverage with little code

๐Ÿชต Development Log

๐Ÿงพ Parts [0..6] - Building the initial compiler. (text based blog)

๐Ÿ“บ Parts [7..] - Building the self-hosted compiler. (YouTube playlist)

๐Ÿ‘€ Overview

Check out example .lo programs including standard library sources and WIP self-hosted compiler in the ./examples folder.

Here are some of them with syntax highlighting from the LO VS Code extension:

Hello World sample

AOC 2020 sample

Dark Maze gif

๐Ÿš€ Getting started

Option 1 (recommended): Using VS Code extension only

This option also works in vscode.dev

  • Install the LO VS Code extension
  • To create a new project: Open empty folder, execute Command Palette: LO: Initialize project in current workspace
  • To run currently open file: execute Command Palette: LO: Run current file, or press โ–ถ๏ธ button in the top toolbar
  • Compiling files:
    • Open Web Shell: execute Command Palette: Terminal: Create New Web Shell
    • Run: run lo.wasm <input>.lo > <output>.wasm

Option 2: Using wasmtime

  • Install wasmtime
  • Compiling files: wasmtime --dir=. lo.wasm <input>.lo > <output>.wasm
  • Getting diagnostics (in json format): wasmtime --dir=. lo.wasm <input>.lo --inspect

Option 3: Using Node.js

  • Install Node.js
  • Compiling files: ./utils.mjs compile <input>.lo > <output>.wasm
  • Compiling & running files: ./utils.mjs run <input>.lo

๐Ÿฆ€ Building the initial compiler

  • Requirements:

    • Install rustup
    • Install nightly: rustup toolchain install nightly
    • Add WASM target: rustup +nightly target add wasm32-unknown-unknown
    • You can also find configs for GitHub Codespaces and GitPod in this repo
  • Run ./build.sh

    This will build the compiler with cargo, putting resulting WASM binary into lo.wasm

๐Ÿงช Running tests

  • Requirements:

    • Install Node.js for running tests
  • Run ./utils.mjs test

    This runs tests defined in utils.mjs. Test programs are located in examples/test