I am confused between Syntax Directed Translation and parser written using Bison. (The main confusion is whether parser written in Bison already consists of syntax directed translator.)I rephrase the above sentence in parenthesis as (How does Bison implement Syntax Directed Translation, is it by attaching for E.g. $$ = $1 + $3)
This link says that
The C code in an action can refer to the semantic values of the components matched by the rule with the construct $n, which stands for the value of the nth component. The semantic value for the grouping being constructed is $$. (Bison translates both of these constructs into array element references when it copies the actions into the parser file.)
And also in chapter 5 (Syntax Directed Analysis) of the book says
Grammar + Semantic rules = Syntax Directed Translation
PRODUCTION SEMANTIC RULE
→1 + {. = 1. ┤| . |′+′}
When looking at the following snippet of translation rules for a simple parser from the book Flex and Bison
%%
E: F default $$ = $1
| E ADD F { $$ = $1 + $3; }
| E SUB F { $$ = $1 - $3; }
;
%%
Is the .code
equavelent to $$
I am so confused. Is syntax directed analysis the same as semantic analysis? The more I read more I get confused. Someone please help me sort this out.