conditional -> if_exp ...

to match Python IfExp AST
This commit is contained in:
rocky
2020-02-07 16:17:47 -05:00
parent 7fb50918cd
commit 278af38df6
19 changed files with 98 additions and 103 deletions

View File

@@ -56,11 +56,11 @@ PRECEDENCE = {
'_mklambda': 30,
'conditional': 28, # Conditional expression
'conditional_lamdba': 28, # Lambda expression
'conditional_not_lamdba': 28, # Lambda expression
'conditionalnot': 28,
'if_expr_true': 28,
'if_exp': 28, # If_Exp expression
'if_exp_lamdba': 28, # Lambda expression
'if_exp_not_lamdba': 28, # Lambda expression
'if_exp_not': 28,
'if_exp_true': 28,
'ret_cond': 28,
'or': 26, # Boolean OR
@@ -301,24 +301,24 @@ TABLE_DIRECT = {
# which we don't use here.
'aug_assign1': ( '%|%c %c %c\n', 0, 2, 1),
'aug_assign2': ( '%|%c.%[2]{pattr} %c %c\n', 0, -3, -4 ),
'designList': ( '%c = %c', 0, -1 ),
'aug_assign2': ( '%|%c.%[2]{pattr} %c %c\n', 0, -3, -4 ),
'designList': ( '%c = %c', 0, -1 ),
'and': ( '%c and %c', 0, 2 ),
'ret_and': ( '%c and %c', 0, 2 ),
'and2': ( '%c', 3 ),
'or': ( '%c or %c', 0, 2 ),
'ret_or': ( '%c or %c', 0, 2 ),
'conditional': ( '%p if %c else %c',
'if_exp': ( '%p if %c else %c',
(2, 'expr', 27), 0, 4 ),
'if_expr_lambda': ( '%p if %c else %c',
'if_exp_lambda': ( '%p if %c else %c',
(2, 'expr', 27), (0, 'expr'), 4 ),
'if_expr_true': ( '%p if 1 else %c', (0, 'expr', 27), 2 ),
'if_exp_true': ( '%p if 1 else %c', (0, 'expr', 27), 2 ),
'ret_cond': ( '%p if %p else %p', (2, 27), (0, 27), (-1, 27) ),
'conditional_not': ( '%p if not %p else %p',
'if_exp_not': ( '%p if not %p else %p',
(2, 27),
(0, "expr", PRECEDENCE['unary_not']),
(4, 27) ),
'conditional_not_lambda':
'if_exp_not_lambda':
( '%p if not %c else %c',
(2, 'expr', 27), 0, 4 ),