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. Advertisements

  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. Advertisements

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:
    563
    Charlie@NISH
    Aug 12, 2005
  2. Replies:
    1
    Views:
    623
    Karl Seguin [MVP]
    Mar 28, 2006
  3. Replies:
    28
    Views:
    12,445
    Fathzer
    Aug 29, 2012
  4. evan
    Replies:
    0
    Views:
    771
  5. Marco Traverso
    Replies:
    7
    Views:
    1,933
    Marco Traverso
    Dec 6, 2003
  6. Jason luo
    Replies:
    3
    Views:
    792
    Peter Ammon
    Aug 19, 2004
  7. Jack Frillman
    Replies:
    2
    Views:
    3,193
    Martin Honnen
    Mar 17, 2011
  8. Piergiuliano Bossi

    evaluate and print an expression

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