Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualÁlvaro

Posted 16 December 2012 - 04:12 PM

The hardest part of this is evaluating expressions. The usual solutions are:
A) Convert to reverse polish notation (the algorithm is not hard to find) and execute using a stack-based machine (if you have used HP calculators or programmed the 8087 FPU you'll get a good idea of how this works).
B) Write a recursive-descent parser.
C) Use a parser generator, like bison or yacc. I am sure there are newer ones, but I am a dinosaur. ;)
D) Use Boost.Spirit.

You already said you can't use D, and it sounds like C might not be acceptable either. B is a great exercise and I strongly recommend you go that route. If you try it and have trouble with it, post your attempt and I can help you fix it.

By the way, why the restriction of not using third-party libraries? Homework?

#2Álvaro

Posted 16 December 2012 - 04:11 PM

The hardest part of this is evaluating expressions. The usual solutions are:
A) Convert to reverse polish notation (the algorithm is not hard to find) and execute using a stack-based machine (if you have used HP calculators or programmed the 8087 FPU you'll get a good idea of how this works).
B) Write a recursive-descent parser.
C) Use a stand-alone parser, like bison or yacc. I am sure there are newer ones, but I am a dinosaur. ;)
D) Use Boost.Spirit.

You already said you can't use D, and it sounds like C might not be acceptable either. B is a great exercise and I strongly recommend you go that route. If you try it and have trouble with it, post your attempt and I can help you fix it.

By the way, why the restriction of not using third-party libraries? Homework?

#1Álvaro

Posted 16 December 2012 - 04:09 PM

The hardest part of this is evaluating expressions. The usual solutions are:
A) Convert to reverse polish notation (the algorithm is not hard to find) and execute using a stack-based machine (if you have used HP calculators or programmed the 8087 FPU you'll get a good idea of how this works).
B) Write a recursive-descent parser.
C) Use a stand-alone parser, like bison or yacc. I am sure there are newer ones, but I am a dinosaur. ;)
D) Use Boost.Spirit.

It sounds like C and D are out of the question. B is a great exercise and I strongly recommend you go that route. If you try it and have trouble with it, post your attempt and I can help you fix it.

PARTNERS