-
Notifications
You must be signed in to change notification settings - Fork 5
Workflow description
dours edited this page Jul 6, 2022
·
1 revision
Workflow:
- The main function parses the command line arguments and (if an existing input file was provided) reads the file
- The parser module uses the ANTLR parser to build an abstract syntax tree and then maps its tree to our own internal representation (also based on AST).
- The SimplePass module applies several python-to-python passes to eliminate some constructions which are not supported in eolang. These include:
- Eliminate
if-else
statements with > 2 branches (rewrite an if-elsif-else as many if-else statements) - Eliminate
for
: rewrite it as awhile
+try
- Prepend each identifier with
x
, so that no identifier starts with a capital letter - Standardize (simplify) quotes for string literals
- Simplify
except
clauses for exception handling: change multipleexcept
clauses of atry
block to oneexcept:
, which catches everything, and a series ofif-else
, which emulates the behaviour of all the typedexcept
clauses and reraises the exception if it should not be caught - Eliminate
if-else
again (because complex if-else statements appear as a result of the previous pass) - Eliminate complex assignments (i.e., translate
a = b = c
tob = c; a = b
) - Eliminate simple cases of method calls (that is, substitute pointer to
this
explicitly) - Extract all function calls to the statement level to make the execution order explicit (i.e., translate
a = f(1) + g(2)
totmp1 = f(1); tmp2 = g(2); a = tmp1 + tmp2
- Eliminate
- The resulting simplified AST is then translated to the eolang code.