Question

Please make a Context Free Grammar (CFG) for the regular languages below: The language that is...

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.

Homework Answers

Answer #1

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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
For the given language descriptions below, write a context-free grammar. Assume that your alphabet is ∑...
For the given language descriptions below, write a context-free grammar. Assume that your alphabet is ∑ = {?, ?, ?}, define a grammar that generates a string cmanbanck, where ‘m’, ‘k’, and ‘n’ represents the amount of a character. Assume that m, k ≥ n and m, k, n ≥ 0.
Problem 5 Regular Expressions. a) Define a regular expression for all strings of odd length, over...
Problem 5 Regular Expressions. a) Define a regular expression for all strings of odd length, over the alphabet of {0}. b) Define a regular expression for identifiers over the alphabet of {A,B,C,a,b,c,0,1,2,3,4,5,6,7,8,9}, such that an identifier must begin with an alphabetic character and must contain at least one numeric character. c) Try to modify the definition above so that identifiers still begin with an alphabetic character, but after that, it must contain at least one numeric, at least one lower-case...
Problem 4. Convert RE to CFG We saw in class how to construct CFGs for U,...
Problem 4. Convert RE to CFG We saw in class how to construct CFGs for U, *, and o operations for existing CFL's. We also saw how to construct CFG's for regular expressions empty-set, e, and c (where c is some member of S). a) Using these constructions, create CFG for the RE R = x ((yx)* U y). This is an algorithm for converting any RE to a CFG with start variable S0. It works as follows: create an...
Write a BNF grammar for a new language called 4040. It should include the following rules:...
Write a BNF grammar for a new language called 4040. It should include the following rules: Variable definitions should start with var. There must be only single space after var. Variable names should come after the var and single space. Variable names should start with a letter or underscore(_). Starting with a digit is not allowed. Variable names can have digits after the first letter. There can be multiple variable names separated by comma. Between variables, spaces are allowed. There...
can someone please answer these in the correct format: Assignment #2 Total 43 pts (12pts) List...
can someone please answer these in the correct format: Assignment #2 Total 43 pts (12pts) List at least 3 words in the language and write regular expressions for the following: S = {a,b,c} L = {all words that have only one letter c in them} S = {a,b,c} L = {all words in which c’s appear in groups of two} S = {a,b,c} L = { all words that begin and end with the same letter} S = {a,b,c} L...
Use python language please #One of the early common methods for encrypting text was the #Playfair...
Use python language please #One of the early common methods for encrypting text was the #Playfair cipher. You can read more about the Playfair cipher #here: https://en.wikipedia.org/wiki/Playfair_cipher # #The Playfair cipher starts with a 5x5 matrix of letters, #such as this one: # # D A V I O # Y N E R B # C F G H K # L M P Q S # T U W X Z # #To fit the 26-letter alphabet into...
Write a program that takes a string of characters (including spaces) as input, computes the frequency...
Write a program that takes a string of characters (including spaces) as input, computes the frequency of each character, sorts them by frequency, and outputs the Huffman code for each character.   When you are writing your program, you should first test it on a string of 7 characters, so you can check it. PLEASE NOTE: Your program must work for any text that has upper and lower case letters digits 0 - 9, commas, periods, and spaces. Please submit the...
***Programming language is Java. After looking at this scenario please look over the requirements at the...
***Programming language is Java. After looking at this scenario please look over the requirements at the bottom (in bold) THIS IS ALL THAT WAS PROVIDED. PLEASE SPECIFY ANY QUESTIONS IF THIS IS NOT CLEAR (don't just say more info, be specific)*** GMU in partnership with a local sports camp is offering a swimming camp for ages 10-18. GMU plans to make it a regular event, possibly once a quarter. You have been tasked to create an object-oriented solution to register,...
For this assignment, you need to submit a Python program that gathers the following employee information...
For this assignment, you need to submit a Python program that gathers the following employee information according to the rules provided: Employee ID (this is required, and must be a number that is 7 or less digits long) Employee Name (this is required, and must be comprised of primarily upper and lower case letters. Spaces, the ' and - character are all allowed as well. Employee Email Address (this is required, and must be comprised of primarily of alphanumeric characters....
Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered...
Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle's diary. The diary was with Ginny and it forced her to open the Chamber of Secrets. Harry wants to know the different people who had ever possessed the diary to make sure they are not under its influence. He has names of n people who possessed the diary in order. You need to tell, for each...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT