Calculator Parser

This is a discussion on Calculator Parser within the C++ Programming forums, part of the General Programming Boards category; I wanna know how to go about making a calculator Parser. I want the user to be able to input ...

  1. #1
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483

    Calculator Parser

    I wanna know how to go about making a calculator Parser.
    I want the user to be able to input problems of different lenghts, but i dont know how to about breaking the problem into the parts.

    Im thinking maybe store the problem in a string/char[] and then check everyting one by one.

    Any ideas on how to do that, or other ideas about a parser?
    Last edited by mrafcho001; 07-17-2005 at 11:31 AM.

  2. #2
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    Posts
    357
    well, I'm sure people disagree with me because your not trying to make an expandable large scale app, but to do it right you should look into context-free grammars

    For a quick one, buf everythying, first search for * and /, your operators with greater precedence, get the operands on each side and perform the calculation, then go through + and - and do the same thing
    Last edited by valis; 07-17-2005 at 11:41 AM.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21