COMPILER DESIGN

SYNTAX ANALYSIS

ROLE OF THE PARSER

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
ab* in a regular expression denotes
A
zero or more occurrences of a and b
B
zero or more occurrences of a or b
C
one or more occurrences of a and b
D
letter a followed by zero or more occurrences of b
Explanation: 

Detailed explanation-1: -a*b* corresponds to the set of strings consisting of zero or more a’s followed by zero or more b’s. a*b+a* corresponds to the set of strings consisting of zero or more a’s followed by one or more b’s followed by zero or more a’s.

Detailed explanation-2: -A regular expression followed by an asterisk ( * ) matches zero or more occurrences of the regular expression. If there is any choice, the first matching string in a line is used. A regular expression followed by a plus sign ( + ) matches one or more occurrences of the one-character regular expression.

Detailed explanation-3: -Hence a string of L consists of zero or more aab’s in front and zero or more bb’s following them. Thus (aab)*(bb)* is a regular expression for L.

Detailed explanation-4: -In regular expressions, asterisk (*) means “match zero or more of the preceding character.” To make a “wildcard” (that is, an expression that matches anything) with regular expressions, you must use ‘. *’ (dot asterisk). This expression means, “match zero or more of any character.”

There is 1 question to complete.