INT Lexer::expectInt( INT & value, INT min, INT max ) { Token token; lex.ExpectTokenType( TT_NUMBER, TT_INTEGER, &token ); INT value = token.GetIntValue(); if( value < min || value > max ) { lex.Error("expected an integer value in range [%u,%u] but got '%s'.\n" ,min,max,token.ToChars()); } return value; }
UINT Lexer::expectUInt( UINT & value, UINT min, UINT max ) { Token token; lex.ExpectTokenType( TT_NUMBER, TT_INTEGER, &token ); INT value = token.GetIntValue(); if( value < 0 ) { dxWarnf("File '%s', line '%d': expected a positive integer value but got '%s'.\n", lex.GetFileName(),lex.GetLineNum(),token.ToChars()); } if( value < min || value > max ) { lex.Error("expected a positive integer value in range [%u,%u] but got '%s'.\n" ,min,max,token.ToChars()); } return (UINT)value; }