How can you control associatively in a grammar a By avoiding
Solution
24.You can control associativity of grammar by altering whether production is left or right recursion.
26.Parser is one type of generator.
27.Given diagram is nothing but the flowchart diagram.The benfit of flowchar over BNF/EBNF is it is eacy to understand.And unambiguos grammar is detected quickly.
28.An attribute grammar is a formal way to define attributes for the productions of a formal grammar, associating these attributes to values. The evaluation occurs in the nodes of the abstract syntax tree, when the language is processed by some parser or compiler.
Example:
The following is a simple Context-free grammar which can describe a language made up of multiplication and addition of integers.
The following attribute grammar can be used to calculate the result of an expression written in the grammar. Note that this grammar only uses synthesized values, and is therefore an S-attributed grammar.
1. Synthesized attributes:
- The value is computed from the values of attributes of the children
- S-attributed grammar - synthesized attributes only
- Bottom-up propagation
2. Inherited attributes :
An inherited attribute at a node in parse tree is defined using the attribute values at the parent or siblings. Inherited attributes are convenient for expressing the dependence of a programming language construct on the context in which it appears.
