Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Evaluate such an expression as: (A and B) xor (C or D) (http://www.velocityreviews.com/forums/t267824-evaluate-such-an-expression-as-a-and-b-xor-c-or-d.html)

evan 06-28-2003 05:18 AM

Evaluate such an expression as: (A and B) xor (C or D)
 
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



John Harrison 06-28-2003 06:36 AM

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

"evan" <epanagio@frontiernet.net> wrote in message
news:zy9La.231$ba2.220@news02.roc.ny...
> 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




All times are GMT. The time now is 01:02 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.