A lightweight transpiler that converts Python code into equivalent JavaScript code. This project demonstrates concepts of parsing, code translation, and compiler design by transforming Python syntax into executable JavaScript.
The Python to JavaScript Transpiler takes Python source code as input, analyzes its structure, and generates corresponding JavaScript code. The project aims to bridge the gap between two popular programming languages while providing insight into how compilers and transpilers work.
- Convert basic Python syntax to JavaScript
- Variable assignment translation
- Print statement conversion
- Conditional statement support
- Loop conversion
- Function translation
- Simple and easy-to-understand architecture
- Extensible for additional Python features
- Python
- JavaScript
- Parsing Techniques
- Compiler Design Concepts
name = "Gaatha"
print("Hello", name)
for i in range(5):
print(i)let name = "Gaatha";
console.log("Hello", name);
for(let i = 0; i < 5; i++) {
console.log(i);
}python-to-js-transpiler/
│
├── src/
├── examples/
├── tests/
├── docs/
├── README.md
- Read Python source code.
- Tokenize and parse the input.
- Generate an intermediate representation.
- Translate Python constructs into JavaScript equivalents.
- Output executable JavaScript code.
- Support for classes and objects
- Advanced function handling
- Error reporting and diagnostics
- Support for Python libraries
- Web-based transpiler interface
- AST visualization
This project explores:
- Compiler Design
- Parsing and Tokenization
- Abstract Syntax Trees (AST)
- Language Translation
- Code Generation
Gaatha Patel