Solved

Context free grammar

Posted on 2011-02-23
2
313 Views
Last Modified: 2012-05-11
Hello experts,
How I will translate a regular expression which contains a group of characters to cfg?
For example if I have this regular expression:
[wx]*ocl(qw|zx)*
how I will translate this?
And also how I will define a cfg which will  not let me define this regular expression using bracketing?
0
Comment
Question by:puffyy_beginner
  • 2
2 Comments
 
LVL 13

Accepted Solution

by:
Superdave earned 500 total points
ID: 34962101
1.  Could you clarify whether this is your homework?
2.  I don't understand the second question.  Are you asking for a CFG that is not an RE?
0
 
LVL 13

Expert Comment

by:Superdave
ID: 34962159
Anyway, you can use "recursion" in a production to make something repeat:

wx ::= "w"|"x"
wxstar := "" | (wx wxstar)
 

If I guessed right about what your second question meant, having a language with the rule that you have the same number of a repeating character in two places is a typical example of a CFG that is not regular.  I'll let you work out the grammar for it until I find out about my first question.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question