Grammar
Question 1 |
In the following grammar
X ::= X ⊕ Y/Y Y ::= Z * Y/Z Z ::= id
Which of the following is true?
‘⊕’ is left associative while ‘*’ is right associative | |
Both ‘⊕’ and ‘*’ is left associative | |
‘⊕’ is right associative while ‘*’ is left associative | |
None of the above |
Question 1 Explanation:

⊕ is left associative.
* is right associative.
Question 2 |
A grammar that is both left and right recursive for a non-terminal, is
Ambiguous | |
Unambiguous | |
Information is not sufficient to decide whether it is ambiguous or unambiguous | |
None of the above |
Question 2 Explanation:
If a grammar is both left and right recursion, then grammar may or may not be ambiguous.
Question 3 |
Given the following expression grammar:
E → E * F | F + E | F F → F - F | id
which of the following is true?
* has higher precedence than + | |
- has higher precedence than * | |
+ and – have same precedence | |
+ has higher precedence than * |
Question 3 Explanation:
The operator which is in low level that can have high preference.
Order of precedence is *, +, -.
Here * and + have equal preference, '-' can have higher precedence than + and *.
Order of precedence is *, +, -.
Here * and + have equal preference, '-' can have higher precedence than + and *.
Question 4 |
Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
Removing left recursion alone | |
Factoring the grammar alone | |
Removing left recursion and factoring the grammar | |
None of the above |
Question 4 Explanation:
Left recursion removing (or) factoring the given grammar are not sufficient to convert an arbitrary CFG to an LL(1) grammar.
To convert an arbitrary CFG to an LL(1) grammar we need to remove the left recursion and as well as left factoring without that we cannot convert.
To convert an arbitrary CFG to an LL(1) grammar we need to remove the left recursion and as well as left factoring without that we cannot convert.
There are 4 questions to complete.