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

E

evan

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
 
J

John Harrison

evan said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top