Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Coder's Corner Lounge (http://www.programmingforums.org/forum11.html)
-   -   context-free grammar (http://www.programmingforums.org/showthread.php?t=11262)

programmingnoob Sep 6th, 2006 6:16 PM

context-free grammar
 
if i have posted it in a wrong section, please feel free to move it!
I have to write a context-free grammr for the language in which a sentence has 0 or more b followed by a c followed by a string of d, and the number of d equals number of b!
Problem! ... how do i keep track of the number of b?? there is no way, right? hmm
thanks!

Jimbo Sep 6th, 2006 8:38 PM

what if you just made sure there was a d for every b? Something like:
:

S = <something1>
T = <something2>b<something3>d<something4>
U = c

Just hook those up properly and you'll have it. (It's really easy if you think about it, but I didn't want to just give the answer straight out; it's a pretty easy one-liner too). If you need more explanation, I'll see if I can do a better job :o

a thing Sep 6th, 2006 10:57 PM

Does anyone else see the irony here?

programmingnoob Sep 6th, 2006 11:23 PM

Quote:

Originally Posted by Jimbo
what if you just made sure there was a d for every b? Something like:
:

S = <something1>
T = <something2>b<something3>d<something4>
U = c

Just hook those up properly and you'll have it. (It's really easy if you think about it, but I didn't want to just give the answer straight out; it's a pretty easy one-liner too). If you need more explanation, I'll see if I can do a better job :o



are you sure it's that easy?? btw i am not supposed to use left recursion

programmingnoob Sep 6th, 2006 11:24 PM

Quote:

Originally Posted by a thing
Does anyone else see the irony here?

what irony?

Dameon Sep 6th, 2006 11:33 PM

Quote:

Originally Posted by a thing
Does anyone else see the irony here?

Yes. Yes I do.

programmingnoob Sep 7th, 2006 12:03 AM

Quote:

Originally Posted by Dameon
Yes. Yes I do.

might as well share it with me? lol

a thing Sep 7th, 2006 7:55 PM

You want to do a project having to do with grammar in another language, yet you don't use proper grammar in English.

programmingnoob Sep 7th, 2006 10:21 PM

hey, so i know how to write context-free grammar for this q now, but I need practice! could you guys come up with more questions like this that requires me to write context-free grammar?
or tell me a site where i could find such questions (and their solutions!!)

Jimbo Sep 7th, 2006 11:25 PM

my best guess would be to google some school sites and look for homework assignments... no guarantees on getting solutions though


All times are GMT -5. The time now is 1:01 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC