Skip to content

ChengranAA/toy_lox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Toy Interpreter for Lox

In this project, I use python to create a Lox interpreter (which is super useless, but educational).

Roadmap

  • Scanning
  • Parser
    • Expression
    • Statement
    • Control/Loop
      • Break/Continue
    • Function
    • Class

I will stop for now. Now, it is a semi-working interpreter (at least it will parse and interpret).

Why bother?

Learning how to build a interpreter is a valuable experience. There are a lot of theories behind the process (Linguistic, TCS, Engineering).

Why python?

The short answer is Python Rules! Well, I can build something like this in C++ also if I really want to torture myself, I can build the interpreter in C or even in Assembly. But that would require me to spend the majority of the time dealing with language limitations rather than the mechenism of interpretor itself.

Lox

All the file is located in one file to avoid circular import error in python. It's not that long, which shows building an interpreter is super easy to do. The whole project follow the book "Crafting Intepreters". In fact, this can be consider a translation from the original JAVA implementation to Python.

How to run

python lox.py {script}
>> quit() // to exit

It requires python, yeah, it's stupid, but it is indeed an interpretor

About

An toy Interpreter for Lox in Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages