In attribute grammars, you have variables attached to the symbols in
the parse-tree which can take values. Equations attached to the rules
specify how these values are propagated through the tree.
For that purpose, different occurences of a non-terminal in the same
rule are distinguished by subscripts, so as to distinguish the
variables attached to them.
For example the rule $S_0 \to S_1 b$ is used in the derivation of the
topmost $S$ in the tree. In this occurrence: $S_0$ stands for the
topmost $S$, while $S_1$ stands for the $S$ just below. So if the
second $S$ has a $count$ variable equal to $-2$, then by applying the
attribute equation $S_0.count=S_1.count+1$, the top $S$ get a count
variable equal to $-1$.
Note that the equations are often interpreted as assignments, at least
in attribute systems used in compilers. That is what was just done.
But there are uses in which it can be seen as unification of logical
variables (but you probably have not seen that).
Here the attribute rules are used as assignments, that are computed
bottom-up (Synthesized attributes), this is why the variable of the topmost symbol (i.e. with the index 0, left-hand side of the grammar rule) are on the left side of the assignment, and get assigned a value depending on the variables of the symbols corresponding to the right-hand side of the grammar rule. But attribute values can also
propagate top-down sometimes and are then called inherited attributes.
Synthesized attributes are more frequent, as they are computationally
more powerful (but it may come at a price).
The parse tree for aab is
V
|
S
/ \
S b
/ \
S a
/ \
S a
|
ϵ
We associate three attributes to non-terminals:
count: contains the number of $b$ minus the number of $a$ for the terminal
string that non-terminal occurrence derives in.
ok: is a boolean variable that is true for an occurrence of a non-terminal $S$ iff
the terminal string this non-terminal occurrence derives in has no prefix with
more $a$ than $b$. It is true for the non-terminal $V$ iff the
terminal string $V$ derives in is acceptable.
endb: is a boolean variable that is true for an occurrence of a non-terminal $S$ iff
the terminal string this non-terminal occurrence derives in terminates with a $b$.
Now you have attribute computation associated to rules as follow:
\begin{array}{llll}
\text{Grammar}& \text{Attributes computation}\\
V \to S& V.ok=S.ok\vee S.endb \\
S_0 \to S_1 a\;\;& S_0.count=S_1.count-1& S_0.ok=S_1.ok\wedge S_1.count>0& S_0.endb=false \\
S_0 \to S_1 b& S_0.count=S_1.count+1& S_0.ok=S_1.ok& S_0.endb=true \\
S \to \epsilon& S.count=0& S.ok=true
\end{array}