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

Discussion in 'C++' started by evan, Jun 28, 2003.

  1. evan

    evan Guest

    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
    evan, Jun 28, 2003
    #1
    1. Advertising

  2. "evan" <> wrote in message
    news:zy9La.231$...
    > 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
    John Harrison, Jun 28, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. EDom

    How to evaluate an expression

    EDom, Jul 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    447
    Charlie@NISH
    Aug 12, 2005
  2. evan
    Replies:
    0
    Views:
    666
  3. Jason luo
    Replies:
    3
    Views:
    520
    Peter Ammon
    Aug 19, 2004
  4. Jack Frillman
    Replies:
    2
    Views:
    2,663
    Martin Honnen
    Mar 17, 2011
  5. Piergiuliano Bossi

    evaluate and print an expression

    Piergiuliano Bossi, Feb 9, 2004, in forum: Ruby
    Replies:
    10
    Views:
    192
    Robert Klemme
    Feb 12, 2004
Loading...

Share This Page