Home

rightassociative

Right-associative describes a property of binary operators in formal grammars, programming languages, and mathematics where an expression with multiple occurrences of the operator groups to the right. Specifically, a op b op c is interpreted as a op (b op c) rather than (a op b) op c. This contrasts with left-associative, where grouping is to the left.

Exponentiation is a classic right-associative operator in both mathematics and many programming languages. For example, 2^3^2

Assignments are often right-associative: in languages like C, C++, Java, JavaScript, and Python, a = b = c

In parsing, associativity affects the structure of the parse tree and the order of evaluation, but parentheses

Right associativity is one of several conventions used to define how expressions are evaluated.

is
interpreted
as
2^(3^2)
=
512,
not
(2^3)^2
=
64.
Some
languages
implement
exponentiation
with
a
right-associative
operator
token,
such
as
Python's
**
and
most
mathematical
conventions.
assigns
c
to
b,
then
the
result
to
a,
effectively
a
=
(b
=
c).
This
property
allows
chained
assignments
to
be
written
concisely.
can
override
default
associativity.
For
example,
(2^3)^2
forces
left
grouping,
yielding
64,
whereas
2^3^2
yields
512
by
default
right
associativity.