Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 6th, 2006, 5:16 PM   #1
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
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!
programmingnoob is offline   Reply With Quote
Old Sep 6th, 2006, 7:38 PM   #2
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 751
Rep Power: 3 Jimbo is on a distinguished road
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
Jimbo is offline   Reply With Quote
Old Sep 6th, 2006, 9:57 PM   #3
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
Does anyone else see the irony here?
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Sep 6th, 2006, 10:23 PM   #4
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
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 is offline   Reply With Quote
Old Sep 6th, 2006, 10:24 PM   #5
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
Quote:
Originally Posted by a thing
Does anyone else see the irony here?
what irony?
programmingnoob is offline   Reply With Quote
Old Sep 6th, 2006, 10:33 PM   #6
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Quote:
Originally Posted by a thing
Does anyone else see the irony here?
Yes. Yes I do.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Sep 6th, 2006, 11:03 PM   #7
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
Quote:
Originally Posted by Dameon
Yes. Yes I do.
might as well share it with me? lol
programmingnoob is offline   Reply With Quote
Old Sep 7th, 2006, 6:55 PM   #8
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
You want to do a project having to do with grammar in another language, yet you don't use proper grammar in English.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Sep 7th, 2006, 9:21 PM   #9
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
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!!)
programmingnoob is offline   Reply With Quote
Old Sep 7th, 2006, 10:25 PM   #10
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 751
Rep Power: 3 Jimbo is on a distinguished road
my best guess would be to google some school sites and look for homework assignments... no guarantees on getting solutions though
Jimbo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Free VS2k5 & MSDN library & other stuff Mad_guy Coder's Corner Lounge 17 Jun 16th, 2006 10:06 PM
least significant 1 bit eax Assembly 14 May 20th, 2006 5:17 PM
Free Ubuntu CD's coldDeath Coder's Corner Lounge 14 Sep 24th, 2005 2:19 AM
Free Cross-Frame Menu crmpicco HTML / XHTML / CSS 6 May 27th, 2005 1:47 PM
how to use malloc() and free() FarAway C++ 5 Feb 16th, 2005 11:08 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:30 PM.

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