How peshala-prabhapoorna/jlox works
Project type and purpose
• This is a language‐interpreter/compiler‐style project (“jlox”) written in Java, implementing the Lox language from the Crafting Interpreters book.
• Its core purpose is to take Lox source code, run it through the standard compilation pipeline (scanning, parsing, semantic analysis/resolution) and then either interpret it directly or run it in a REPL.
File structure
• Top‐level:
• pom.xml – Maven build, dependency and packaging configuration
• jlox (executable wrapper/script)
• LICENSE, .gitignore, README.md
• src/tool/GenerateAst.java – code‐generation utility for AST classes (one‐time or build‐time tool).
• src/lox/ – contains all interpreter source code:
• Scanner.java – lexical analysis component
• Parser.java – syntax analysis, builds AST (Expr, Stmt hierarchies)
• AstPrinter.java – utility to pretty‐print the AST
• Resolver.java – semantic analysis (scope resolution, binding)
• Interpreter.java – evaluation of AST nodes (implements Visitor pattern)
• Environment.java – runtime storage for variable bindings and scopes
• Classes for runtime values: LoxFunction, LoxClass, LoxInstance, LoxCallable
• Token, TokenType, RuntimeError, Return, etc.
• Lox.java – entry point (sets up REPL or runs script file)
• test/ – folder of .lox files exercising language features (control flow, classes, functions, etc.)
README for additional insights
• Clarifies dependencies (JDK, Maven) and expected usage (REPL vs script mode).