Skip to content

MarcManiez/lox-wat-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WAT compiler

Web assembly text format is an easier way for humans to write web assembly than raw binary instructions.

This repo contains two things:

This is the first compiler I've writen, and WAT seemed appropriately challenging, but also convenient because the output is easier to grasp. Working from an implementation of Lox that I was familiar with was a nice boost too!

Playing with lox

  • Install Maven
  • You can then play with lox in an REPL using ./jlox from the root folder
  • To run lox from a file, run ./jlox [filename]

Compiling to WAT

To compile the contents, and see the output of the wat file in your console:

  • Install the Web Assembly Binary Toolkit, following these instructions
  • Add the newly created build folder to your path for convenience (and for my scripts to work!)
  • Write some lox inside of test.lox. My compiler only supports a subset of the language: strings, the + operator, numbers, and print statements!
  • use the command ./runLoxAsWasm from this project's root folder
  • view the output in output.wat, and in the console (if you've decided to print anything)

About

A fledgling web assembly compiler for the lox language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published