COMPILER DESIGN

SYNTAX ANALYSIS

ROLE OF THE PARSER

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Regular expression for an identifier is
A
(letter | digit)*
B
(letter)(letter | digit)*
C
(letter)* (letter | digit)*
D
(letter)+ (letter | digit)*
Explanation: 

Detailed explanation-1: -identifier = letter (letter | digit)* real-numeral = digit digit* .

Detailed explanation-2: -Regular expression is an important notation for specifying patterns. Each pattern matches a set of strings, so regular expressions serve as names for a set of strings. Programming language tokens can be described by regular languages. The specification of regular expressions is an example of a recursive definition.

Detailed explanation-3: -Regular Expression: (0+10)*(+1) – L((0+10)*(+1)) = all strings of 0’s and 1’s without two consecutive 1’s. Regular Expression: (0+1)(0+1) – L((0+1)(0+1) ) = 00, 01, 10, 11 = all strings of 0’s and 1’s of length 2. For every regular expression there is a finite automaton.

Detailed explanation-4: -L* denotes Kleene closure and is given by L* = U Li i=0 example : 0* =, 0, 00, 000, ………………………………… Language includes empty words also. L+ denotes Positive closure and is given by L+= Li i=1 example:0+=0, 00, 000, ……………………………………..

There is 1 question to complete.