Giter Site home page Giter Site logo

jlox's Introduction

JLox

An implementation of the Lox programming language base on Robert Nystrom's book Crafting Interpreters in Java.

Chapters Completed

  • Chapter 1
  • Chapter 2
  • Chapter 3
  • Chapter 4
  • Chapter 5
  • Chapter 6
  • Chapter 7
  • Chapter 8
  • Chapter 9
  • Chapter 10
  • Chapter 11
  • Chapter 12
  • Chapter 13
  • Chapter 14
  • Chapter 15
  • Chapter 16
  • Chapter 17
  • Chapter 18
  • Chapter 19
  • Chapter 20
  • Chapter 21
  • Chapter 22
  • Chapter 23
  • Chapter 24
  • Chapter 25
  • Chapter 26
  • Chapter 27
  • Chapter 28
  • Chapter 29
  • Chapter 30

Grammar of Current Implementation

Expressions

expression  -> literal
             | unary
             | binary
             | grouping ;
             
literal     -> NUMBER | STRING | "true" | "false" | "nil" ;

grouping    -> "(" expression ")" ;

unary       -> ( "-" | "!" ) expression ;

binary      -> expression operator expression ;

operator    -> "==" | "!=" | "<" | "<=" | ">" | ">="
             | "+"  | "-"  | "*" | "/" ;

# For variable access
primary     -> "true" | "false | "nil" 
             | NUMBER | STRING
             | "(" expression ")"
             | IDENTIFIER ;

Statements

program         -> declaration* EOF ;

declaration     -> varDecl
                 | statement ;
                 
varDecl         -> "var" IDENTIFIER ( "=" expression )? ";" ;

statement       -> exprStmt
                 | printStmt
                 | block ;

block           -> "{" declaration* "}" ;
                 
exprStmt        -> expression ";" ;

printStmt       -> "print" expression ";" ;

Lexical Grammar

NUMBER          -> DIGIT+ ( "." DIGIT* )? ;
STRING          -> "\"" <any char except "\"">* "\"" ;
IDENTIFIER      -> ALPHA ( ALPHA | DIGIT )* ;
ALPHA           -> "a" ... "z" | "A" ... "Z" | "_" ;
DIGIT           -> "0" ... "9" ;

Challenges Implemented

  • 7.2 Implement implicit type conversion during string concatenation

jlox's People

Contributors

sunkit02 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.