COMPUTER SCIENCE AND ENGINEERING
COMPILER DESIGN
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
L(LD)*
|
|
LD*
|
|
L(L|D)*
|
|
(L|D)*
|
Detailed explanation-1: -1.7 Example: Identifiers (or Names) [a-zA-Z ][0-9a-zA-Z ]* or [a-zA-Z ]* Begin with one letters or underscore, followed by zero or more digits, letters and underscore. You can use metacharacter for a word character [a-zA-Z0-9 ] .
Detailed explanation-2: -Which of the following expression defines an identifier? Explanation: Clearly, option (C) is correct as a valid identifier can only start with a letter followed by any number of letters or digits. L(L + D) * can only generate the strings for a valid identifier.
Detailed explanation-3: -In some programming languages, an identifier is permitted to be a letter followed by any number of letters or digits. If L and D denotes the set of letters and digit respectively.
Detailed explanation-4: -A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for “find” or “find and replace” operations on strings, or for input validation.