You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Small changes to document some of the complexity.
This commit is contained in:
@@ -175,6 +175,7 @@ class Python26Parser(Python2Parser):
|
|||||||
iflaststmt ::= testexpr_then c_stmts_opt JUMP_ABSOLUTE come_froms POP_TOP
|
iflaststmt ::= testexpr_then c_stmts_opt JUMP_ABSOLUTE come_froms POP_TOP
|
||||||
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_froms POP_TOP
|
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_froms POP_TOP
|
||||||
|
|
||||||
|
# "if"/"else" statement that ends in a RETURN
|
||||||
ifelsestmtr ::= testexpr_then return_if_stmts returns
|
ifelsestmtr ::= testexpr_then return_if_stmts returns
|
||||||
|
|
||||||
testexpr_then ::= testtrue_then
|
testexpr_then ::= testtrue_then
|
||||||
|
@@ -180,6 +180,8 @@ class Python27Parser(Python2Parser):
|
|||||||
ifelsestmtc ::= testexpr c_stmts_opt JUMP_ABSOLUTE else_suitec
|
ifelsestmtc ::= testexpr c_stmts_opt JUMP_ABSOLUTE else_suitec
|
||||||
ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel
|
ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel
|
||||||
ifelsestmtl ::= testexpr c_stmts_opt CONTINUE else_suitel
|
ifelsestmtl ::= testexpr c_stmts_opt CONTINUE else_suitel
|
||||||
|
|
||||||
|
# "if"/"else" statement that ends in a RETURN
|
||||||
ifelsestmtr ::= testexpr return_if_stmts COME_FROM returns
|
ifelsestmtr ::= testexpr return_if_stmts COME_FROM returns
|
||||||
|
|
||||||
# Common with 2.6
|
# Common with 2.6
|
||||||
|
@@ -177,6 +177,7 @@ class Python3Parser(PythonParser):
|
|||||||
ifelsestmtc ::= testexpr c_stmts_opt JUMP_ABSOLUTE else_suitec
|
ifelsestmtc ::= testexpr c_stmts_opt JUMP_ABSOLUTE else_suitec
|
||||||
ifelsestmtc ::= testexpr c_stmts_opt jump_absolute_else else_suitec
|
ifelsestmtc ::= testexpr c_stmts_opt jump_absolute_else else_suitec
|
||||||
|
|
||||||
|
# "if"/"else" statement that ends in a RETURN
|
||||||
ifelsestmtr ::= testexpr return_if_stmts returns
|
ifelsestmtr ::= testexpr return_if_stmts returns
|
||||||
|
|
||||||
ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel
|
ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel
|
||||||
|
@@ -350,11 +350,17 @@ TABLE_DIRECT = {
|
|||||||
'testtrue': ( 'not %p',
|
'testtrue': ( 'not %p',
|
||||||
(0, PRECEDENCE['unary_not']) ),
|
(0, PRECEDENCE['unary_not']) ),
|
||||||
|
|
||||||
|
# Generally the args here are 0: (some sort of) "testexpr",
|
||||||
|
# 1: (some sort of) "cstmts_opt",
|
||||||
|
# 2 or 3: "else_suite"
|
||||||
|
# But unfortunately there are irregularities, For example, 2.6- uses "testexpr_then"
|
||||||
|
# and sometimes "cstmts" instead of "cstmts_opt" happens.
|
||||||
|
# Down the line we might isolate these into version-specific rules.
|
||||||
'ifelsestmt': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, 3 ),
|
'ifelsestmt': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, 3 ),
|
||||||
'ifelsestmtc': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, 3 ),
|
'ifelsestmtc': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, 3 ),
|
||||||
'ifelsestmtl': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, 3 ),
|
'ifelsestmtl': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, 3 ),
|
||||||
'ifelsestmtr': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, 2 ),
|
'ifelsestmtr': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, 2 ),
|
||||||
'ifelsestmtr2': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-\n\n', 0, 1, 3 ), # has COME_FROM
|
'ifelsestmtr2': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-\n\n', 0, 1, 3 ), # has COME_FROM in position 2
|
||||||
|
|
||||||
|
|
||||||
# "elif" forms are not generated by the parser but are created through tree
|
# "elif" forms are not generated by the parser but are created through tree
|
||||||
@@ -364,7 +370,7 @@ TABLE_DIRECT = {
|
|||||||
'elifstmt': ( '%|elif %c:\n%+%c%-', 0, 1 ),
|
'elifstmt': ( '%|elif %c:\n%+%c%-', 0, 1 ),
|
||||||
'elifelsestmt': ( '%|elif %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, 3 ),
|
'elifelsestmt': ( '%|elif %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, 3 ),
|
||||||
'elifelsestmtr': ( '%|elif %c:\n%+%c%-%|else:\n%+%c%-\n\n', 0, 1, 2 ),
|
'elifelsestmtr': ( '%|elif %c:\n%+%c%-%|else:\n%+%c%-\n\n', 0, 1, 2 ),
|
||||||
'elifelsestmtr2': ( '%|elif %c:\n%+%c%-%|else:\n%+%c%-\n\n', 0, 1, 3 ), # has COME_FROM
|
'elifelsestmtr2': ( '%|elif %c:\n%+%c%-%|else:\n%+%c%-\n\n', 0, 1, 3 ), # has COME_FROM in position 2
|
||||||
|
|
||||||
'whileTruestmt': ( '%|while True:\n%+%c%-\n\n', 1 ),
|
'whileTruestmt': ( '%|while True:\n%+%c%-\n\n', 1 ),
|
||||||
'whilestmt': ( '%|while %c:\n%+%c%-\n\n', 1, 2 ),
|
'whilestmt': ( '%|while %c:\n%+%c%-\n\n', 1, 2 ),
|
||||||
|
Reference in New Issue
Block a user