Thread: Calculator Parser

  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