Most languages go away from it by declaring assignment with an expression.
In your example, the assignment would be:
def p_expression_assign(t): 'expression : NAME EQUALS expression' t[0] = names[t[1]] = t[3]
I simply changed the “statement” to “expression” both in the function name and in the docstring syntax and “returned” (assigned t[0] ) the value that is assigned.
I say “leave with” because other languages (like Python) go the extra mile because they allow multiple assignments, but forbid the use of the assignment result in any other expression.
But your second example a=(b=1)*1 tells me that you need the first, weaker (or C-like) multiple-use form.
Tobia source share