Consider the following grammar:
A -> aB | b | cBB
B -> aB | bA | aBb
C -> aaA | b | caB
Ans:-
Given,
A -> aB | b | cBB
B -> aB | bA | aBb
C -> aaA | b | caB
let A, the first sets of each RHS of each nonterminal
a] A -> aB | b | cBB
FIRST(aB) = a
FIRST(b) = b
FIRST(cBB) = c
PASSED
b] B -> aB | bA | aBb
FIRST(aB) = {a}
FIRST(bA) = {b}
FIRST(aBb) = {a}
FAILED
c] C -> aaA | b | caB
FIRST(aaA) = {a}
FIRST(b) = {b}
FIRST(caB) = {c}
PASSED
* PROGRAM:
#include <stdio.h>
void A();
void B();
void C();
char input[100];
int i,error;
int main()
{
printf("/n Enter the inputs:");
A();
}
A()
{
if (input(i) == 'a''B') {
i++;
B();
}
else if(input(i) == '|')
{
i++;
}
else if(input(i) == 'b')
{
i++;
}
else if(input(i) == '|')
{
i++;
}
else if(input(i) == 'c''B''B')
{
i++;
B();
}
}
B()
{
if (input(i) == 'a''B') {
i++;
B();
}
else if(input(i) == '|')
{
i++;
}
else if(input(i) == 'b''A')
{
i++;
A();
}
else if(input(i) == '|')
{
i++;
}
else if(input(i) == 'a''B''b')
{
i++;
B();
}
}
C()
{
if (input(i) == 'a''a''A') {
i++;
A();
}
else if(input(i) == '|')
{
i++;
}
else if(input(i) == 'b')
{
i++;
}
else if(input(i) == '|')
{
i++;
}
else if(input(i) == 'c''a''B')
{
i++;
B();
}
}
(10] Eliminate left recursion from the grammar A Ba |Aa c B Bb | Ab 1 d A Ad IB A BA ASJAE Consider the following grammar G: S'S S (S)S|e fa) (10] Construct the collection of the sets of LR(0) items (b) [5] When constructing the action table of SLR parser of G what are the rules to determine the parsing actions? That is, what is the rule for a shift action at state /? What is the rule...
1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming languages according to Sebesta? a. Increased capacity to express ideas. b. Improved background for choosing appropriate languages. c. Increased ability to design new languages. d. Increased ability to learn new languages. 2. (p. 5-6.) What programming language has dominated scientific computing over the past 50 years? a. FORTRAN b. ALGOL c. SNOBOL d. PL/I 3. (p. 6.) What programming language has dominated artificial intelligence...