A custom-designed programming language built from the ground up, featuring a complete compiler pipeline comprising lexical analysis, syntax parsing, Abstract Syntax Tree (AST) generation, semantic evaluation, and JavaScript code generation.
NovaScript is an educational compiler engineering project that explores the complete lifecycle of a programming language—from raw source code to executable JavaScript. The project implements every fundamental stage of a modern compiler, including lexical analysis, parsing, AST construction, interpretation, and code generation.
Rather than relying on existing compiler frameworks, each phase was developed independently to provide a deeper understanding of language design, parsing techniques, runtime execution, and compiler architecture.
- 📝 Custom programming language syntax
- 🔍 Handcrafted lexical analyzer (Lexer)
- 🌳 Recursive parser with Abstract Syntax Tree (AST) generation
- ⚡ Runtime interpreter for immediate code execution
- 🔄 JavaScript code generation pipeline
- 📚 Variable declarations and scope management
- ➕ Expression parsing and evaluation
- 🛡️ Comprehensive syntax validation and error reporting
- 🧩 Modular compiler architecture with clearly separated compilation stages
NovaScript follows a traditional compiler pipeline where each stage is responsible for transforming the source program into a more structured representation before execution.
Source Code
│
▼
Lexical Analysis (Lexer)
│
▼
Token Stream
│
▼
Syntax Analysis (Parser)
│
▼
Abstract Syntax Tree (AST)
│
├──────────────► Interpreter
│ │
│ ▼
│ Runtime Execution
│
▼
JavaScript Code Generator
│
▼
Executable JavaScript
The lexical analyzer scans raw source code and transforms it into a structured stream of tokens while eliminating irrelevant whitespace and recognizing language constructs such as:
- Identifiers
- Keywords
- Numeric literals
- Operators
- Delimiters
- Parentheses and punctuation
- Assignment expressions
This tokenization phase establishes the foundation for accurate syntax analysis.
The parser processes the token stream according to the language grammar and constructs an Abstract Syntax Tree (AST) representing the hierarchical structure of the program.
The AST serves as the intermediate representation for both interpretation and code generation, enabling:
- Expression parsing
- Operator precedence handling
- Nested statement evaluation
- Variable declarations
- Program structure validation
The interpreter traverses the generated AST to execute programs directly without requiring prior compilation.
Supported runtime capabilities include:
- Variable declaration and initialization
- Arithmetic and logical expression evaluation
- Runtime execution of statements
- Environment and symbol resolution
- Sequential program execution
This execution model demonstrates the implementation of core interpreter concepts used in modern scripting languages.
Beyond interpretation, NovaScript includes a complete code generation phase that transforms the AST into executable JavaScript.
The generated output preserves the logical semantics of the original program while demonstrating concepts such as:
- AST traversal
- Intermediate representation transformation
- Source-to-source compilation
- Language transpilation techniques
The compiler incorporates validation mechanisms throughout multiple compilation stages to detect and report errors early.
- Invalid characters
- Unknown tokens
- Malformed literals
- Unexpected tokens
- Missing delimiters
- Invalid grammar structures
- Parsing failures
- Undefined variables
- Invalid expression evaluation
- Execution consistency
- Designed and implemented a complete compiler pipeline entirely in JavaScript.
- Built a custom lexer for efficient tokenization of source code.
- Developed a recursive-descent parser capable of generating structured Abstract Syntax Trees (ASTs).
- Implemented an interpreter supporting runtime execution, variable management, and expression evaluation.
- Created a source-to-source compiler that transpiles NovaScript into executable JavaScript.
- Applied compiler design principles including lexical analysis, parsing, AST traversal, semantic evaluation, and code generation.
- Structured the project with modular compiler stages to maximize maintainability, extensibility, and readability.
| Category | Technologies |
|---|---|
| Programming Language | JavaScript |
| Compiler Components | Lexer, Parser, AST, Interpreter |
| Core Concepts | Compiler Design, Language Processing, Parsing Algorithms |
| Code Generation | JavaScript Transpilation |
| Version Control | Git & GitHub |
NovaScript demonstrates a practical understanding of compiler engineering through the implementation of every major compilation stage, combining theoretical computer science concepts with real-world software engineering practices.
Key concepts explored include:
- Programming language design
- Lexical analysis
- Recursive-descent parsing
- Abstract Syntax Tree construction
- Interpreter implementation
- Source-to-source compilation
- Compiler pipeline architecture
- Runtime environment management
- Algorithmic problem solving
- Modular software design