Skip to content

gaathapatel07/Py2JS-Transpiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Python to JavaScript Transpiler

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.

Overview

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.

Features

  • 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

Technologies Used

  • Python
  • JavaScript
  • Parsing Techniques
  • Compiler Design Concepts

Example

Python Input

name = "Gaatha"
print("Hello", name)

for i in range(5):
    print(i)

JavaScript Output

let name = "Gaatha";
console.log("Hello", name);

for(let i = 0; i < 5; i++) {
    console.log(i);
}

Project Structure

python-to-js-transpiler/
│
├── src/
├── examples/
├── tests/
├── docs/
├── README.md

How It Works

  1. Read Python source code.
  2. Tokenize and parse the input.
  3. Generate an intermediate representation.
  4. Translate Python constructs into JavaScript equivalents.
  5. Output executable JavaScript code.

Future Enhancements

  • Support for classes and objects
  • Advanced function handling
  • Error reporting and diagnostics
  • Support for Python libraries
  • Web-based transpiler interface
  • AST visualization

Learning Outcomes

This project explores:

  • Compiler Design
  • Parsing and Tokenization
  • Abstract Syntax Trees (AST)
  • Language Translation
  • Code Generation

Author

Gaatha Patel

About

Py2JS Transpiler is a Python-to-JavaScript transpiler that converts Python source code into equivalent JavaScript code. It parses Python syntax, maps language constructs, and generates readable JavaScript output automatically. Built to explore compiler design concepts, code translation techniques, and cross-language execution workflows.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages