If used with parse tree, often try to compute attribute values while parsing. Sometimes, attributes are more important than parse tree itself. More complicated attribute equations may require whole tree to exist first, before attribute evaluation begins. Values at terminal nodes are provided by lexical analyzer. When parsing bottom-up, at time of a reduction all attribute values on RHS are known, so LHS can be computed.
Semantic stack is manipulated in parallel with parser stack.
When a terminal is shifted onto parser stack, its attributes are pushed onto semantic stack. After the reduction, top value is attribute for LHS non- terminal. E Note that parse stack and semantic stack always have equal depths. Stack yacc-generated parser automatically maintains a value stack in parallel with the parsing stack.