| View previous topic :: View next topic |
| Author |
Message |
evan Guest
|
Posted: Sat Jun 28, 2003 5:18 am Post subject: 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
|
|
| Back to top |
|
 |
John Harrison Guest
|
Posted: Sat Jun 28, 2003 6:36 am Post subject: Re: Evaluate such an expression as: (A and B) xor (C or D) |
|
|
"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 |
|
 |
|