python compiler to c++
# Note: The last time I tested something was missing so I couldn't work
import pathlib
import transpyle
path = pathlib.Path('my_script.py')
code_reader = transpyle.CodeReader()
code = code_reader.read_file(path)
from_language = transpyle.Language.find('Python 3.6')
to_language = transpyle.Language.find('Fortran 95')
translator = transpyle.AutoTranslator(from_language, to_language)
fortran_code = translator.translate(code, path)
print(fortran_code)
class Node:
def __init__(self, char, desc, parent):
self.char = char
self.desc = desc
self.parent = parent
self.children = dict()
if(not self.parent is None):
self.parent.children[char] = self
home = Node('H','Home',None)
men = Node('M','Men',home)
women = Node('W','Women',home)
electronics = Node('E','Electronics',home)
mclothing = Node('C','Clothing',men)
maccessories = Node('A','Accessories',men)
mfootwear = Node('F','Footwear',men)
wclothing = Node('C','Clothing',women)
waccessories = Node('A','Accessories',women)
wfootwear = Node('F','Footwear',women)
computers = Node('C','Computers',electronics)
mobiles = Node('M','Mobiles',electronics)
mjeans = Node('J',"Jeans",mclothing)
mtrousers = Node('T',"Trousers",mclothing)
mshirts = Node('S',"Shirts",mclothing)
wjeans = Node('J',"Jeans",wclothing)
wtrousers = Node('T',"Trousers",wclothing)
wshirts = Node('S',"Shirts",wclothing)
#LIKE-WISE FILL REST
root = home
p_list = [home]
print(home.desc)
while(True):
try:
ch=input()
if(ch==":"):
break
if(ch[:2]=="MB"):
back_count = int(ch.split()[-1])
p_list = p_list[:-back_count]
elif(ch[:4]=="GOTO"):
front_count = int(ch.split()[-1])
p_list = p_list[:front_count]
else:
p_list.append(root.children[ch])
root = p_list[-1]
print(" > ".join([node.desc for node in p_list]))
except Exception as e:
print("Invalid Option")
This paste expires in <8 hours. Public IP access. Share whatever you see with others in seconds with Context.Terms of ServiceReport this