Hacker News new | past | comments | ask | show | jobs | submit login

Well, to be fair, your calculator seems to miss the point of being a calculator...

    > 10/2*2
    2.5



Clearly a bug. Thanks when I have more time I will fix it. I didn't give much thought to operator precedence, I assumed the user would specify it using parentheses.

The idea is what is important though. Recursive descent parsing uses the functions that correspond to types in the grammar to mutually call each other thus parsing the expression recursively in a descending fashion.


I decided to simply add to the description, "use parentheses to specify operator precedence."




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: