COMPILER DESIGN

SYNTAX ANALYSIS

ROLE OF THE PARSER

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
The regular expression (0|1)*(0|1) represents a language with
A
Odd nonempty strings
B
Even nonempty strings
C
Empty and nonempty binary strings
D
Nonempty binary strings
Explanation: 

Detailed explanation-1: -Consider the regular expression (0|1)*. This stands for the set of all strings of binary digits. If we match this pattern against 0101B, there are 4 possible substrings it can match, namely 0, 01, 010, and 0101. Often we try to match the longest possible substring, in this case 0101.

Detailed explanation-2: -Since they mean “(0 or 1) repeated 0 or more times", both of them can generate the language 101 .

Detailed explanation-3: -Every regular expression over 0, 1 is itself a string over the 8-symbol alphabet 0, 1, +, *, (, ), , Ø. regular expression is a base-9 representation of a unique integer. Countably infinite!

Detailed explanation-4: -It matches “", “01", “0101", “01010101", etc. (01)* is nothing like (0*1*). The latter is just zero or more 0s followed by zero or more 1s, and never a 0 after a 1.

There is 1 question to complete.