Add if1else. Fixes #101

This commit is contained in:
rocky
2017-04-13 21:27:22 -04:00
parent a9f7a3c6d0
commit 8cdaac93ab
5 changed files with 7 additions and 2 deletions

Binary file not shown.

View File

@@ -0,0 +1 @@
1 if 1 else __file__

View File

@@ -508,8 +508,12 @@ class PythonParser(GenericASTBuilder):
expr ::= conditional
conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM
conditional ::= expr jmp_false expr JUMP_ABSOLUTE expr
expr ::= conditionalnot
conditionalnot ::= expr jmp_true expr _jump expr COME_FROM
conditionalnot ::= expr jmp_true expr _jump expr COME_FROM
expr ::= conditionalTrue
conditionalTrue ::= expr JUMP_FORWARD expr COME_FROM
ret_expr ::= expr
ret_expr ::= ret_and

View File

@@ -409,7 +409,6 @@ class Python3Parser(PythonParser):
conditional ::= expr jmp_false expr jf_else expr COME_FROM
conditionalnot ::= expr jmp_true expr jf_else expr COME_FROM
expr ::= LOAD_CLASSNAME
# Python 3.4+

View File

@@ -170,6 +170,7 @@ TABLE_DIRECT = {
'or': ( '%c or %c', 0, 2 ),
'ret_or': ( '%c or %c', 0, 2 ),
'conditional': ( '%p if %p else %p', (2, 27), (0, 27), (4, 27)),
'conditionalTrue': ( '%p if 1 else %p', (0, 27), (2, 27)),
'ret_cond': ( '%p if %p else %p', (2, 27), (0, 27), (-1, 27)),
'conditionalnot': ( '%p if not %p else %p', (2, 27), (0, 22), (4, 27)),
'ret_cond_not': ( '%p if not %p else %p', (2, 27), (0, 22), (-1, 27)),