How ayush-that/small-compiler works
Project type and purpose
• This is a small compiler (language-to-language translator) whose purpose is to read a Lisp‐style function call string, parse it into an AST, transform that AST to match JavaScript call‐syntax, and emit JavaScript code.
• The README confirms it: input is something like (add 2 (subtract 4 2)) and the output is add(2, subtract(4, 2));.
File structure
• Top‐level files correspond to each compilation stage:
• tokenizer.js – splits source text into tokens
• parser.js – builds an initial Abstract Syntax Tree (AST) from tokens
• traverser.js – walks the AST (visitor pattern)
• transformer.js – converts the original Lisp AST to a JavaScript‐style AST
• codeGenerator.js – emits final JavaScript code from the transformed AST
• compiler.js – likely ties these modules together into a single compile() function
• main.js – CLI or script entry point that reads input, invokes compiler.js, writes output
• package.json + package-lock.json: Node.js project
• No external services, databases, or frontend–backend separation—everything is local and sequential.
README for additional insights
• The project follows a classic compiler pipeline (tokenize → parse → transform → codegen).
Detailed checklist
• Title: “Small Lisp‐to‐JS Compiler Architecture”
• Module name
• Source filename
• Brief description (e.g., “tokenizer.js – splits input into tokens”)
• Entry point (main.js) at the far left, output sink at the far right.
• License and runtime environment in a side note.