Interpreter

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Interpreter

 
0
  #1
Jun 30th, 2008
I am trying to write an Interpreter but are not really sure about the methods that are used for this.
What I think I have understood is for the example below, I will have to parse out 3 things from the string.
"Number1", "==" and "2" and associate these to maps in some way ?

Though I dont know much more than this and are not sure where to begin how to do this ?
What could be the first step.
  1. int Number1 = 2;
  2. std::string Criteria = "Number1 == 2";
  3.  
  4. if ( Criteria )
  5. {
  6. MessageBox::Show("Number1 has a Value of 2");
  7. }
Last edited by Jennifer84; Jun 30th, 2008 at 5:13 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,802
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 747
Team Colleague
Narue's Avatar
Narue Narue is online now Online
Code Goddess

Re: Interpreter

 
1
  #2
Jun 30th, 2008
Infix notation is relatively difficult to parse. If you're doing this to learn how interpreters work, I'd recommend starting with a simpler syntax. For example, instead of "Number1 == 2", you could more easily parse "Number1 2 ==" (ie. postfix notation) with a simple stack.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: Interpreter

 
0
  #3
Jun 30th, 2008
Thank you.. I am not sure but if there could be any Tutoriouls about how interpreters is written.. Perheps this could be a good start also.
I have googled "Interpreters C++" but cant really find this. If there is any links anywhere I would be more than interested to read them.

Originally Posted by Narue View Post
Infix notation is relatively difficult to parse. If you're doing this to learn how interpreters work, I'd recommend starting with a simpler syntax. For example, instead of "Number1 == 2", you could more easily parse "Number1 2 ==" (ie. postfix notation) with a simple stack.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,802
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 747
Team Colleague
Narue's Avatar
Narue Narue is online now Online
Code Goddess

Re: Interpreter

 
1
  #4
Jun 30th, 2008
>I am not sure but if there could be any Tutoriouls about how interpreters is written..
Not that I know of off the top of my head, but I'm sure they exist. If you want an example, I wrote an extremely simple interpreter a while ago and posted it on Daniweb. You can find it here.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: Interpreter

 
0
  #5
Jun 30th, 2008
That would be really nice to read but when I press the link, the page is not showing and I get:
"404 File Not Found"

Perheps I can search for the Title if you remember what this was called.


Originally Posted by Narue View Post
>I am not sure but if there could be any Tutoriouls about how interpreters is written..
Not that I know of off the top of my head, but I'm sure they exist. If you want an example, I wrote an extremely simple interpreter a while ago and posted it on Daniweb. You can find it here.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,833
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Interpreter

 
0
  #6
Jun 30th, 2008
I think it's this thread. I just took the thread number from the link and typed it in:

http://www.daniweb.com/forums/thread19348.html
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: Interpreter

 
0
  #7
Jun 30th, 2008
Okay, thanks! I will look at this.



Originally Posted by VernonDozier View Post
I think it's this thread. I just took the thread number from the link and typed it in:

http://www.daniweb.com/forums/thread19348.html
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 48
Reputation: yilmazhuseyin is an unknown quantity at this point 
Solved Threads: 5
yilmazhuseyin's Avatar
yilmazhuseyin yilmazhuseyin is offline Offline
Light Poster

Re: Interpreter

 
0
  #8
Jun 30th, 2008
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: Interpreter

 
0
  #9
Jun 30th, 2008
Thanks, this seems to be good to read.

Originally Posted by yilmazhuseyin View Post
herer is some lecture notes.
http://www.cse.iitd.ernet.in/~nvkris...07/csl862.html
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 296
Reputation: tesuji is on a distinguished road 
Solved Threads: 42
tesuji tesuji is offline Offline
Posting Whiz in Training

Re: Interpreter

 
0
  #10
Jun 30th, 2008
howdy

Is this problem not roaring for herd of lex, yacc, flex, gnus, bison?
Also Aho and Sethi might be involved

krs,
tesu
Last edited by tesuji; Jun 30th, 2008 at 9:42 pm.
Information is moving—you know, nightly news is one way, of course, but it's also moving through the blogosphere and through the Internets. I promise you I will listen to what has been said here, even though I wasn't here. Ann and I will carry out this equivocal message to the world. I'm the master of low expectations.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC