Skip to content

Script to create a Polyglot file between Python and JS using Python

License

Notifications You must be signed in to change notification settings

nnnGi/Pyolycompiler-pyjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pyolycompiler (Python & Javascript)

Python Version
This PolyCompiler is inspired by https://github.com/evanzhoudev/polycompiler written in Node JS. This project is written in Python, and ultimately, the polyglot method used here is double comment parasite polyglot, unlike the original, which used a combination of various methods.

Installation and Use:

1) Install Python 3.13.2 -> Python3
2) Download Script

Usage

polycompile in.py in.js out.poly


This Project will take in a Python (.py) and Javascript (.js) file and output a .poly file which can be run in both languages using

node {file name}.poly and python3 {file name}.poly respectively.

Installation Requirements:

- Node JS
- Python 3

How PyolyCompiler works

PyolyCompiler uses a parasite method both ways to let syntactically correct files in both languages run in both. The script used for the parasite is

1 // 1; """
/*"""
#*/ {jscontent in one line} /*
{pycontent in multiple lines}
#*/

Syntax Highlighting

1 // 1; """
/*"""
#*/ console.log("Hello JS"); if (1 == 1) { console.log('1 == 1'); } /*
print("Hello Python")

a = input('Hello: ')

if (1 == 1):
    print(f'1 == 1 and a == {a}')
#*/
1 // 1; """
/*"""
#*/ console.log("Hello JS"); if (1 == 1) { console.log('1 == 1'); } /*
print("Hello Python")

a = input('Hello: ')

if (1 == 1):
    print(f'1 == 1 and a == {a}')
#*/

© Copyright @nnnGi (_nnn_) 2025 - 2025