In: Computer Science
We are using javaCC notation.This is the full question
Given the following grammar:
Which of the following strings are correct according to this grammar?
Group of answer choices
A C C D X X Y
X X Y
A B C D
A X
A B C D
A C D C
A B C D X Y
A X X X
A X Y X C D
A B X X Y
B C D
A
B X X Y
According to the given gramer
1.The string must start with "A" and follows "B" or "c" or "D" or "x" or "Y"
2.If we see Grammer T it should have either "X" and again
calling T or only "Y".This shows that T always ends with "Y". that
is If we have "X" in the string it should have any number of "X"
and should ends with Y:
eg:XY,XXY,XXXXXY etx they are correct strings
X,XX,XYX etc which ends with X are incorrect strings.
So by considering the about two points
1. ACCDXXY is a correct string.
3.ABCD is correct string
4.ACDC is correct string.
5.ABCDXY is correct string
8.ABXXY is correct string.
10.A is correct string. There("B"|T|V)+ "+" represents either 0 or
n times.
2.XXY is incorrect because of reason 1
6.AXXX is incorrect string because of reason 2
7.AXYXCD is incorrect string because of reason 2
9.BCD is incorrect string because of reason 1
11.BXXY is incorrect string because of reason 1