C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Evaluate such an expression as: (A and B) xor (C or D)

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
evan
Guest





PostPosted: Sat Jun 28, 2003 5:18 am    Post subject: Evaluate such an expression as: (A and B) xor (C or D) Reply with quote



Can you give me a hint as how to go about evaluating such an expression. The
actual expression will be different every time (user input). The data will
be sorted in an array or a list.

Thanks,

Evan


Back to top
John Harrison
Guest





PostPosted: Sat Jun 28, 2003 6:36 am    Post subject: Re: Evaluate such an expression as: (A and B) xor (C or D) Reply with quote




"evan" <epanagio (AT) frontiernet (DOT) net> wrote

Quote:
Can you give me a hint as how to go about evaluating such an expression.
The
actual expression will be different every time (user input). The data will
be sorted in an array or a list.

Thanks,

Evan


You have to write a parser. Best way would be to find an example in a book.
Writing parsers is a big topic in computer science and many books cover this
in more or less depth.

Stroustrup has an example in 'The C++ Programming Language' 3rd edition. His
is an evaluator for arithmetic expressions whereas you seem to have a
logical expression but the principles are just the same.

john



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.