Jikka-5.0.11.1: A transpiler from Python to C++ for competitive programming
Copyright(c) Kimiyuki Onaka 2021
LicenseApache License 2.0
Maintainerkimiyuki95@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Jikka.RestrictedPython.Convert.Alpha

Description

 
Synopsis

Documentation

run :: (MonadAlpha m, MonadError Error m) => Program -> m Program Source #

run renames variables. This assumes doesntHaveAssignmentToBuiltin.

  • This introduce a new name for each assignment if possible. For example, the following
x = 21
x += x
x = 42
x += x
for _ in range(100):
    x = x + 1
x = x + 1

turns the following

x0 = 21
x1 += x0
x2 = 42
x3 += x2
for a4 in range(100):
    x3 = x3 + 1
x5 = x3 + 1
for i in range(10):
    a = 0
return a  # error
  • This blames leaks of names from for-statements and if-statements at all. For example, the followings are not allowed.
if True:
    a = 0
else:
    b = 1
return a  # error
for i in range(10):
    a = 0
return a  # error