How can you control associatively in a grammar a By avoiding

How can you control associatively in a grammar? a. By avoiding mathematical operations b. By using EBNF c. By avoiding use of non-terminals on the RHs d. By altering whether productions are left or right recursive e. None of the above. Remember that in EBNF, braces {} are used to describe repetition. given a BNF rule like: A parser is one type of: a. Recognizer b. Reader c. Logic d. Generator e. None of the above Name what the following is and at least ONE benefit of it over BNF/EBNF: Describe what attribute grammars are and ONE example of their use.

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.

 How can you control associatively in a grammar? a. By avoiding mathematical operations b. By using EBNF c. By avoiding use of non-terminals on the RHs d. By al

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site