Please make a Context Free Grammar (CFG) for the regular languages below:
The language that is in C++ and containing lowercase and upper case letters, and also can have digits, and can also contain the underscore character '_', and it must begin with an underscore or a letter.
Language containing lowercase and upper case letters, and also can have digits, and can also contain the underscore character '_', and it must begin with an underscore or a letter:
Context Free Grammar :
S-> _A | UA | LA
A-> _A | LA | UA | DA | epsilon
L-> a|b|c|d...........x|y|z
U-> A|B|C|D.............X|Y|Z
D->0|1|2.......8|9
Explanation:
S-> _A | UA | LA
indicates that it must begin with a underscore(_) , U(uppercase
character ) or
L(lowercase letter)
A-> _A | LA | UA | DA | epsilon
indcates that any number of underscores, lowercase characters,
uppercase characters
or digits can be added.
and last three productions are used to get the terminal expression.
Get Answers For Free
Most questions answered within 1 hours.