-
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-elsestatements 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
exceptclauses for exception handling: change multipleexceptclauses of atryblock to oneexcept:, which catches everything, and a series ofif-else, which emulates the behaviour of all the typedexceptclauses and reraises the exception if it should not be caught - Eliminate
if-elseagain (because complex if-else statements appear as a result of the previous pass) - Eliminate complex assignments (i.e., translate
a = b = ctob = c; a = b) - Eliminate simple cases of method calls (that is, substitute pointer to
thisexplicitly) - 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.