This project aims to create a simple TypeScript compiler. The goal is to understand the fundamental components of a compiler by implementing a lexer, parser, and type checker from scratch. The project will also include a code generator to produce executable code from the parsed and type-checked source.
Though some progress has been merged into the main branch, The project is currently under active development. You can check the progress on the following branch:
Please note that the main branch is not being updated at this time. All development work is happening in the feature branches mentioned above.
- Lexer: Tokenizes the input TypeScript code into a stream of tokens.
- Parser: Parses the token stream into an Abstract Syntax Tree (AST).
- Type Checker: Ensures the type correctness of the AST.
- Code Generator: Generates executable code from the AST.
- Node.js
- TypeScript
-
Clone the repository:
git clone https://github.com/amarbego/tsmorph.git cd simple-ts-compiler
-
Install dependencies:
npm install
-
To build the project:
npm run build
-
To run tests:
npm test
src/lexer.ts
: Contains the lexer implementation.src/parser.ts
: Contains the parser implementation.src/typeChecker.ts
: Contains the type checker implementation.src/codeGenerator.ts
: Contains the code generator implementation.test/
: Contains unit tests for the various components.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.