Furkanzmc / cpplox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lox++

C++ implementation of Lox language from craftinginterpreters.

Grammar

program        → declaration* EOF ;
declaration    → varDecl | statement ;
varDecl        → "var" IDENTIFIER ( "=" expression )? ";" ;
statement      → expressionStmt | printStmt ;
expressionStmt → ternary ";";
printStmt      → "print" ternary ";";
ternary        → expression | (ternary)* "?" expression | (ternary)* ":" expression | (ternary)* | primary
expression     → assignment ;
assignment     → IDENTIFIER "=" assignment
               | equality ;
equality       → comparison ( ( "!=" | "==" ) comparison )* ;
comparison     → term ( ( ">" | ">=" | "<" | "<=" ) term )* ;
term           → factor ( ( "-" | "+" ) factor )* ;
factor         → unary ( ( "/" | "*" ) unary )* ;
unary          → ( "!" | "-" ) unary
               | primary ;
primary        → NUMBER | STRING | "true" | "false" | "nil"
               | "(" expression ")" | IDENTIFIER ;

About


Languages

Language:C++ 90.5%Language:CMake 4.1%Language:Python 3.1%Language:Lua 2.3%