yep, that's what I thought XD
Do a good job there = flamed
Uhm, if I look at http://www.gamedev.net/community/forums/viewposts.asp?ID=8836&RestrictTo=Replies, then three years later http://www.gamedev.net/community/forums/viewposts.asp?ID=122861&RestrictTo=Replies under ban evasion, then I wonder what good stuff that would be in that case.
Anyways, Vincenzo, so far that's good work.
Let me analyze your code syntactically/cosmetically only for now:
using namespace std;
Dirty, not good practice.
#define MAXIDSIZE 256
Hardcoded maximum size. Not good practice, error prone.
bool EatSymbol( void )
Putting "void" there is C practice, but is uncommon C++ practice.
if ( GetNextToken()==false )
Explitly comparing against boolean literals is uncommon and redundant. Just write "if (!GetNextToken())", which many programmers will also find more readable.
Not standard C++ but MSVC++. Use the literal "0" instead.
You might want to initialize instead of assign to your members: "CExprParser() : Value(0.0f), Look(0)".
bool Parse( char *text )
If you don't plan to modify the passed string, then use "const char *text". See also http://www.parashift.com/c++-faq-lite/const-correctness.html about const correct code.
int _tmain( )
In standard C++, we say "int main ()", "_tmain()" is MSVC++ again.
parser.Parse( &text );
21.3.4 basic_string element access [lib.string.access]
const_reference operator(size_type pos) const;
reference operator(size_type pos);
1 Returns: If pos \< size(), returns data()[pos]. Otherwise, if pos == size(), the const version returns charT(). Otherwise, the behavior is undefined.
Better use text.c_str():
21.3.6 basic_string string operations [lib.string.ops]
const charT* c_str() const;
1 Returns: A pointer to the initial element of an array of length size() + 1 whose first size() elements equal the corresponding elements of the string controlled by *this and whose last element is a null character specified by charT().
The internal representation of std::string that you are dissecting does not have a \0 (null character).
What if your program is run in non-interactive mode?
edit: I forgot about your list of #includes:
//#include "stdafx.h" //! why?
//#include <fstream> //! why?
//#include <cstdarg> //! why?
#include <cassert> //! assert.h is for C
#include <cstring> //! was missing, needed for memset()
#include <cstdlib> //! was missing, needed for strtod()
edit: Another issue:
Here you should catch a division by zero before it happens, otherwise your program yields undefined behaviour (cf. ISO/IEC 14882:2003(E), Section 5 Expressions:
If during the evaluation of an expression, the result is not mathematically defined or not in the range of representable values for its type, the behavior is undefined