Giter VIP home page Giter VIP logo

pylox's Introduction

pylox

Pylox is a Lox interpreter, implemented in Python, based on the book Crafting Interpreters by Bob Nystrom.

I am currently working through Chapter 9.

Also, I have implemented some of the chapter challenges so far, but not all. Eventually I want to 100% the Tree-Walk Interpreter section


Table of Contents

Demo

REPL

pylox demo

Verbose REPL

Useful for debugging

pylox demo verbose

Source files

pylox demo src

Installation

Pull from Github

Requires Python 3.10 or later

I use Hatch to manage the Python environment

Challenges

Ch 4. Scanning

  • Support for C-style block comments (NOT nestable)

Ch 5. Representing Code

  • AST print Reverse Polish Notation

Ch 6. Parsing Expressions

  • Comma Operator
  • Ternary Operator
  • Error productions for binary operators without left-hand side expression

Ch 7. Evaluating Expressions

  • [] define "+" so that if one operand is string, it coerces other operand to string I don't really like this behaviour with strings. Between floats and ints this is okay, but Lox anyways only has float type
  • handle zero division error

Ch 8. Statements and State

  • Evaulate expressions in REPL
  • Runtime error when accessing uninitialized variables

Ch 9. Control Flow

Architecture of pylox

cli: handles command line interface (cli) options, cli formatting, stdin/stdout.

utils: helper utilities; not particularly significant to the function of the app, but convenient.

engine: the core of the pylox interpreter

License

pylox is distributed under the terms of the MIT license.

pylox's People

Contributors

imakappa avatar

Stargazers

Alex Lemna avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.